The document discusses various graph algorithms and representations including:
- Adjacency lists and matrices for representing graphs
- Breadth-first search (BFS) which explores edges from a source vertex s level-by-level
- Depth-first search (DFS) which explores "deeper" first, producing a depth-first forest
- Classifying edges as tree, back, forward, or cross based on vertex colors in DFS
- Topological sorting of directed acyclic graphs (DAGs)
- Strongly connected components (SCCs) in directed graphs and using the transpose
3. Adjacency List Representation of a Graph For each u є V , the adjacency list Adj [ u ] contains all the vertices v such that there is an edge ( u , v ) є E .
4. Adjacency Matrix Representation of a Graph The adjacency-matrix representation of a graph G consists of a | V | × | V | matrix A = ( aij ) such that a ij =1 if (i,j) є E =o otherwise
14. Depth-first Search The strategy followed by depth-first search is, as its name implies, to search "deeper" in the graph whenever possible.
15. Depth-first Search The predecessor sub-graph of a depth-first search forms a depth-first forest composed of several depth-first trees . The edges in Eπ are called tree edges .
16.
17. Depth-first Search Each vertex v has two timestamps: the first timestamp d [ v ] records when v is first discovered (and grayed), and the second timestamp f [ v ] records when the search finishes examining v 's adjacency list (and blackens v ).
23. Classification of Edges We can define four edge types in terms of the depth-first forest Gπ produced by a depth-first search on G . 1. Tree edges are edges in the depth-first forest Gπ . Edge ( u , v ) is a tree edge if v was first discovered by exploring edge ( u , v ). 2. Back edges are those edges ( u , v ) connecting a vertex u to an ancestor v in a depth first tree. Self-loops, which may occur in directed graphs, are considered to be back edges.
24. Classification of Edges 3. Forward edges are those non-tree edges ( u , v ) connecting a vertex u to a descendant v in a depth-first tree. 4. Cross edges are all other edges.
25. Classification of Edges The DFS algorithm can be modified to classify edges as it encounters them. The key idea is that each edge ( u , v ) can be classified by the color of the vertex v that is reached when the edge is first explored . 1. WHITE indicates a tree edge, 2. GRAY indicates a back edge, and 3. BLACK indicates a forward or cross edge.
26. Topological Sort A topological sort of a graph can be viewed as an ordering of its vertices along a horizontal line so that all directed edges go from left to right.
29. Strongly Connected Components A strongly connected component of a directed graph G=(V,E) is a maximal set of vertices such that for every pair of vertices u and v in C , we have both u ~v and v ~u
31. Strongly Connected Components The transpose of a graph G, G T =(V,E T ) is used for finding the strongly connected components of a graph G=(V,E) It is interesting to observe that G and G T have exactly the same strongly connected components