Graph Representations - PowerPoint PPT Presentation

About This Presentation
Title:

Graph Representations

Description:

Graph Representations. There are two main ways of representing graphs in a computer: ... Graph Representations. The adjacency matrix representation, again, ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 11
Provided by: DavidR6
Learn more at: http://www.cs.rpi.edu
Category:

less

Transcript and Presenter's Notes

Title: Graph Representations


1
Graph Representations
  • There are two main ways of representing graphs in
    a computer
  • The adjacency matrix representation.
  • The adjacency list representation.

2
Graph Representations
The adjacency matrix representation
1 if (v, w) ? E
M(v, w)
0 otherwise
A B C D E F
0 1 0 1 0 0
A B C D E F
B
1 0 1 0 0 0
C
A
0 1 0 1 1 0
F
1 0 1 0 1 0
D
0 0 1 1 0 0
E
0 0 0 0 0 0
3
Graph Representations
The adjacency matrix representation
1 if (v, w) ? E
M(v, w)
0 otherwise
A B C D E F
0 1 0 1 0 0
A B C D E F
B
1 0 1 0 0 0
C
A
0 1 0 1 1 0
F
1 0 1 0 1 0
D
0 0 1 1 0 0
E
0 0 0 0 0 0
4
Graph Representations
The adjacency list representation
L(v) list of w such that (v, w) ? E, for v
? V
A B C D E F
B
D
B
C
A
C
A
B
D
E
F
A
E
C
D
E
C
D
5
Graph Representations
The adjacency list representation
How much space ?
A B C D E F
B
D
B
C
A
C
A
B
D
E
F
A
E
C
D
E
C
D
6
Graph Representations
The adjacency list representation
Space a V 2 b E
a
b
A B C D E F
B
D
B
C
A
C
A
B
D
E
F
A
E
C
D
E
C
D
7
Graph Representations
The adjacency matrix representation,
again, this time representing a directed graph.
A B C D E F
0 1 0 1 0 0
A B C D E F
B
0 0 1 0 0 0
C
A
0 0 0 0 1 0
F
0 0 1 0 0 0
D
0 0 0 1 0 0
E
0 0 0 0 0 0
8
Graph Representations
The adjacency list representation, again, this
time representing a directed graph.
A B C D E F
B
D
B
C
C
A
E
F
C
D
E
D
9
Graph Representations
The adjacency list representation, again, this
time representing a directed graph.
How much space?
A B C D E F
B
D
B
C
C
A
E
F
C
D
E
D
10
Graph Representations
The adjacency list representation, again, this
time representing a directed graph.
Space a V b E
a
b
A B C D E F
B
D
B
C
C
A
E
F
C
D
E
D
Write a Comment
User Comments (0)
About PowerShow.com