Directed Graphs

Directed Graph

as in the undirected case, with the difference that edges are (directed) pairs

  • edges are also called arcs
  • usually, we allow loops, with
  • is the source node, is the target
  • a path is a sequence of vertices, with in for all . is OK.
  • a cycle is a path
  • a directed acyclic graph (DAG) is a directed graph with no cycle

Directed Graphs basics

Definition:

  • the in-degree of is the number of edges of the from
  • the out-degree of is the number of edges of the form

Data structures:

  • adjacency lists
  • adjacency matrix (not symmetric anymore)

BFS and DFS for directed graphs

The algorithms work without any change. We will focus on DFS.

Still true:

  • we obtain a partition of into vertex-disjoint trees
  • when we start exploring a vertex , any with an unvisited path becomes a descendant of (white path lemma)
  • properties of start and finish times

But there can exist edges connecting the trees .

A directed graph G can be seen as a DAG of disjoint strongly connected components (SCC)

For any directed graphs, you will always be able to find its SCCs (even if that means its just a single SCC). Regardless, you will be able to create a DAG out of the SCCs

Some questions:

  • For a vertex in a directed graph , are the neighbours of of vertex only the vertices where there is an edge from to ?
    • Yup, so the number of neighbours of in a directed graph is always equal to the out-degree of .