Directed Graphs

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 9

Directed graphs

Digraphs

A digraph (or adirected graph) is a graphin which the edges are


directed.

In an directed graph, we write edges using parentheses to denote


ordered pairs. For example, edge (2,3) is directed from 2 to 3 , which is
different than the directed edge (3,2) from 3 to 2.

Diagramatic representation

Paths in directed graphs

The blue lines highlight P = ((6,4), (4,5), (5,1)) which is a directed path
from 6 to 1 in directed graph G.

Undirected paths

The red lines highlight P = ((6,4), (4,3), (3,2), (2,5), (5,1)); the 4th edge
of P -- (2,5) -- goes the "wrong way"; and so P is not a directed path in
G. We instead refer to P as anundirected pathin a directed graph.

Adjacency matrix of a directed graph

The adjacency matrix of a directed graph is not symmetrical about its


major diagonal.

Reachability of directed graph

Depth-first search (DFS)

Find all vertices reachable from s


long a directed path

You might also like