Directed Graphs
-
Upload
eugenewong -
Category
Documents
-
view
34 -
download
5
description
Transcript of Directed Graphs
Directed graphs
Digraphs
A digraph (or a directed graph) is a graph in 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 an undirected path in a directed graph.
Adjacency matrix of a directed graph
The adjacency matrix of a directed graph is not symmetrical about its major diagonal.
A B C D
A 1 1 0 1
B 0 0 0 1
C 0 0 0 0
D 1 0 1 0
Reachability of directed graph
Depth-first search (DFS)
Find all vertices reachable from s long a directed path