8_graphs.v3

8_graphs.v3 - CS161 - Graph Algorithms David Kauchak Types...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS161 - Graph Algorithms David Kauchak Types of graphs What is a graph? A graph is a set of vertices V and a set of edges ( u,v ) E where u,v V undirected directed weighted Some special cases tree - connected, undirected graph without any cycles DAG (directed acyclic graph) - directed graph without any cycles complete graph - a graph where every vertex is connected bipartite graph - a graph where every vertex can be partitioned into two sets X and Y such that all edges connect a vertex u X and a vertex v Y Examples Transportation networks (flights, roads, etc.) Communication networks Web Bayesian networks Social networks Circuit design Representation 1 Adjacency list Each vertex u V contains an adjacency list of the set of vertices v such that there exists an edge ( u,v ) E Example of undirected and directed Adjacency matrix A graph is represented by a | V | x | V | matrix A such that a ij = braceleftBigg 1 if ( i,j ) E 0 otherwise Example of undirected and directed Tradeoffs Dense vs. sparse graph Adjacency list: Space efficient, e.g. web Adjacency matrix: constant time lookup to see if an edge exists Best of both worlds? Weighted graphs Adjacency list: store the weight in the adjacency list Adjacency matrix: a ij = braceleftBigg weight if ( i,j ) E otherwise Graph algorithms graph traversal (BFS, DFS) Shortest path from a to b * unwieghted * weighted positive weights * negative/positive weights All pair shortest paths Are all nodes in the graph connected?...
View Full Document

Page1 / 8

8_graphs.v3 - CS161 - Graph Algorithms David Kauchak Types...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online