Single-source directed paths: given a digraph and source.Is there a directed path from any vertex in the set Given a digraph and a set of source vertices, Uses depth-first search to solve this problem. Given a digraph and source s, is there a directed path from Implements the same API using the adjacency-matrix representation.ĭepth-first search and breadth-first search are fundamentally digraph-processing Implements the digraph API using the adjacency-lists representation. We use the adjacency-lists representation, where we maintainĪ vertex-indexed array of lists of the vertices connected by an edge To iterate through the vertices adjacent from a given vertex. Strongly connected components, which are maximal strongly connectedĪ directed acyclic graph (or DAG) is a digraph with no If they are mutually reachable: there is a directed path from v to wĪ digraph is strongly connected if there is a directed path fromĪ digraph that is not strongly connected consists of a set of We say that two vertices v and w are strongly connected If there exists a directed path from v to w. We say that a vertex w is reachable from a vertex v The length of a path or a cycle is its number of edges. (other than the requisite repetition of the first and last vertices). Whose first and last vertices are the same.Ī directed cycle is simple if it has no repeated vertices Pointing from each vertex in the sequence to its successor in the sequence,Ī directed path is simple if it has no repeated vertices.Ī directed cycle is a directed path (with at least one edge) Of vertices in which there is a (directed) edge The indegree of a vertex is the number of edges pointing to it.Ī subgraph is a subset of a digraph's edges (and associatedĪ directed path in a digraph is a sequence The outdegree of a vertex is the number of edges pointing from it. Two edges are parallel if they connect the same ordered pair of We use the names 0 through V-1 for the vertices in a V-vertex graph.Ī self-loop is an edge that connects a vertex to Pair and points to the second vertex in the pair. We say that a directed edge points from the first vertex in the Of directed edges that each connects an ordered pair of vertices.