0% found this document useful (0 votes)
32 views

1987 - A Versatile Graph Structure For Edge-Oriented Graph Algorithms (Ebert1987AVD)

The document describes an abstract module for representing graphs that supports edge-oriented programming of graph algorithms. The module represents both directed and undirected graphs using symmetrically stored forward and backward adjacency lists. This representation allows algorithms designed for undirected graphs to be used on directed graphs without adaptation. The module includes traversal procedures that iterate through the edges and vertices of a graph in an edge-oriented manner suitable for graph algorithms.

Uploaded by

culyun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

1987 - A Versatile Graph Structure For Edge-Oriented Graph Algorithms (Ebert1987AVD)

The document describes an abstract module for representing graphs that supports edge-oriented programming of graph algorithms. The module represents both directed and undirected graphs using symmetrically stored forward and backward adjacency lists. This representation allows algorithms designed for undirected graphs to be used on directed graphs without adaptation. The module includes traversal procedures that iterate through the edges and vertices of a graph in an edge-oriented manner suitable for graph algorithms.

Uploaded by

culyun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

COMPUTINGPRACTICES

Edgar H. Sibley An abstract graph module that allows for easy and secure programming of a
Panel Editor
great number of graph algorithms is implemented by symmetrically stored
forward and backward adjacency lists, thus supporting edge-oriented
traversals of general directed and undirected graphs.

A VERSATILE DATA STRUCTURE FOR


EDGE-ORIENTEDGRAPH Al.GORlTHMS

JiiRGEN EBERT

It is widely accepted that graphs are a useful In this article we describe an abstract module for
medium for modeling relevant parts of reality in graph handling that is especially suited for the edge-
computer programs. Graphs are rather natural oriented paradigm of programming graph algorithms,
models for road maps, electrical networks, chemical and show how this module can be implemented effi-
structure formulas, data and control flow of com- ciently in Algol-like languages. This graph realiza-
puter programs, state spaces of discrete games, socio- tion is of the adjacency-list type and is suitable for
logical diagrams, timetables, etc. In addition, many directed and undirected graphs (with multiple edges
discrete problems in several areas (e.g., formal lan- allowed). Undirected graphs are represented as di-
guage theory, automata theory, compiler construc- rected graphs through arbitrary assignment of direc-
tion, operating-systems theory, operations research) tions to every edge (and not through storage of the
can be transformed into equivalent graph problems corresponding symmetric graph). This representation
and then solved using graph algorithms. has been used successfully in a number of applica-
Representation greatly influences the efficiency tions; for instance, it has been used as a tool for
of graph algorithms. Often, linearity can only be representing the graphs in the EMS project on the
achieved through appropriate storage of adjacency implementation of functional languages [3].
information (see, e.g., [6]). There are several differ-
ent ways of internally representing graphs in pro- GRAPHS
cedural languages, including adjacency matrices, There is a large variety of graph types. Depending
sequential or linked adjacency lists, and edge lists on the area of application, graphs can be directed or
(cf. [Z]). On the other hand, good and clear algorithm undirected, weighted or unweighted, and ordered
design is greatly enhanced by rather abstract graph or unordered. Multiple edges and loops are either
representations that include operations on the graph, permitted or forbidden. Here, we present a graph
as well as control statements (e.g., for-loops) trig- representation that is suitable to all of these variants
gered by the graph. ([l] and [5] are introductory books on graph theory;
[Z] and [4] introduce graph algorithms).
01987 ACMOOOI-0782/87/0600-0513 750 Using a very general type of graph definition, a

Iune 1987 Volume 30 Number 6 Communicationsof the ACM 513


Computing Practices

