6

Click here to load reader

A local algorithm for finding the bicomponents in a flow graph

Embed Size (px)

Citation preview

Page 1: A local algorithm for finding the bicomponents in a flow graph

U.S.S.R. Comput. Maths Math. Phys. Vol. 18, pp. 274-279 0 Pergamon Press Ltd. 1979. Printed in Great Britain.

0041-5553/78/1001-0274$07.50/O

A LOCAL ALGORITHM FOR FINDING THE BICOMPONENTS IN A FLOW GRAPH*

V. A. EVSTIGNEEV

Novosibirsk

(Received 1 February 1977)

A LOCAL algorithm for finding the bicomponents in a flow graph is constructed.

All the definitions concerning local algorithms can be found in [ 1 ] , and definitions concerning graph theory in [2].

Let a flow graph G = (X, U) be given. We denote by 2 the graph obtained from the graph G by replacing all the arcs by edges.

Definition 1 (see [ I] ). The neighbourhood Sk@ I?) of order k of the edge ii = (xc xi) in the. graph c is defined as a subgraph, tight on the vertices xi, xi and the vertices at a distance k from xi or xi (here distance is the number of edges in the shortest chain connecting the vertices

considered).

Definition 1’. The neighbourhood Sk(u, C) of order k of the arc u = (Xi, xi) is defined as the subgraph in the orgraph (flow graph) G, isomorphic after replacing arcs by edges to the

neighbourhood S@, .c) of the edge ii = (xi, xi) in the graph E

Let the arcs of the graph be ordered in some way, and let P1 (u, C) be the predicate “the arc u belongs to some component of strong connectivity”. The values of the predicate are taken from the set (0, A, 1).

Description of the algorithm A.

Step 1. For every arc we consider the neighbourhood &(u, C). We have:

a) P1 (u, G) = 1, if u belongs to a contour lying wholly within Sk(u, G);

b) Pl (u, G) = 0, if the arc u is incident with a source or sink of the graph;

c) Pl (u, G)'= A otherwise.

After executing step 1 all the neighbourhoods of arcs will contain arcs with labels which are values of the predicate PI.

*Zh. vjkhid. Mat. mat. Fiz., 18,5,1345-1349,1978.

274

Page 2: A local algorithm for finding the bicomponents in a flow graph

Short communications 275

Step 2. We remove from the graph all the arcs with the labels 0. Let the label of the arc u be A. We have: a) P1 (u, G) = 1, if the arc u belongs to the path p [Z A, in the neighbourhood S&, G) the vertices X and jr being joined by a path ii+ 1-1, consisting wholly of arcs with the label 1; b) P1 (u, G) = 0, if the arc u calls at a vertex which has become a sink or source after the removal of the arcs with the label 0.

Step 2 is repeated until no arc with the label A remains in the graph, or it is impossible to change the label A of a single arc.

This ends the algorithm. It is easy to verify that in the fust case all the bicomponents will have been found, in the second case there are only strongly connected subgraphs, which are not necessarily bicomponents and are connected to each other by arcs with labels A.

Obviously it is only possible to change the remaining labels A by seeking additional information. It can be obtained by introducing new predicates, for example, such as P~(u, G): “the arc

u = (xi, xi) emerges from the vertex xi at which the arc v with label A arrives”, and P3(u, G): “the arc u = (xi, xi) arrives at the vertex xi from which the arc v with the label A emerges”. These predicates enable us to detect pendant bicomponents, that is, to answer the question whether the strongly connected subgraph found is a bicomponent, at which there only arrive, or from which there only emerge, arcs not belonging to a bicomponent. However, the use of these predicates does

not permit us to distinguish a large contour, that is, one not located in a single neighbourhood, from two large contours connected by a path. Moreover, there is no reason to suppose that the choice of other auxiliary predicates or an increase in their number (the memory of the algorithm) will enable us to solve the problem posed.

The above suggests the idea of varying somewhat the concept of a local algorithm.

We note that it is characteristic of the algorithm described above that at each’step the neighbourhoods of all the edges are considered and the labels are displayed simultaneously, that is, all the neighbourhoods are regarded as consisting of edges without labels or of’edges with one label, with two labels etc. Each step of the algorithm then consists of m independent substeps, where m is the number of edges (or arcs).

