An economical algorithm for distinguishing blocks in a graph

An economical algorithm for distinguishing blocks in a graph

AN ECONOMICAL ALGORITHM FOR DISTINGUISHING BLOCKS IN A GRAPH* E. A. DINITS, M. A. ZAITSEV and A. V. KARZANOV Moscow (Received 23 March 1973) (Revised ...

678KB Sizes 1 Downloads 75 Views

AN ECONOMICAL ALGORITHM FOR DISTINGUISHING BLOCKS IN A GRAPH* E. A. DINITS, M. A. ZAITSEV and A. V. KARZANOV Moscow (Received 23 March 1973) (Revised version 4 July 1973) AN ALGO~THM for organizing the search for blocks in a connected graph is presented. The estimate of the number of operations of the algorithm is of min~um possible order: o@), where p is the number of arcs of the graph.

We consider a connected non-oriented graph G without multiple arcs and loops with V vertices, 1V 1=a, and the set of arcs u, 1U 1=m. 1. Blocks in a graph. (The basic properties of the graphs described below are given in [ 1,2] ). The vertex z in the graph G is called a separating vertex, if on removing it (together with all the

arcs incident with it) the connectivity of the graph is destroyed. A graph not containing separating vertices is called inseparable. An inseparability component or block of the graph G is called maximum on the inclusion of its insep~able subgraph. (A subgraph G(P), V’c V, is defined as a part of the graph G with a set of vertices V , containing all the arcs which connect these vertices in the graph G.) It is known that the number of blocks in G does not exceed n-l.

FIG. 1 The graph of blocks flG) of the graph G is defined as fohows. Its vertices correspond to blocks and separating vertices of the graph G (see Fig. 1). The vertices “z” and ‘Y?’ of the graph of blocks are connected by an arc if .zeS (here z is a separating vertex, and B is a block). It is known that the separation of a graph into blocks corresponds to the separation of its set of vertices into non-~ter~~t~g equivalence classes R : R (zh, a*) -+=+there exists a simple (not self-intersecting with respect-to vertices) cycle, connecting the arcs ur and tiz. A branch of &locks, depending on the (separating) vertex z, is defined as a subgraph G’=G (VU {z) ), V’?b, such that the vertices of V’ are not joined by arcs to the vertices of V\ ( V’U {z) ) *Zh. v_@&& M&t.ma?.FE-Z.,14,5,1309-1316,

1974.

208

Distinguishingblocks in a graph

and the subgraph G(V’) is connected

209

(that is, the vertex z is not separating in G’). It is obvious

that the vertex z belongs to only one block in the graph G’; we will call it radical for the branch G’. Let the vertex a be fixed. Then each block

B (apart from U%rj if a is not separating in G)

emerges as radical for a unique branch of blocks of the class {G’ ) a@ V’}. 2. The discovery of separating vertices may be required in the solution of problems on electrical, reliable and other networks.

For example, if a problem on the paralleling of calculations

is to be

solved, it becomes necessary to recognize which parts of the program it will be necessary to operate (independently of the actual realization of the process at the branch points of the computing scheme). In the scheme these parts correspond to vertices separating output from input. The separation of the graph into blocks may considerably

reduce the dimensionality

defined on large networks, and thereby sharply reduce the difficulty Economical

of problems

of solving them.

algorithms for the solution of the similar problem of the “coarser” separation of

a graph into bicomponents

were presented in [3-S]

In the present paper an algorithm is proposed which distinguishes vertices in a given graph G, and also constructs algorithm is o(m) operations,

the blocks and separating

the graph of blocks F(G). The laboriousness

of the

and the required storage volume is o(m) cells. For these estimates to

be valid it is necessary that the graph be defined in the form of registers for each vertex v of the graph of vertices adjacent to it (that is, connected to it by an arc). The proposed algorithm is based on a definite method of going round the graph described below. The algorithm will be obtained theoretically traversal. Then a formal description

by an investigation

of the properties of the

of the algorithm suitable for programming

3. By the traversal Q of the graph G we understand

will be given.

the motion from vertex to vertex along

the arcs of the graph, each arc being traversed not more than once in each direction. We denote by Q the trajectory of the motion in the traversal, we denote by a the initial vertex (it can be any one). We will consider that the successive vertices a=~,, u,, . . . , vat . . . , uw of the route Q correspond o of traversal, and its arcs to the paths of the traversal. The first to the instants 0, 1, . . . , cc, . . . , path along an arc will be called direct, the second (in the opposite direction) the direct path defines the orientation notation

