Académique Documents
Professionnel Documents
Culture Documents
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.
1. INTRODUCTION
This work was supported in part by the National Science Council, Taiwan, R.O.C., under Grant No. NSC 89-
2213-E-238-002.
0895-7177/02/$ - see front matter 2002 Elsevier Science Ltd. All rights reserved. Typeset by ~4~4$-TEX
PII: S0895-7177(02)00096-1
1454 Y.-K. LIN
LEMMA 2. Let X be a spanning tree. Then X = ZF for each subnetwork F of X s.t. fi,j = 1,
V(i,j).
PROOF. Given a s u b n e t w o r k F = ( f l , f 2 , . . - , fro) o f X s.t. fi,j = 1 for each (i,j). Suppose to the
c o n t r a r y t h a t X ~ ZF (i.e., ZF <_ X ) . T h e n there exists an ak ZF s.t. Xk = 1, b u t zk = 0 (note
t h a t Zp = Xp = 1 for each a p c ZF since ZF <_ X). Set Y = (Yl,Y2,... , Y k - l , Y k , Y k + l , . . . ,YIAI) =
( X l , X 2 , . . . , X k - l , X k -- 1 , X k + l , . . . ,XIAj) < X . T h a t is, Y is the s u b n e t w o r k o b t a i n e d from X by
deleting ak only. However, AF C_ A y and so Y is a connected subnetwork. This contradicts to
t h a t X is a m i n i m a l connected subnetwork. Hence, X = ZF.
For convenience, let F = { F I F = ( f l , f 2 , . . . ,fro) s.t. f~,j = 1, V ( i , j ) } and p = {ZF [ F E F}.
B y L e m m a 2, p contains all spanning trees. Let Pmin = {ZF ] ZF is m i n i m a l w.r.t. < in p}. It
is obvious t h a t Pmin = {spanning trees}. Hence, Pmin can be o b t a i n e d by further a p p l y i n g
c o m p a r i s o n a l g o r i t h m to delete those n o n m i n i m a l ones in p. However, it is known t h a t each
s p a n n i n g tree has e x a c t l y n - 1 arcs. Hence, Pmin can also be o b t a i n e d by a p p l y i n g the following
lemma.
n
LEMMA 3. Pmin = {ZF E p [ [ZF[ = n -- 1}, where [ZF[ -- ~-~i=1 Zi.
Generate F =
1
{FwlEweN} = {FIF = (f l, fi ..... fm) s.t. fi.j = 1 V ( i, j) l
1
Generate 0 = {ZFIFeF}
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 - 1, 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).
3.1. E x a m p l e 1
W e use t h e n e t w o r k in F i g u r e 2 t o i l l u s t r a t e t h e p r o p o s e d a l g o r i t h m .
1< 3 a4 ~ as
?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) com-
ponents.
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.
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.
Table 3. The spanning trees corresponding to the spanning trees with flow.
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 Reli-
ability 30, 32-35, (1981).
2. V.B. Basnal and K.B. Misra, Hardware approach for generating spanning trees in reliability studies, Micro-
electronics 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 enu-
meration algorithm, I E E E Transactions on Circuits and Systems 31 (10), 853-860, (1984).