Presentation is loading. Please wait.

Presentation is loading. Please wait.

Graph Representations

Similar presentations


Presentation on theme: "Graph Representations"— Presentation transcript:

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 A B C D E F B C A F D E

3 Graph Representations
The adjacency matrix representation: Space: |V| bits 2 1 if (v, w)  E M(v, w) = 0 otherwise A B C D E F A B C D E F B C A F D E

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 C E 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 C E 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 C E D E C D

7 Graph Representations
The adjacency matrix representation, again, this time representing a directed graph. A B C D E F A B C D E F B C A F D E

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


Download ppt "Graph Representations"

Similar presentations


Ads by Google