U=

encounter

of the arcs (connected

inverse. We agree that

with a given traversal). Also the

( y, z) will denote that the arc tl is oriented from y to z. The arc along which we first

a vertex v (obviously

by the direct path), will be denoted by u,,.

Traversal rules. a. If we are first at the vertex v, the next path must be direct along any arc

incident

to v and not occurring earlier in the traversal, if such a one exists; otherwise the next path

must be the inverse path along the arc uU if v#aand b. If along the first path we encounter

the end of the traversal if ~=a.

a vertex already occurring in the traversal, the next

path must be the reverse one along the same arc (such an arc of the graph and such an instant of traversal will be called touching, from the German betreffen - to touch.) c. If along the reverse path we encounter

the vertex v we proceed further as in case a.

The property of the traversal by the rules a which is fundamental (here) consists of the fact that, entering a branch of blocks G’ along the arc U, we remain within G’ until we traverse it completely, ending the motion along G’ by a reverse passage along the arc u (see below).

USSR.

N

210

E. A. Dinits, M. A. Zaitsev and A. V. Karzanov 4.

We will study the properties of a traversal constructed

We consider a fundamental

(non-touching)

by the rules described.

part e of the traversal Q, obtained by discarding

from Q all the touching segments. Since only there-and-back

paths along touching arcs are discarded,

G may be regarded as a traversal of the part ?? of the graph G formed by non-touching by arcs of type u,,, where v runs through V\ {a}. It is easy to verify that cis root a. For every vertex .P&

there exists a unique oriented path L,S

arcs, that is,

a tree oriented from the

from a to x.

We say that an arc not occurring in a traversal is untraversed, traversed once - semitraversed, and traversed twice - traversed. Statement 1 The set of semitraversed

