7 Determining the Degree of Each Vertex
If the graph is represented by its adjacency list and vertex list , Algorithm 13 develops a mapping whose domain is and whose range is the degree of . It assumes the buffer provides communication with the vertex list.
first() |
while |
map() |
next() |
first() |
while |
for all vertices adjacent to |
evaluate() |
map() |
next() |
If is a directed graph, represented by its vertex list and edge list , Algorithm 14 maps each vertex in to its degree. It is assumed that each edge is represented by an ordered pair of vertices and the buffer provides communication with the edge list.
first() |
while |
map() |
next() |
first() |
while |
evaluate() |
map() |
next() |
If is an undirected graph, Algorithm 15 performs the same operation. It is assumed that each edge is represented by an unordered pair of vertices .
first() |
while |
map() |
next() |
first() |
while |
evaluate() |
map() |
evaluate() |
map() |
next() |
If all the elementary operations are , creating is linear, i.e. has complexity .