Directed Graphs

9
Directed graphs

description

Directed graph presentation

Transcript of Directed Graphs

Page 1: Directed Graphs

Directed graphs

Page 2: 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.

Page 3: Directed Graphs

Diagramatic representation

Page 4: Directed Graphs

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.

Page 5: Directed Graphs

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.

 

Page 6: Directed Graphs

Adjacency matrix of a directed graph

Page 7: Directed Graphs

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

Page 8: Directed Graphs

Reachability of directed graph

Depth-first search (DFS)

Page 9: Directed Graphs

Find all vertices reachable from s long a directed path