arcs at any instant (Yof the traversal c (that is, at any non-trivial

instant of the traversal Q) is identical with the set of arcs of the “current”

path L,=L,,.

(This is easily proved by induction). We say that a vertex is free if all the arcs incident with it are untraversed, traversed, and open otherwise. We consider a vertex ~#a.

closed if they are all

It is obvious that it ceases to be free at

the instant when it is included in the current path together with an arc uv leading to it. We prove that the vertex v becomes closed at the instant when the current path ceases to include v and as the result of an inverse passage along the arc uV. Indeed, by Rule a the vertex v is not incident with the untraversed

arcs, and by the Statement

1, not with the semitraversed

arcs, which is what it

was required to prove. It is similarly proved that at the instant w of ending the traversal the vertex a is closed. This proves Statement

2.

Statement 2 The set of open vertices is identical with the set of vertices of the current path, not counting the initial and final instants when it is empty. Statement 3 At the instant w all the arcs have been traversed and all the vertices are closed. (This is proved in the same way as for the traversal described in [6] .) Corollary. The tree ?? contains all the vertices of the graph G, that is, it is its carcase (connecting tree). (Thus, the method of traversing a graph described may be used to construct carcase of a given graph.) The carcase ?? possesses an important

the

specific property.

Statement 4 Let U= ( y, z) E U be a chord of the carcase ?? (that is, z&G).

Then ZEL,.

Proo$ By the definition of 5, u is a touching arc. Let the direct passage along it have been completed at the instant OL,that is, u,=y, vafi- -2. The vertex z is not free, by the definition of touching, and it is not closed, by the definition of closeness. Therefore, z is open and, by the Statement

2, zEL,=L,.

Distinguishingblocks in a graph

The structure of the set of semitraversed by Fig. 2, where Li,,

,is the contour

211

arcs at the touching instant (11+ 1 can be illustrated

formed at the instant cr t 1 from the semitraversed

arcs.

FIG. 2 5. From the structure specified on the graph G by the carcase ??, any branch of the blocks G’, V’$u, is uniquely

defined, namely, the set of vertices of the branch of blocks forms in the

carcase c a separable branch in the following sense. We consider a part of the carcase I!? separable by the arc u from the root of the tree ??, the vertex a. We associate with it the arc u(z, JJ) itself. We describe the part c, obtained

branch zr,, except for z (internal),

is denoted by V,. We call the branch ??u separable if from the

vertices of the set Vu there do not emerge arcs (necessarily more accurately,

touching)

to a vertex of I,,, apart from z (the correction

On the one hand it is obvious that the separable branch blocks with a set of internal vertices V,&zdependent

to a vertex of V\ (V,U {z}),

is valid by Statement G,, u= (z,

the vertex z in the carcase E separates

in c one or several branches dependent

I/’ from

4).

y) , defines a branch of

on the vertex z.

Conversely, we consider the branch of blocks G’, V’&,dependent CcG.

of the carcase c

as the brunch of it depending on the arc u and the vertex z. The set of vertices of the

on the vertex z. Since

the remaining vertices. Therefore,

on z. However, by Statement

various branches dependent on one vertex, cannot be connected G(V’) affects the uniqueness of this branch.

V’ forms

4, the internal vertices of the

by arcs. Therefore the connectivity

6. We now consider the problem of finding the separable branches in the traversal process. It is obvious that the traversal of the branch I?, is part of the traversal Q, beginning with a direct passage along the arc u and ending with the reverse passage along it. We call the part of the traversal Q included in this interval a branch of the traversal, and denote it by Q,. We extend the definition

of separability

to a branch of the traversal: Q, is separable *Gu

is separable. From the

properties of a traversal described above it is easy to deduce that the branch of the traversal Q, for u = (z, y) is a traversal of the subgraph G,=G (V,,U {z} ) plus touching arrivals at vertices of the path L,, apart from z. Thereby the following criterion of separability Criterion of separability:

may be regarded as justified.

the branch Q,, where u = (z, v), is separable if and only if on the

extent of Q, there are no touching entries into vertices of the current path, situated on it closer to the beginning (the vertex a), than the vertex z. We show how this criterion can be used in the traversal process. Each non-touching

arc, from

the instant of its appearance on the current path, (that is, after the direct passage along it) will be considered to be “suspicious”_ The following is taken as a mark of suspiciousness. At the instant OL u,+,=zE&. have been completed. let the direct passage along the touching arc(y, Z) : u,=Y,

212

E. A. Dinits, M. A. Saitsev and A. V. Karzanov

Then, obviously, all the arcs situated on the current path L, are further from the beginning than the arc emerging from z (that is, all the arcs of the contour L’o+ I , except for the arc emerging from z), cannot generate a separable branch of the traversal. Therefore all such arcs, possessing at the instant considered the sign of suspiciousness, are freed from it. It is obvious that the separability of a branch of the traversal Q, is equivalent to it being regarded as “suspicious” up to the instant of the return passage along the arc U. Therefore, theoretic~ly an algorithm for finding separable branches of the traversal has been obtained. But for this algorithm to become sufficiently economical (in the sense of estimating the order of the amount of work involved), it is necessary to indicate a method of erasing the sign of suspiciousness, which does not require all the arcs of the contour being generated to be scanned at each touching instant. This method is as follows. It is necessary to have a register of “suspicious” arcs (r.s.a.) in the order in which they occur on the current path. Then we only have to organize non-trivially the cancellation of the elements of the r.s.a. At the instant of touching there is discarded from the r.s.a. a “tail” (some number of elements from the end), so the problem is to find the element of the r.s.a. which becomes the last as a result of this. This element could be found by sc~ning the r.s.a. from the end, if the vertices possessed a feature making it possible to determine the order of their arrangement on the current path. Therefore the following is proposed. The vertices of the graph must be numbered in the order of traversal by the numbers 1,2, . . . ., n in the order of their first occurrence in the traversal. The current path is changed only from the

“tail”, and on the attachment of it there is assigned to it a vertex with a number greater than any previously assigned. Therefore it can be asserted that for any cuof the path L, the numbers of the vertices increase from a to va (which is what was required). We now show how the discovery of separable branches of the traversal implies the distinguishing of the blocks of the graph G. At the instant of the return passage along the arc u = (z, y) suppose it has been observed that the branch Q, is separable. Then the set of internal vertices of the corresponding branch of blocks is VUand can be found at this instant as the set of vertices encountered in the traversal not earlier than the vertexy. In order, at the instant of finding the branch of blocks, to distinguish the set of vertices of its radical block (as indicated in section 1 of the paper, this is suf~cient for distinguishing all the blocks of the graph), it is suf~cient in ending each branch of blocks, to eliminate from further consideration the set of its internal vertices. Then at the instant of completing the traversal of any branch of blocks G’, all its sub-branches depending on the radical block B, will have been traversed and their internal vertices eliminated. Only the vertices of B remain, which is what was required. For economy in carrying out the operations described it is proposed to arrange the current register of vertices (c.r.v.) in the order of increasing ordinal numbers. The elimination of vertices from the c,r.v. will be reduced to the discarding of its “tail”. 7. Therefore, we pass to the formal description of the algorithm, namely to a description of the additional operations which must be carried out in the traversal process, in order to distinguish the blocks and separating vertices of the graph G. a’. Let us first encounter the vertex v at the instant CLWe assign to it the next number N(u). We enter it (its identifier is understood) at the end of the c.r.v. file. We enter the arc uy at the end of the r.s.a. file. b’. Let the direct passage over the touching arc (v,, va+ 1) have been made. We consider the r.s.a. from the end to the-first element of it - the arc {x, y), for which N(x) GN( ~~,+.~>.in what follows we regard this arc as the last in the r.s.a.

213

Distinguishingblocks in a graph

c’. By the return passage along the arcu,=

(z, y) let us “return”

to the vertex z. If the arc z+,

stands last in the r.s.a., we do the following. We transfer the end of the r.s.a. back to the cell. We mark the vertex z as separating, if it does not already have this feature, and enter z in the register of the new block B. We scan the c.r.v. from the end, entering the scanned vertices in the vertex register of the block B. We continue the process until we arrive at the vertex y and do not enter it. Afterwards we regard as the last vertex in the c.r.v. that precedingy. d’. At the end of the traversal of all the vertices of the c.r.v. we enter in the register the next block A (uc~),

if in the c.r.v. there is at least one more vertex besides a.

If it is also required to construct

the graph of blocks F(G), the following are the additional

operations. c”. We add to the part of the tree F(G) already constructed

the vertex “B”, corresponding

to

the next block B found, and “z”, if z has not previously been marked as separating. If it has been marked, we “draw” in F(G) an arc between “Y” and “B”. d”. Similar to c”. 8. Estimation

of the amount of work in the algorithm. We first consider the actual traversal of

the graph. We first show how to arrange the information untraversed constant.

so that at a given instant the search for an

arc incident with any vertex, will require a number of operations

not exceeding some

Before beginning a traversal from each vertex v we add to the register of vertices adjacent to v a reference character: with each element of the register we associate two cells, containing references to the preceding and following elements of the register. With the vertex Y we associate a reference to the first element of the register. So that this register will always correspond

to untraversed

sufficient to cancel elements from it at the required instants. The cancellation requires constant

numbers of operations

here.

It is easy to see that with this arrangement a - c requires a constant

traversal is proportional

arcs, it is

of elements obviously

the repeated implementation

of any of the rules

amount of work. Therefore, the amount of work in completing the whole to the number of steps in it, and does not exceed O(m) operations.

We pass to the estimation

of the amount of work in the algorithm, that is, of the operations

by the rules a’ - d’, c” and d”. 1) each vertex of the graph is entered once in the c.r.v., it is scanned once for the return passage, it is entered once in the register of vertices of the next block and it is checked whether it is separating (not counting

operations

with the vertex on which the block “depends”),

this is O(n)

operations; 2) each arc is entered once in the r.s.a., it is scanned once for the return passage along it (not counting the scanning of the arc on which the return passage stops), this is O(m) operations; 3) the actual construction

