Directed Graphs

Glossary

  • A self-loop is an edge that connects a vertex to itself.

  • Two edges are parallel if they connect the same ordered pair of vertices.

  • The outdegree of a vertex is the number of edges pointing from it.

  • The indegree of a vertex is the number of edges pointing to it.

  • A subgraph is a subset of a digraph's edges (and associated vertices) that constitutes a digraph.

  • A directed path in a digraph is a sequence of vertices in which there is a (directed) edge pointing from each vertex in the sequence to its successor in the sequence, with no repeated edges.

  • A directed path is simple if it has no repeated vertices.

  • A directed cycle is a directed path (with at least one edge) whose first and last vertices are the same.

  • A directed cycle is simple if it has no repeated vertices (other than the requisite repetition of the first and last vertices).

  • The length of a path or a cycle is its number of edges.

  • We say that a vertex w is reachable from a vertex v if there exists a directed path from v to w.

  • We say that two vertices v and w are strongly connected if they are mutually reachable: there is a directed path from v to w and a directed path from w to v.

  • A digraph is strongly connected if there is a directed path from every vertex to every other vertex.

  • A digraph that is not strongly connected consists of a set of strongly connected components, which are maximal strongly connected subgraphs.

  • A directed acyclic graph (or DAG) is a digraph with no directed cycles.

DiGraph: Set of vertices connect pairwise by directed edges

Adjacency List Representation

Java Implementation

Java implementation is same as undirected graph

Java implementation is same as undirected graph

Depth First Order

Depth-first search search visits each vertex exactly once. Three vertex orderings are of interest in typical applications:

  • Preorder: Put the vertex on a queue before the recursive calls.

  • Postorder: Put the vertex on a queue after the recursive calls.

  • Reverse postorder: Put the vertex on a stack after the recursive calls.

Java Implementation

DI-Graph Applications

****

Last updated

Was this helpful?