Data Structures and Algorithms with Object-Oriented Design Patterns in C#
next up previous contents index

Adjacency Lists

One technique that is often used for a sparse graph, say tex2html_wrap_inline70252, uses tex2html_wrap_inline70678 linked lists--one for each vertex. The linked list for vertex tex2html_wrap_inline70382 contains the elements of tex2html_wrap_inline70682, the set of nodes adjacent to tex2html_wrap_inline70418. As a result, the lists are called adjacency lists .

Figure gif shows the adjacency lists for the directed graph tex2html_wrap_inline70346 of Figure gif and the directed graph tex2html_wrap_inline70500 of Figure gif. Notice that the total number of list elements used to represent a directed graph is tex2html_wrap_inline70690 but the number of lists elements used to represent an undirected graph is tex2html_wrap_inline70692. Therefore, the space required for the adjacency lists is tex2html_wrap_inline70694.

   figure48931
Figure: Adjacency lists.

By definition, a sparse graph has tex2html_wrap_inline70636. Hence the space required to represent a sparse graph using adjacency lists is tex2html_wrap_inline70702. Clearly this is asymptotically better than using adjacency matrices which require tex2html_wrap_inline70626 space.


next up previous contents index

Bruno Copyright © 2001 by Bruno R. Preiss, P.Eng. All rights reserved.