of F(G), this is O(n) operations;

4) all the remaining operations in the repeated use of any of the rules do not require operations with registers, that is, they involve a constant amount of work, this is again O(m) operations.

214

E. A. Dinits. M. A. Zaitsev and A. V. Karzanov

Therefore, taking into account the inequality n G m t 1, known for a flow graph, we obtain that the estimate of the amount of work of the whole algorithm is O(m) operations. We finally estimate the amount of storage required for implementing obvious that to each vertex and each arc of the graph there corresponds information

cells. Therefore,

9. Remarks.

the algorithm.

It is

only a limited number of

the amount of storage is estimated as O(m) cells.

1. Instead of the c.r.v. we could have introduced

register of arcs with similar rules. In this case at the “output”

in the algorithm the current

of the algorithm we would have

obtained the assignment of blocks with registers of the arcs belonging to them. Some simplification of the algorithm (the absence of the analog of the special operations register of the block on which it depends) is obtained

for entering

the vertex in the

because of the fact that each arc belongs to

one and only one block. 2. In a non-oriented

graph G an arc is called separating if its removal destroys the connectivity

of the graph. If all the separating arcs are removed from the graph G, the connectivity

components

of the resulting graph will be subgraphs of the original graph. These subgraphs are called bicomponenrs (leaves) of the graph G. The factor graph obtained

