An algorithm to generate all spanning trees with flow

An algorithm to generate all spanning trees with flow

MATHEMATICAL AND COMPUTER MODELLING PERGAMON Mathematical and Computer Modelling 35 (2002) 1453-1458 www.elsevier.com/locate/mcm A n A l g o r i t h...

279KB Sizes 0 Downloads 66 Views

MATHEMATICAL AND COMPUTER MODELLING PERGAMON

Mathematical and Computer Modelling 35 (2002) 1453-1458 www.elsevier.com/locate/mcm

A n A l g o r i t h m to G e n e r a t e All S p a n n i n g Trees W i t h F l o w YI-KuEI LIN Department of Information Management, Van Nung Institute of Technology Chung-Li, Tao-Yuan, Taiwan 320, R.O.C.

(Received November 2001; accepted December 2001) A b s t r a c t - - S p a n n i n g tree enumeration in undirected graphs is an important issue and task in many problems encountered in computer network and circuit analysis. This paper discusses the spanning tree with flow for the case that there are flow requirements between each node pair. An algorithm based on minimal paths (MPs) is proposed to generate all spanning trees without flow. The proposed algorithm is a structured approach, which splits the system into structural MPs first, and also all steps in it are easy to follow. (~) 2002 Elsevier Science Ltd. All rights reserved.

K e y w o r d s - - S p a n n i n g tree, Flow, Minimal path, Undirected network.

1.

INTRODUCTION

T h e s p a n n i n g tree of a network is a minimal subnetwork which connects all nodes b u t w i t h o u t circle. M a n y approaches [1-13] had been proposed to generate all spanning trees of an undirected network. B u t no flow is considered in such spanning trees. However, it is an i m p o r t a n t issue to consider the flows (or traffic) between node pairs in m a n y real-life systems such as c o m p u t e r systems, t e l e c o m m u n i c a t i o n systems, etc. For instance, a telecommunication system has multiple switches (nodes), transmission lines (arcs), and calls between all switches (flow requirements). Hence, this paper discusses the problem a b o u t the spanning tree with flow under the condition t h a t there are flow requirements between each node pair. Here, a spanning tree with flow is defined to be subnetwork with flow parameter, which connects all nodes, contains no cycle and fulfills the flow requirement between each node pair. A minimal p a t h (MP) between the node pair (i,j) is a set of arcs and no proper subset of it is a p a t h between (i,j), see [14]. A necessary condition for a subnetwork H of an undirected network G to be a spanning tree is that, for each node pair (i,j), there exists exactly one M P between (i, j) in H . Using this p r o p e r t y of MPs, this paper, thus, first presents an algorithm to generate all spanning trees in terms of M P s in Section 3. In Section 4, another algorithm is t h e n p r o p o s e d to generate all spanning trees with flow for the case t h a t there are flow requirements between each node pair. This work was supported in part by the National Science Council, Taiwan, R.O.C., under Grant No. NSC 892213-E-238-002. 0895-7177/02/$ - see front matter © 2002 Elsevier Science Ltd. All rights reserved. PII: S0895-7177(02)00096-1

Typeset by ~4~4$-TEX

1454

Y.-K. LIN

2. M I N I M A L

PATHS

AND

SPANNING

TREES