(finite) directed graph G = (V, E, (Y,w) consists of a


finite nonempty set V of vertices, a finite set E of procedure DFS (v : vertex);
LOWPT[v] := NUMBER(v] := NUM := NiJM + 1;
edges (with V O E = 0), and two functions (Y:E -P V
for all e incident with v do
(denoting the start vertex) and w: E + V (denoting the let w be the other vertex of e;
end vertex of each edge). If there is an edge e with if NUMBER[w] = 0 then
vertices v = u(e) and w = w(e), then w is a successor of PARENT[w] := e;
v and v is a predecessor of w. Those edges e with DFS(w);
if LOWPT[w] 1 NUMBER[w] then
v = a(e) (“e goes out of v”) constitute the fomard star
e is bridge
of v. Analogously, the backward star of v consists of fi;
those edges e with v = o(e) (“e goes into v”). LOWPT[v] := min (LOWPT[v], LOWPT[w])
On the other hand, a (finite) undirected graph else
G = (V, E, ‘P) contains only one function if NUMBER[v] L NUMBER[w]
and e is not a tree edge then
P:E+=(WCVll I JWl ~Z],assigninguptotwo
LOWPT[v] := rain (LOWPT[v], NUMBER[w] )
vertices to every edge. A self-loop is an edge e with fi
1‘P(e)1 = 1. If v E P(e), we say v and e are incident. fi
The star of a vertex v consists of those edges that are od;
incident with v. The degree y(v) of v is the number of NUM := 0;
edges incident with v, where self-loops are counted for all Y in V do
twice. PARENT[v] := NUMBER[v] := 0
For a directed graph G = (V, E, LY,o), the under- od;
for all v in V do
lying undirected graph H = (V, E, P) is given by if NUMBER] v] = 0 then
‘P(e) = (o!(e), o(e)). Thus, all concepts and algorithms DFS ( v)
defined for undirected graphs can also be used for fi
directed graphs through simple reference to their od.
underlying undirected graphs. Thus, an edge e and a
vertex v are incident if v = cu(e)or v = .o(e), and e is a
FIGURE1. An Edge-Oriented Pseudocode
self-loop if a(e) = w(e). Version of a Bridge Detection Algorithm
With the implementation given below, the repre-
sentation of the underlying undirected graph is iden-
tical to the representation of the graph itself. Thus,
edge procedure first-out (v : vertex)
algorithms that were designed for undirected graphs returns first edge going out of 11.
(e.g., algorithms for finding spanning trees, testing edge procedure next-out (e : edge)
(bi-)connectivity) can be executed on directed returns edge following e in
graphs without further adaptation. forward star of alpha(e).
edge procedure first-in (v : vertex)
returns first edge going into v.
EDGE-ORIENTED GRAPH ALGORITHMS edge procedure next-in (e : edge)
The graph module described here strongly supports returns edge following e in
an edge-oriented way of handling graphs. This para- backward star of omega(e).
digm makes programming more secure and is at the edge procedure first (v : vertex)
returns first edge incident with v.
same time suitable for handling graphs with multi-
edge procedure next (e : edge)
ple edges. returns edge following e in
The following conventions apply to edge-oriented star of this(e).
programming of graph algorithms: vertex procedure first-vertex ( )
returns first vertex of the graph.
(1) Neighborhoods of vertices are traversed by ref- vertex procedure next-vertex (v : vertex)
erence to the edges incident with a given vertex. returns vertex following Y in the graph.
edge procedure first-edge ( )
(4 Edges are regarded as objects having two states. returns first edge of the graph.
They may be pointing outwards (positive sign) edge procedure next-edge (e : edge)
or pointing inwards (negative sign). returns edge following e in the graph.

Thus, for processing the successors of a given vertex


v, one must proceed as follows:
These procedures return a n i 1 value if there is no object
foralledges eoutof vdo to be returned.
letwbetheother vertexof e;
process w FIGURE2. Traversal Procedures for the Translation
od. of the Pseudocode f or-Statements

514 Communications of the ACM fune 1987 Volume 30 Number 6


Computing Practices

The sign of the edges makes it possible to talk about Note that these functions assume an arbitrary but
the “other” vertex. fixed order on all sets. For handling “signed” edges,
Using loops over edges and giving a state to the some auxiliary transfer functions like those listed in
edges allow a straightforward translation for for- Figure 3 are necessary. Figure 4 shows how the
loops into a combination of a whi le-loop and some bridge detection algorithm of Figure 1 can be pro-
standard function calls, since signed edges contain
enough information to (re)enter a while-loop to
process the next edge. This is not possible for loops
over (e.g., successor) vertices. Furthermore, travers- vertex procedure alpha (e : edge)
returns start vertex of e.
ing neighborhoods by explicitly looking at all inci- vertex procedure omega (e : edge)
dent edges clarifies the fact that successors are listed returns end vertex of e.
more than once, if multiple edges exist. (A vertex- vertex procedure this (e : edge)
oriented for-loop is often valid only for graphs returns start vertex of e, if e is positive,
without multiple edges.) and end vertex, otherwise.
vertex procedure that (e : edge)
In addition, the sign on the edges allows sufficient returns end vertex of e, if e is positive,
information to be kept for deferred processing, if-as and start vertex, otherwise.
in some search algorithms-edges are stored for later edge procedure normal (e : edge)
use in an intermediate data structure. When an edge returns edge e with positive direction.
is retrieved, its sign helps to deduce its provenance. edge procedure reverse (e : edge)
returns edge e with reversed direction.
Assigning directions (signs) to edges also helps to
distinguish incoming from outgoing edges during un-
directed searches in directed graphs. Furthermore it FIGURE3. Auxiliary Transfer Procedures for Handling “Signed” Edges
helps to describe the direction of edges in (undi-
rected) cycles and/or cuts of directed graphs.
As an example, Figure 1 shows an edge-oriented
pseudocode version of a bridge detection algorithm procedure DFS (v : vertex);
(derivable from [6]). Note that this algorithm works LOWPT[v] := NUMBER[v] := NUM := NUM + 1;
e := first (v);
on undirected graphs, though the input graph might while e <> 0 do
be directed. Here, the PARENT-entries, which de- w := that (e);
note a spanning tree in a multigraph, contain edges if NUMBER[w] = 0 then
(instead of vertices), since there is at most one in- PARENT[w] := normal (e);
coming tree edge for every vertex. DFS (w);
if LOWPT[w] 2 NUMBER[w] then
output (e, "is bridge")
GRAPH OPERATIONS fi;
We now give the description of a module (in the LOWPT[v] := min (LOWPT[v], LOWPT[w])
sense of an abstract data structure) for implementing else
edge-oriented algorithms in Algol-like languages. if NUMBER[v] 1 NUMBER[w]
and normal(e) <> PARENT[v] then (*)
For programming a pseudostatement like the for-
LOWPT[v] := min (LOWPT[v], NUMBER[w])
loop over the outward star from above, we use tra- fi
versal functions first-out and next-out and an fi;
auxiliary function omega according to the following: e := next (e)
od;
e :=first-out (v); NUM := 0;
while e<>O do v := first-vertex ( );
w:=omega (e); while II <> 0 do
PARENT[v] := NUMBER[v] := 0;
process w; v := next-vertex (v)
e:=next-out(e) od;
od. v := first-vertex ( );
while v <> 0 do
Note that this is a very straightforward way of trans- if NUMBER(v] = 0 then
lating for-loops, which is made possible by the “di- DFS (v)
rection” (sign) assigned to every edge value. Since fi;
the edges denoted by e point outward, it is possible II := next-vertex (v)
od.
to identify the “next” edge as the next one going out
of the same start vertex.
Figure 2 lists the traversal functions necessary for FIGURE4. A Concrete Program for Bridge Detection, Showing
the translation of the pseudocode for-statements. How the Procedures from Figures 2 and 3 Can Be Used

June 1987 Volume 30 Number 6 Communications of the ACM 515


Computing Practices

now be stored separately in arrays of length n or m,


respectively. (Note that this is one of the main ad-
vantages of adjacency list representations over adja-
cency matrices, at least when the graph is sparse.)
Thus, values of vertices and edges have only to be
stored once, even for undirected graphs.
We use these numbers as names for the corre-
v = 11, 2, 3, 4) sponding objects. But we take care not to confuse
E = (1, 2, 3, 4, 5, 61 vertex i with edge i (for 1 I i 5 min (n, m)). Thus, we
take
1 2 3 4 5 6
a 1 1 2 3 3 2 vertex = 0 .. n
w 2 3 4 4 2 3
edge = -m . . m
as types, with the integer sign as the direction indi-
cator for edges and with zero as a nil-value for
Node: vertices and edges.
Next:
First:
edge procedure first-out (v : vertex);
e := FIRST[v];
FIGURE5. A Sample Graph and Its Array Representation while e < 0 do
e := NEXT[e]
od;
grammed using these procedures. Note that this pro- return e.
gram, though designed for undirected graphs, also edge procedure next-out (e : edge);
handles directed graphs without any further action e := NEXT[abs(e)];
while e < 0 do
or adaptation. e := NEXT[e];
Since edges are signed objects, some care has to be od;
taken in testing edge equality. In the line marked return e.
with a star (*) in Figure 4, both sides of the inequal- edge procedure first-in (v : vertex);
ity sign were simply normalized. e := FIRST[v];
while e > 0 do
The next section shows that all operations used e := NEXT[e]
thus far can be implemented efficiently. A great od;
number of graph algorithms can be formulated return e.
using only the operations described here. In [Z], for edge procedure next-in (e edge) ;
instance, it is shown that all the generally used effi- e := NEXT[--abs(e)];
while e > 0 do
cient graph algorithms can be based on the opera- e:= NEXT[e]
tions described here (except for the class of all-pair- od;
shortest-path algorithms, which usually use some return e.
kind of is-edge ( v, w)-test). edge procedure first (v : vertex);
return FIRST[v];
edge procedure next (e : edge);
GRAPH REPRESENTATION return NEXT[e].
Adjacency lists are usually used to store the succes- vertex procedure first-vertex( );
sors of every vertex by means of linked lists. We returq 1.
store the predecessors, as well, to enable algorithms vertex procedure next-vertex (v : vertex);
on the underlying undirected graph. Using some return if v = n then 0 else v + 1 fi.
edge procedure first-edge ( );
practical “tricks,” we get a storage schema, which return 1.
implements all the operations of our graph module edge procedure next-edge (e : edge);
in an efficient way. return if e'= m then 0 else e + 1 fi.
Let G = (V, E, (Y,w) be a given directed graph with
1V 1 = rr and 1E 1 = m. We number the vertices in V
from 1 to n, and the edges in E from 1 to m. FIGURE6. Implementation of the Traversal Procedures
All concrete information about the vertices and from Figure 2, Assuming Validity of Input
edges (e.g., names, weights, lengths, markings) can Parameters and n and m 2 1

516 Communications of the ACM June 1987 Volume 30 Number 6


Computing Practices

Using an array
vertex procedure alpha (e : edge);
NODE : array [edge] of vertex return NODE[--abs(e)].
vertex procedure omega (e : edge);
we can store cy(e)in NODE [-e] and w(e) in return NODE[abs(e)].
NODE [+e] for every edge e. This allows all edge- vertex procedure this (e : edge);
list-oriented algorithms to be used on our structure return NODE[-e].
by accessing the array NODE alone. vertex procedure that (e : edge);
return NODE [ e] .
Conversely, the adjacency lists for every vertex z, edge procedure normal (e : edge);
are made traversable by using array indexes as links: return abs(e).
edge procedure reverse (e : edge);
FIRST : array [vertex] of edge return -e.
NEXT : array [edge] of edge
These arrays link all edges incident with a vertex v FIGURE7. Implementation of the Auxiliary Procedures
to v by using the chain of indexes starting at from Figure 3, Assuming Validity of Input Parameters
FIRST [v] , following the NEXT-entries, and ending
with a zero-entry. The indexes are positive for edges
going out of v and negative for edges going into v. this array suffices. Figure a shows how the graph
Then, the nonzero entries in the FIRST/NEXT- representation described in the previous section can
arrays are the signed edges themselves, with their be reconstructed from its NODE-array in linear time.
direction seen from the corresponding vertex. This algorithm traverses the edge list in reverse or-
Figure 5 gives an example by showing a sample der. It inserts each (positive) edge e at the front of
graph and its array representation. Figure 6 shows the adjacency list of a(e) and inserts -e to the list
how the traversal procedures of Figure 2 can be im- of w(e).
plemented using our structure, and Figure 7 gives
the implementation of the auxiliary functions of Fig-
ure 3. (Note that in practical applications all gener-
ally usable procedures should check their argu-
for v := 1 to n do
ments. These checks have been skipped to simplify
FIRST[v] := 0
the presentation.) od;
These implementations of the traversal functions for e := m downto 1 do
lead to a complexity of for-loops over (for/back- NEXT[e] := FIRST[NODE[-e]] ;
ward) stars of a vertex v proportional to y(v). FIRST [NODE [-e] ] := e;
NEXT[-e] := FIRST[NODE[e] I ;
Equally, for-loops over V and E have a complexity
FIRST[NODE[e]] := -e
proportional to n and m, respectively. All the imple- od.
mentations of the auxiliary functions apparently use
constant time.
The first/next-pair of functions enumerates FIGURE8. Reconstruction of the Graph Representation
self-loops twice. If this is not wanted, first and from Its NODE-Array in Linear Time
next should be modified to ignore negative edge
values e, if
NODE [e] = NODE [-e] . This algorithm is order preserving: If the NODE-
array is compatible with all the adjacency lists, then
The graph module can of course be augmented by the adjacency lists are reconstructed as they were
additional operations, if they are needed, such as before. On the other hand, if the NODE-array gets
procedures for determining degrees, for testing the sorted (e.g., according to some weight), then all adja-
existence of edges, etc. Note that is-edge ( v, w) - cency lists are sorted as well-after reconstruction.
tests have a complexity at least proportional to This procedure might also be used for simplifying
min (Y(V), r(W graph input to simply reading an edge list. Graph
output can be performed by just printing the edge list
RECONSTRUCTION AND COMPRESSION while traversing the NODE-array. If, however, the
The NODE-array alone (being an edge-list representa- NODE-array order is not compatible with the orders
tion of the graph) already contains all incidence in- of the adjacency lists, some topological sorting has to
formation. Thus, for example, for external storage, be done when the graph is written to an external

June 1987 Volume 30 Number 6 Communications of the ACM 517


Computing Practices

procedure test-and-mark (e : edge): Using the zero-entries in these arrays (which are
if e <> 0 and not is-marked (e) then unused up to now) as a start pointer, we can link the
mark (e); unused entries together following a stack ‘discipline.
if is-marked (-e) then To distinguish used from unused entries, we add a
enqueue (abs(e)) large value LARGE (preferably MMAX) to the link val-
fi;
if NODE[-e] = NODE[e] then ues in FIRST and NEXT, if we use them for chaining
test-and-mark (-e) unused entries.
fi In this case the graph should be initialized as an
fi; empty graph using the following procedure:
init-queue ( ); procedureinit ( );
init-marking ( );
for Y := 1 to n do forv:=OtoNMAXdo
test-and-mark (FIRST[v]) FIRST [ v] := v+ 1 + LARGE
od; od;
while not is-empty-queue ( ) d6 fore:=OtoMMAXdo
e := extract-front-of-queue ( ); NEXT[-e] := 0;
output (NODEI-e], "A', NODE[e]);
test-and-mark (NEXT[ej); NEXT [e] :=e+ 1 +LARGE
test-and-mark (NEXT[-e]) od;
od. n .=*
. .=
. 0.

(In this case the procedures for traversing -the vertex


FIGURE9. A Linear-Time Algorithm for Compressing and edge sets have to be adapted.)
the Graph Structure into an Edge-List It is even possible to keep track of the order in
which the edges are added to the vertices by using
an additional array
medium. Otherwise, the original order on the stars
LAST : array[vertex] of edcle
cannot be reconstructed. (This incompatibility might
occur, for instance, if the graph was constructed to keep the last edge entry for every vertex. (This
dynamically using the procedures presented in the applies to forward and backward stars as well as to
next section.) (undirected) stars.) In this case all loops varying over
Figure 9 gives a linear time algorithm for com- adjacency sets traverse these sets in the order of
pressing the graph structure into an edge list. But edge creation. This leads to ordered graphs, where
here tie need some (linear) additional work space the edges incident with every vertex are linearly or-
for queueing (up to m) normalized edges, and mark- dered. Figure 11 shows how the creation/deletion
ing (up to 2~2)signed edges. This algorithm prints an procedures are implemented; two auxiliary proce-
edge e only if its predecessors in the adjacency list of dures are given in Figure 12.
cu(e)as well as w(e) have all been printed. To decide The create procedures use constant time. The
this property, a marking of e and -e is used. A complexity of delete-vertex is proportional to
queue helps to keep track of all printable edges. This y(v). The delete-edge(e) procedure uses time
algorithm fails (by not printing all edges) if there is proportional to y(cY(e))+ -y(w(e)). It could be made
no NODE-array ordering that is compatible with the constant time by using double chains on edges, but
adjacency-list ordering. this does not seem worthwhile.

DYNAMIC GRAPHS
Many applications use graphs whose size and struc-
vertex procedure create-vertex ( );
ture change during execution. This implies a need returns a new vertex.
for procedures to create and delete vertices and procedure delete-vertex (v : vertex);
edges. The representation presented in this article deletes vertex v.
can easily be extended for graphs with a (moder- edge procedure create-edge (v, W : vertex);
ately) varying number of vertices and/or edges, as returns a new edge.
procedure delete-edge (e : edge);
long as a maximum number (NMAX/MMAX) can be deletes edge e.
given for both. Figure 10 gives the procedures neces-
sary for handling dynamic graphs.
To implement dynamic graphs, we link all unused FIGURE10. Creation and Deletion Procedures
(nonnegative) entries in the FIRST/NEXT arrays. for Handling Dynamic Graphs

518 Commu?rications of the ACM June 1987 Volume 30 Number 6


Computing Practices

CONCLUSION
vertex procedure create-vertex ( );
II := FIRST[O] - LARGE; Following the paradigm of edge orientation, our
FIRST[O] := FIRST[v]; software module for general graphs and their imple-
FIRST[v] := LAST[v] := 0; mentation on von Neumann machines allows for
n := n+ 1; easy and secure programming of a great number of
return v.
procedure delete-vertex (v : vertex);
graph algorithms, since traversal of forward and
while FIRST[v] <> 0 do backward stars as well as edge enumeration is par-
delete-edge (FIRST [ v] ) ticularly easy. Since there is no distinction between
od; a directed graph and its underlying undirected
FIRST[v] := FIRST[O]; graph, our module allows a very straightforward
FIRST[O] := " + LARGE;
n := n - 1.
transliteration of published algorithms into concrete
edge procedure create-edge (v, w : vertex); programming code.
e := NEXT[O] - LARGE; The module has successfully been used in various
NEXT[O] := NEXT[e]; applications. A version written in the C language is
NEXT[e] := 0; one of the basic cornerstones of the EMS system for
In := In + 1;
create-entry (Y, e) ;
the implementation of functional languages by
create-entry (w, -e) ; graphs.
return e.
procedure delete-edge (e : edge);
e := abs (e);
delete-entry (NODE [-e] , e) ; REFERENCES
1. Berge. C. Graphs and Hypergraphs. North-Holland, Amsterdam, 1973.
delete-entry (NODE[e], -e); A textbook on graph theory.
NODE [-e] := NODE[e] := NEXT[-e] := 0; 2. Ebert. J. Effiziente Graphenalgorithmen.Aula, Wiesbaden. West Ger-
NEXT [e] := NEXT[O] ; many. 1981. A textbook on graph algorithms and their implementa-
NEXTlO] := e + LARGE; tion in Algal-like languages using abstract data and refinements.
3. Ebert, J. Implementing a functional language on a vom Neumann
In :=m- 1. computer. Tech. Rep. 3/&i, EWH Koblenz, Fachbericht Informatik,
Mar. 1985. A report on an implementation technique for functional
languages using attributed and ordered directed graphs.
FIGURE11. Implementation of the Creation and Deletion 4. Even, S. Graph Algorithms. Pitman, Marshfield, Mass., 1979. A text-
Procedures, Assuming Validity if Input Parameters book on graph theory featuring algorithms.
5. Harary, F. Graph Theory. Addison-Wesley, Reading, Mass., 1969.
and without Checking Overflow Conditions A textbook on graph theory.
6. Tarjan, R.E. Depth-first search and linear graph algorithms. SIAM J.
Comput. I, 2 (1972). 146-160. A fundamental paper showing that
some connectivity problems are solvable in linear time using depth-
first search on adjacency-list representations of graphs.
procedure create-entry (v : vertex, e : edge);
if FIRST[v] = 0 then
FIRST[v] .= e
else CR Categories and Subject Descriptors: E.1 [Data]: Data Structures-
arrays: graphs; lists; E.2 [Data]: Data Storage Representations-contiguous
NEXT[LAST [VI] := e representafions;linked representations: F.2.2 [Analysis of Algorithms and
fi; Problem Complexity]: Nonnumerical Algorithms and Problems-compu-
LAST[v] := e; tations on discrete structures; G.2.2 [Discrete Mathematics]: Graph The-
NODE[-e] := v. ory-graph algorithms
General Terms: Algorithms
procedure delete-entry (v : vertex, e : edge); Additional Key Words and Phrases: Edge-oriented algorithms, graph
if FIRST [v] = e then traversal
FIRST[v] := NEXT[e];
if LAST [v] = e then
LAST[v] := 0
fi Received 6/86; accepted U/86
else
i := FIRST[v];
while NEXT[i] <> e do
i := NEXT[i] Author’s Present Address: Jiirgen Ebert. EHW Koblenz, Informatik,
od; Rheinau 3-4, 5400 Koblenz, West Germany.
NEXT[i] := NEXT[e];
if LAST [v] = e then
LAST[v] := i
fi Permission to copy without fee all or part of this material is granted
provided that the copies are not made or distributed for direct commer-
fi. cial advantage, the ACM copyright notice and the title of the publication
and its date appear, and notice is given that copying is by permission of
the Association for Computing Machinery. To copy otherwise, or to
FIGURE12. Auxiliary Creation and Deletion Procedures republish, requires a fee and/or specific permission.

June 1987 Volume 30 Number 6 Communications of the ACM 519

You might also like