from G by the shrinking of each bicom-

ponent to a point is called its Herrz graph. The bicomponents can otherwise be defined as the subgraphs tight on the class of vertices with respect to the equivalence s : s ( ul, I?) -+F there exists a cycle containing v1 and v2. (This definition extends to flow graphs, with the replacement of “cycle” by “contour”.) It is possible to find the bicomponents

and separating arcs of a graph G and construct

its

Hertz graph by means of an algorithm differing negligibly from the algorithm for distinguishing blocks presented in this paper, with the same estimates of the amount of work and memory volume required. The changes are as follows. Firstly, in rule b the inequalityN(z) N( 2)
G!y( LJ,+~) is replaced by

(u,+9).(This

means that at a touching instant we erase the mark of suspiciousness of all the arcs situated on the contour L’,, 1 being generated.) Secondly, on finding a separable branch QU, u=(z,

9)) we do not include the vertex z in the register of the next bicomponent.

Thirdly,

we mark as separating not the vertices, but the arcs, on which the separable branches depend. The construction

of the Hertz graph is similar to the construction

of the graph of blocks.

The algorithm obtained is close to the algorithm derived by A. V. Karzanov and is generalized to the oriented case just like the latter (see [5] ). Translated by J. Berry REFERENCES 1.

WHITNEY, H. Non-separable and planar graphs. LPans Amer. Math. Sot., 34.339-362,

2.

ORE, 0. 79teov ofgraphs (Teoriya grafov), “Nauka”, Moscow, 1968.

3.

FARADZHEV, I. A. Effective algorithms for the solution of problems for flow graphs. Zh. vjJchisl. Mat. mat. Fiz., 10.4, 1049-1054, 1970.

4.

FARADZHEV, 1. A. An algorithm for the separation of the bicomponents of a flow graph. Proceedings of the Third School on Mathenmtical Programming and Rehted Questions (Tr. Tret’ei shkoly po matem. programmirovaniyu i smezhnym vopr.), No. 3,650-654, TsEMI, Moscow, 1970.

1932.

Short communications

215

5.

KARZANOV, A. V. An economical algorithm for finding the bicomponents of a graph, Proceedings of the Third School on MathematicalProgrammingand Related Questions (Tr. Tret’ei shkoly po matem. programmirovaniyu i smezhnym vopr.), No. 2, 343-347, TsEMI, Moscow, 1970.

6.

BERGE, C. Theory ofgraphs and its applications (Teoriya grafov i ee primeneniya), Izd-vo in. lit., Moscow, 1962.

SHORT COMMUNICATIONS

SOME NUMERICAL METHODS OF DESIGNING ELECTRICAL NETWORKS* N. P. ZHIDKOV, N. P. ILYSHEVA and D. V. TIMOFEEV Moscow (Received 18 April 1973)

ITERATIVE methods (direct iteration, inverse iteration, inverse matrix, the linearization method and the generalized Gauss-Seidel method) of calculating the parameters of network modes of electrical systems are explained. The convergence of these methods is analyzed and estimates of the numerical results are given. In calculations using the generalized Gauss-Seidel method the number of iterations and the computing time are considerably reduced.

1. Introduction When determining the optimal modes of heavily loaded networks a large number of flow distribution calculations have to be carried out [ 1, 21. The results of these calculations enable answers to be given to a number of important questions, namely: 1) is the given mode of the system feasible; 2) will the voltage at the nodal points exceed specified limits. Great difficulties arise in calculating the parameters of modes in complex network schemes with a large number of nodes and branches. The information necessary for this requires a large memory, and a large expenditure of computer time is required to obtain a result. The realization of the calculation also becomes complex, since we have to deal with complex matrices of high order and with large systems of non-linear equations. Another difficulty is that solutions may be obtained which satisfy the system but not the corresponding physical requirements. Therefore, despite the existence of some programs for calculating power systems, at the present time, both here and abroad, the search for more efficient computing methods continues. This paper is devoted to these questions.

*Zh. vjjchisl. Mat. mat. Fiz., 14, 5, 1317-1323, 1974.