Let G = (N, A) be an undirected network where N is the set of n nodes and A = {hi [ 1 < i < IA[} is the set of all arcs. Let E ( i , j ) denote the set of M P s between node pair (i,j) and m =- ~ i < j IE(i,j)[ be the n u m b e r of M P s between all node pairs, where IE(i,j)l is the n u m b e r of M P s between (i, j). T h e vector X = ( x l , x 2 , . . . , X l A i ) and F = ( f l , f ~ , . . . , f m ) denote the s u b n e t w o r k s t h r o u g h deleting arcs and M P s from G, respectively, where x~ = 0 and fj = 0 (respectively, xi = 1 and fj = 1) denote t h a t the arc ai and M P mpj are deleted (respectively, not deleted) from G, respectively. Hence, X is the same as (N, A x ) and F is the s a m e as (N, AF), where A x = {hi I xi = 1 for 1 < i < IAI} and AF = {hi I ai E mpj for an j s.t. f j = 1} = Ul
3.

Pmin =

n {ZF E p [ [ZF[ = n -- 1}, where [ZF[ -- ~-~i=1 Zi.

In order to generate F, let E = E ( 1 , 2 ) x E ( 1 , 3 ) x . . . x E(1, n) x E ( 2 , 3 ) x . . . x E ( n - 1,n) be the C a r t e s i a n p r o d u c t of n ( n - 1)/2 sets of E(i, j) first. Each c o m p o n e n t Ew of E represents t h a t one and only one M P is chosen from E ( i , j ) for each i < j, where w = 1, 2 , . . . , 1-[i
Spanning Trees With Flow

1455

Determine the Cartesian product of n(n-1)/2 sets of MPs E = E(1,2) x E(1,3) x . . . x E(1,n) x E(2,3) x ... x E(n-l,n)

Generate F =

1 1

{FwlEweN} = {FIF = (f l, fi ..... fm) s.t. fi.j = 1 V ( i, j) l

Generate 0 = {ZFIFeF}

Determine Pmin = {ZFE pl

IZFI = n-1 }

Figure 1. The proposed procedure to find all spanning trees.

3. A L G O R I T H M TO G E N E R A T E ALL S P A N N I N G TREES ( W I T H O U T FLOW) S t e p 1. List all M P s in E ( i , j ) in t h e o r d e r ( 1 , 2 ) , ( 1 , 3 ) , . . . , ( 1 , n ) , ( 2 , 3 ) , . . . , ( n S t e p 2. D e t e r m i n e t h e C a r t e s i a n p r o d u c t E of n(n - 1)/2 sets of M P s E = E ( 1 , 2 ) x E ( 1 , 3 ) x . . . x E ( 1 , n ) x E(2,3) x . . . x E ( n -

1, n).

1,n).

S t e p 3. T r a n s f o r m each c o m p o n e n t E ~ of E to t h e c o r r e s p o n d i n g Fw = ( f l , f2 . . . . . fro) s.t. fk = 1 if mpk a p p e a r s in Ew a n d fk = 0 if otherwise. T h u s , F is o b t a i n e d . S t e p 4. T r a n s f o r m each Fw c F to t h e c o r r e s p o n d i n g ZF, o = ( z l , z 2 , . . . , ZlAI) s.t. zk = 1 if

ak e Ul<_j<_m {mpj I fJ = 1} a n d zk = 0 if ak ~ Ul
1< 3 a4

~

as

Figure 2. A simple undirected network. S T E P 1. rap1 : { a l } , glzp2 = { a 4 , a 3 } , mp3 = {a4,ah, a2}, E ( 1 , 2 ) = {?'D.pl,mp2,~tp3 }. rap4 = { a l , a 2 } , rap5 :

{ a 4 , a h } , rap6 = { a l , a 3 , a h } ~ rap7 = { a 4 , a 3 , a2}, E ( 1 , 3 ) :

rrtp6 , mp7 }.

raps = {a4}, rap9 = { a l , a3}, mplo = { a l , a2, a s } , E ( 1 , 4 ) = {raps, rap9, m p l o } . rap11 = {a2}, mpl2 = { a 3 , a h } , mpl3 = { a l , a 4 , a h } , E ( 2 , 3 ) = { m p l l , m p 1 2 , m p 1 3 } .

{?rip4 ,rnph,

1456

Y.-K. LIN

?riP14 ~- {a3}, m p l 5 = {al, a4}, mp16 = {a2, as}, E(2, 4) = {mpl4, m p 1 5 , raP16}. rapt7 = {as}, rnpls = {a2, a3}, rap19 = {a2, al, an}, E(3, a) = {rnp17, topis, 77/.p19}. STEP 2. E = E ( 1 , 2 ) × E ( 1 , 3 ) × E ( 1 , 4 ) × E ( 2 , 3 ) × E ( 2 , 4 ) × E ( 3 , 4 ) = { m p l , m p 2 , m p 3 } × {rap4, mph, rap6, rapT} × . . . × {rnp17, rnpls, mptg} = (mplmp4mpsmpllmp14mp17, m p l m p 4 m p s m p l l m p 1 4 m p l s , . . . ,mp3mpTrnplomp13mp16mp19). Thus, E has 972 (3 × 4 × 3 × 3 × 3 × 3) components. STEP 3. For E t = m p l m p 4 m p s m p l l m p 1 4 m p 1 7 , generate F1 = ( f 1 , f 2 , . . . , f 1 9 ) s.t. f l = f4 = fs = f l l = f14 = f17 = 1 and fk = 0 for others. For E2 = m p l m p 4 m p g m p l l m p 1 4 m p l s , generate F2 = ( f l , f 2 , . . . , f19) s.t. f l = f4 = f9 = f l l -- f14 = f l s = 1 and fk = 0 for others.

For E972 = mp3mp7mplomp13mp16mp19, generate/;'972 -= ( f l , f 2 , . . . , f19) s.t. f3 = f7 = flo = f13 --- f16 --- f19 --- 1 and fk = 0 for others. STEP 4 AND 5. In F1, rap1 U rap4 t2 raps U m p l l U mpx4 t2 mpl7 = {al, a2, a3,a4, as}. T h u s ZF1 = ( 1 , 1 , 1 , 1 , 1 ) and IZF, I = 5 and so ZFx is not a spanning tree. In F2, m p l tJ rap4 t2 mp9 t_J rap11 t2 mpla t2 m p l s = {al,a2,a3}. T h u s ZF2 = (1, 1, 1,0,0) and IZF=I = 3 and so ZF~ is a s p a n n i n g tree. After calculating, all spanning trees are (1,1,0,1,0), (1,1,1,0,0), (1,1,0,0,1), (1,0,0,1,1), (1,0,1,0,1), (0,0,1,1,1), (0,1,1,1,0), and (0,1,0,1,1). In other terminology, all spanning trees are {al,a2,a4}, ( a l , a 2 , a 3 } , {al,a2,ah}, (al,a4, ah}, {al,a3,ah}, (a3,a4,ah}, (a2,aa,a4}, and {a2, a4, as}.

4. A L G O R I T H M TO GENERATE ALL SPANNING TREES WITH FLOW W h e n e v e r there are flow requirements between each node pair, all spanning trees with flow can be g e n e r a t e d as follows. Step 1. A p p l y the algorithm in Section 3 to generate all spanning trees (without flow). Step 2. For each spanning tree (without flow), generate the corresponding spanning tree with flow as the following steps. (2.1) T h e flow on the unique M P of each node pair ( i , j ) is set to be the required flow of ( i , j ) . (2.2) T h e flow ui on arc ai is equal to the s u m of flows on those M P s containing ai. T h e spanning tree with flow is represented as an IA[-tuple vector: (ut, u2 . . . . , UlAi).

4.1. E x a m p l e 2 S u p p o s e t h a t there are flow requirements in E x a m p l e 1 as follows: 2 for node pair (1,2), 1 for (1,3), 3 for (1,4), 1 for (2,3), 2 for (2,4), and 1 for (3,4). T h e spanning trees with flow can be g e n e r a t e d as follows. STEP 1. All s p a n n i n g trees w i t h o u t flow are generated in E x a m p l e 1.

STEP 2. One s p a n n i n g tree is (1,1,0,1,0) with mpl for node pair (1,2), mp4 for (1,3), mps for (1,4), mp11 for (2,3), mp15 for (2,4) and rap19 for (3,4). STEP 2.1. T h e flow on rap1 is 2, on mp4 is 1, on mps is 3, on rap11 is 1, on rap15 is 2 and on mp19 is 1. (See Table 1.) STEP 2.2. Since m p l , rap4, mp15, and mp19 all contain al, the flow Ul on al is the s u m of flows on these M P s (i.e., 2 + 1 + 2 + 1). Similarly, u2 = 1 + 1 + 1, u3 = 0, u4 -- 3 + 2 + 1, and u5 --- 0. Hence, we o b t a i n one spanning tree with flow: (6,3,0,6,0). (See Table 2.)

All s p a n n i n g trees with flow can be generated similarly as Step 2 (see Table 3).

Spanning Trees With Flow

1457

Table 1. Required flow for each node pair and the corresponding MP. Node Pair

Required Flow

(1,2)

2

Selected Minimal Path* mpl ={al}

(1,3) (1,4)

1 3

m p 4 = {al,a2}

(2,3) (2,4)

1 2

m p l l = {a2}

(3,4)

1

mpl9 ={al,a2,a4}

m p s ={a4} rnp15 = {al, a4}

*The selected minimal path is chosen from the spanning tree (1,1,0,1,1). Table 2. The flow on MP corresponding to the flow on arc. mpl 2

al

mpa

raps

1

mp15 2

1

a2

mpll 1

1 1

as

3

a4

2

1

2

1

a5

Flow on MP

2

1

3

1

Flow on Arc

mpl9

6 3 0 6 0

(6 ----2 + 1 + 2 + 1) (3----1+1+1) (6=3+2+1)

Table 3. The spanning trees corresponding to the spanning trees with flow. The Spanning Tree

The Spanning Tree with Flow

{al, a2, a4} {al, a2, a3} {al, a4, as}

(6,3,0,6,0) (6,3,6,0,0) (5,0,0,7,3)

{al, {al, {a3, {a2,

(6,7,0,0,6) (6,0,7,0,3) (0,0,5,6,3) (0,5,0,6,6)

a2, a3, a4, a4,

as} a5} as} as}

5. C O N C L U S I O N S

AND

FUTURE

RESEARCH

First, this p a p e r proposes an a l g o r i t h m to g e n e r a t e all s p a n n i n g trees ( w i t h o u t flow) in t e r m s of m i n i m a l paths. I n each s p a n n i n g tree t h e r e is exactly one m i n i m a l p a t h b e t w e e n each n o d e pair. We use this p r o p e r t y to assign the flow to t h e s p a n n i n g tree for t h e case t h a t t h e r e are flow r e q u i r e m e n t s b e t w e e n all node pairs. T h e n all s p a n n i n g trees w i t h flow are t h u s o b t a i n e d . T h e proposed a l g o r i t h m is in fact a s t r u c t u r e d approach t h a t splits the s y s t e m into s t r u c t u r a l MPs, a n d also all steps in it are easy to follow. If each arc has several capacities (i.e., each arc is m u l t i s t a t e ) w i t h some p r o b a b i l i t y d i s t r i b u t i o n a n d there are flow r e q u i r e m e n t s b e t w e e n each n o d e pair, we c a n t r y to e x t e n d the proposed approach to calculate t h e p r o b a b i l i t y (or called reliability) t h a t t h e r e q u i r e m e n t s are fulfilled in t h e f u t u r e research.

REFERENCES 1. K.K. Aggarwal and S. Rai, Reliability evaluation in computer-communication, I E E E T r a n s a c t i o n s on Reliability 30, 32-35, (1981). 2. V.B. Basnal and K.B. Misra, Hardware approach for generating spanning trees in reliability studies, Microelectronics and Reliability 21 (2), 243-253, (1981). 3. V.B. Basnal, K.B. Misra and M.P. Jain, Improved implementation of search technique to find spanning trees, Microelectronics and Reliability 23 (1), 141-147, (1983). 4. J.P. Char, Generation of trees, two-trees, and storage of master forests, I E E E Transactions on Circuit T h e o r y 15 (3), 228-238, (1968). 5. H.N. Gabow and E.W. Myers, Finding all spanning trees of directed and undirected graphs, S I A M J o u r n a l on C o m p u t i n g 7 (3), 280-287, (1978).

1458

Y.-K. LIN

6. R. Jayakumar, K. Thuslasiraman and M.N.S. Swamy, MOD-CHAR: An algorithm for Char's spanning trees enumeration algorithm and its complexity analysis, I E E E Transactions on Circuits and Systems 36 (2), 219-228, (1989). 7. S. Kapoor and H. Ramesh, Algorithms for enumerating all spanning trees of undirected and weighted graphs, S I A M Journal on Computing 24 (2), 247-265, (1995). 8. V. Kumar and K.K. Aggarwal, A Petri net approach to determine all spanning trees for overall reliability analysis of general networks, Reliability Engineering and System Safety 25, 283-291, (1989). 9. T. Matsui, A flexible algorithm for generating all the spanning trees in undirected graphs, Algorithmica 18, 530-544, (1997). 10. R.B. Misra, An algorithm for enumerating all simple paths in a communication network, Microelectronics and Reliability 19, 363-366, (1979). 11. V.V.B. Rao and V.G.K. Murti, Enumeration of all trees of a graph, Electronics Letters 5 (13), 282-283, (1969). 12. A Shioura, A. Tanura and T. Uno, An optimal algorithm for scanning all spanning trees of undirected graphs, S I A M Journal on Computing 26 (3), 678-692, (1997). 13. W. Xu and X. Lin, A new algorithm for the reliability evaluation of computer-communication network, Microelectronics and Reliability 26 (6), 1013-1017, (1986). 14. K.K. Aggarwal, Y.C. Chopra and J.S. Bajwa, Capacity consideration in reliability analysis of communication systems, I E E E Transactions on Reliability 31, 177-180, (1982). 15. R. Jayakumar, K. Thuslasiraman and M.N.S. Swamy, Complexity of computation of a spanning tree enumeration algorithm, I E E E Transactions on Circuits and Systems 31 (10), 853-860, (1984).