| Data Structures and Algorithms 
with Object-Oriented Design Patterns in C#           | 
The following four operations are used extensively in the implementations of many different graph algorithms:
	When adjacency lists are used,
	the worst-case running time is   ,
	since
,
	since   is the length of the adjacency list associated
	with vertex v.
 is the length of the adjacency list associated
	with vertex v.
This is the operation performed by the GetEdge method of the Graph interface.
 matrix entries.
	Therefore, the worst-case running time needed to enumerate
	all the edges is
 matrix entries.
	Therefore, the worst-case running time needed to enumerate
	all the edges is   .
.
	On the other hand, to enumerate all the edges when using adjacency
	lists requires the traversal of   lists.
	In all there are
 lists.
	In all there are   edges.
	Therefore the worst case running time is
 edges.
	Therefore the worst case running time is   .
.
This operation is performed using the enumerator obtained using the Edges property of the Graph interface.
 row of an
	adjacency matrix.
	Therefore, the worst-case running time when using adjacency matrices
	is
 row of an
	adjacency matrix.
	Therefore, the worst-case running time when using adjacency matrices
	is   .
.
	Enumerating the edges emanating from vertex v is a trivial
	operation when using adjacency lists.
	All we need do is traverse the   list.
	This takes
 list.
	This takes   time in the worst case.
 time in the worst case.
This operation is performed using the enumerator obtained using the EmanatingEdges property of the Vertex interface.
 column of an
	adjacency matrix.
	Therefore, the worst-case running time when using adjacency matrices
	is
 column of an
	adjacency matrix.
	Therefore, the worst-case running time when using adjacency matrices
	is   .
.
	Enumerating the edges incident on vertex w is a non-trivial
	operation when using adjacency lists.
	It is necessary to search every adjacency list in order to find all
	the edges incident on a given vertex.
	Therefore, the worst-case running time is   .
.
This operation is performed using the enumerator obtained using the IncidentEdges property of the Vertex interface.
 summarizes these running times.
 summarizes these running times.
| representation scheme | ||
| operation | adjacency matrix | adjacency list | 
| find edge (v,w) | O(1) |   | 
| enumerate all edges |   |   | 
| enumerate edges emanating from v |   |   | 
| enumerate edges incident on w |   |   | 
 
  
  
  
  
 
 Copyright © 2001 by Bruno R. Preiss, P.Eng.  All rights reserved.
Copyright © 2001 by Bruno R. Preiss, P.Eng.  All rights reserved.