We introduce the following definitions.

Definition 2 (see [3] ). A parallel iterative algorithm is defined as an algorithm by which at each step a label is placed independently and simultaneously on all the edges of the graph.

Therefore, the local algorithms studied in [ 1,4] belong to the class of parallel algorithms.

We now consider a class of algorithms in which the value of the predicate calculated for some edge is used to calculate the value of the same predicate on an edge incident with the first one.

Definition 3 (see [3] ). A sequential iterative algorithm is defined as an algorithm, in which each step consists of the assignment of a label to one edge (arc) taking into account the labels assigned to the edges at previous steps. Labels A previously assigned are not thereby changed.

We note that the absence of a label may be regarded as an additional value of the predicate - an empty value. Thereby the sequential algorithm practically uses a four-valued logic.

Page 3: A local algorithm for finding the bicomponents in a flow graph

276 K A. Evstigneev

We show that the solution of the problem of finding the bicomponents in a graph can be obtained by a sequential algorithm with memory 2. More precisely, we will use a combined algorithm with the basic predicate PI : “the arc belongs to a bicomponent” whose values are calculated by a parallel algorithm, and the auxiliary predicate P2 : “the arc belongs to a contour”, whose value is calculated by a sequential algorithm.

Description of the algorithm B (it is based on the algorithm proposed in [5] ).

Step 1. We mark with the labels a = {A, 0, 1) the arcs of G resulting from the values of the predicate P1 (u, G) (see the algorithm A described above).

Step 2. We put the value of the predicate P2 on all the arcs of the graph equal to 0, We choose an arbitrary arc uAl=ul and calculate on the arcs of the graph the values of the predicate P2 by the following rule:

a)weputPZ=Aforthearcul;

b) we put P2 = A for an arc emerging from the end of the arc with the label ((u, A), a! = A, 1.

If there is no arc with the label (A, 0) we pass to step 9.

If in the neighbourhood &(u, G) of the arc u with the label (1, A) there is an arc with the label (A, 0)) emerging from a component of strong connectivity and joined to the arc u by the path u, then the arcs of the path u are labelled consecutively. If there are no such arcs, then we label the arcs of the path ,Ci to the beginning of the nearest arc emerging from the neighbourhood considered (the paths ji and ~1 may be empty). If there are no such paths either, that is, the component of strong connectivity is pendant, we pass to step 3.

Step 2 is repeated until either an arc v is labelled from whose end an arc w with the label (CY, A) emerges (in this case we pass to step 4) or an arc i? with the label ((u, 7), where 7 = 0 or I

(in this case we pass to step 5), or else an arc v is labelled, arriving at the pendant bicompact (in this case we pass to step 3).

Step 3. Let vAA - be an arc arriving at a pendant bicompact. We assume for it the

predicate value P2 = 0 and pass to step 6.

Step 4. Let vQ be the last arc labelled at step 2. We assume for it P2 = 1 if (Y = A, and

Pz=Oifcu=l.

Step 5. Let VOA be an arc from whose end there emerges an arc with P2 = 7,7 = 0 or 1. We assume for it Pz(v) = 7.

Step 6. Let waA= (5, Y) be the last arc for which the value of the predicate P2 has been

changed from A to 0 or 1, and let EVA= (z, y) be an arc incident with it (see Fig. 1).

Then:

a) if from the vertex y there exists a path fi to the beginning of an arc emerging from &(w, G), then we pass to step 2 with the arc iT as the initial arc;

Page 4: A local algorithm for finding the bicomponents in a flow graph

Short communications 277

b) if there is no path ~1 described above in Sk(w, C) and 7 = 1, then we assume P@) = 0

and pass to step 6 with the arc W as the initial arc;

c) if there is no path p described above in &(w, C) and 7 = A, then we assume P#) = 1 and pass to step 6 with the arc iii as the initial arc;

Step 6 is repeated until the value of the predicate P2 of the arc w emerging from the end of

the arc Y has been changed (see Fig. 1).

FIG. 1 FIG. 2

Step 7. Let the arc t(“A be incident with the arcs v and w (Fig. 1). For it we have a = A.

We assume Pi = 0 and pass to step 8.

Srep 8. Let the arc tA A arrive at the beginning of the arc with the label (A, 0). Then if from

the end of the arc r an arc i emerges with Pa(S) = 0, then we pass to step 2 with one t as the initial arc; otherwise we assume P2(f) = 0 and continue as long as possible.

Step 9. We assume P2 = 0 for all arcs with labels (a, a), incident with arcs with Pzf@, and pass to step 8.

Step 10. For the arc u with PI(U) = A we assume

Pi(U) = {

1, if P,(u)= 1,

0, if &(I&) = 0.

The algorithm is complete.

We show that this algorithm gives the solution of the problem posed. Indeed, the following statements hold.

Reposition 1. The algorithm B is finite.

Indeed, every arc for calculating the predicate P1 is considered a ftite number of times, and in calculating the predicate P2, not more than twice.

Proposition 2. After the end of the work of the algorithm B there does not remain in the graph an arc with P1 = A.

Proposition 3. The algorithm B recognises large contours (not containing a single neighbourhood

MU, G).

Page 5: A local algorithm for finding the bicomponents in a flow graph

278 K A. Evsrigneev

Reposition 4

The algorithm B recognizes chords of contours and isthmuses.

Roof: If u is the beginning of a chord, and Y’ is an arc arriving at the beginning of u, and Y” is’an arc emerging from the beginning of u (Fig. 2), then the value of the predicate P2 on the arc u is calculated immediately after the calculation of the predicate on the arc Y’. This occurs whenever u’ isidentical with the first arc on which the value of P2 is calculated (see step 2). Here three cases are possible:

a) the arc u serves as the initial chord of the contour,

b) the arc u does not belong to any contour,

c) the arc u belongs to a contour not passing through the arc Y’.

In case a) the arc Y’ also belongs to the chord of the contour, for it Pz(v’) k 1, therefore (step 5) Pa = 1 for the arc u also.

In case b) there is realized either the situation shown in Fig. 3,~ (then the arc Y’ also does not belong to the chord, for it Pi k 0 and therefore Pz(r4) = 0, see step 5), or the situation shown in Fig. 3, b (then Pi = 0 by the rule of steps 4 and 6).

FIG. 3

In case c) the arc Y” receives the label (a, A) and by step 4 for it P2 = 1 or 0, from which

also follows the replacement of the label (OL, 7) of the arc u by (o1,O) or (o, l), depending on whether o equals unity or zero.

In conclusion it can be mentioned that sequential iterative local algorithms realize the circuit of an arc or edge of a graph and therefore with their aid many problems on graphs can be solved, such as, for example, the determination of the connectivity of a graph, the fmding of a path between given vertices, the fmding of a cycle (or contour) passing through a given edge (or arc), and the fmding of points of junction and blocks (since in [6] an algorithm is presented based on a special traversal of the edges of the graph).

The author thanks Yu. I. Zhuravlev for his interest, and also L. S. Mel’nikov, A. A. Levin and A. V. Kostocbka for useful discussions and valuable comments.

i’kanslated by J. Berry.

Page 6: A local algorithm for finding the bicomponents in a flow graph

Short communiccrtions 279

REFERENCES

1. ZHURAVLkV, Yu. I. Local algorithms for calculating information. I. Kibemetika, No. 1,12-19,196s.

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

3. EVSTIGNEEV, V. A. On the solution of two problems of the theory of graphs by local algorithms. Fourth All-Union conference on problema of theoretical cybernetics. Subjects of papers (IV Vses. konf. po problemam teoretich. kibemetiki. Tezisy dokl.), 135-136, Novosibirsk, 1977.

4. KHUTORYANSKAYA, I. V. Some topics of the theory of local algorithms on graphs. Kibernetiku, No. 1, 29-33, 1971.

5. FARADZHEV, I. A. An algorithm for distinguishing the bicomponents of a flow graph. Proceedings of the third school on mathematical programming and related topics (Tr. III Shkoly po matem. programmirovaniyu i smezhnyn vopr. No. 3,650-654, TsEMI, Moscow, 1970.

6. DINITS, E. A., ZAITSEV, hi. A. and KARZANOV, A. V. An economical algorithm for distinguishing blocksinagraph. Zh. vmisl. Mut. mar. I&, 14,5,1309-1316,1974.