• 沒有找到結果。

The swap edges of a multiple-sources routing tree

N/A
N/A
Protected

Academic year: 2022

Share "The swap edges of a multiple-sources routing tree"

Copied!
20
0
0

加載中.... (立即查看全文)

全文

(1)

The swap edges of a multiple-sources routing tree

Bang Ye Wu Chih-Yuan Hsiao Kun-Mao Chao

Abstract

Let T be a spanning tree of a graph G and S ⊂ V (G) be a set of sources. The routing cost of T is the total distance from all sources to all vertices. For an edge e of T , the swap edge of e is the edge f minimizing the routing cost of the tree formed by replacing e with f . Given an undirected graph G and a spanning tree T of G, we investigate the problem of finding the swap edge for every tree edge. In this paper, we propose an O(m log n + n2)-time algorithm for the case of two sources and an O(mn)-time algorithm for the case of more than two sources, where m and n are the numbers of edges and vertices of G, respectively.

Key words: algorithm, graph, swap edge, spanning tree, optimization problem.

1 Introduction

A routing tree of a graph is a spanning tree, along which the messages can be routed from sources to destinations. Let G = (V, E, w) be an undirected graph with nonnegative edge length function w. All vertices are destinations, whereas some of them are sources.

The routing cost of a spanning tree is defined by the total distance from sources to all vertices. For the sake of efficiency, the routing cost should be made as small as

bangye@mail.stu.edu.tw, Department of Computer Science and Information Engineering, Shu-Te University, YenChau, Kaohsiung, Taiwan 824, R.O.C.

skiky@mail2000.com.tw, Department of Computer Science and Information Engineering, National Taiwan University, Taipei, Taiwan 106, R.O.C.

corresponding author, kmchao@csie.ntu.edu.tw, Department of Computer Science and Information Engineering / Graduate Institute of Networking and Multimedia, National Taiwan University, Taipei, Taiwan 106, R.O.C.

(2)

possible. Given a graph and a set of p sources, the problem of finding the minimum routing cost spanning tree (MRCT) is NP-hard for any constant p > 1 [9]. When p = 1, i.e., there is only one source, it is reduced to the well-known single-source shortest- paths tree problem and can be solved in polynomial time. For the p-sources MRCT problem, several approximation algorithms have been reported, including a polynomial time approximation scheme (PTAS) for the case that all vertices are sources [12], a PTAS for the case of two sources [8], and a 2-approximation algorithm for an arbitrary number of sources [11]. A survey of the MRCT and some other related problems can be found in [10].

The survivability of a network is the ability to recover the communication if a link of the network fails [3]. A tree has the benefits of low cost and simple routing algorithms, but it suffers from weak survivability. Therefore, how to recover a tree from failures is an important issue. Any edge of a spanning tree corresponds to a bipartition of the vertex set. To recover a spanning tree from the failure of an edge, we need to find another edge crossing the bipartition so as to minimize the routing cost. For an edge e of T , the swap edge of e is the edge f minimizing the routing cost of the tree formed by replacing e with f .

Let m and n be the numbers of edges and vertices of the input graph, respectively.

In [7], the authors proposed an O(n2)-time algorithm for finding the swap edge for every edge of a single-source shortest-paths tree. More recently, an O(m log2n)-time algorithm for the same problem was reported in [1], which improves the previous one for sufficiently sparse graphs. In this paper, we investigate the problem of finding the swap edge for every tree edge when the number of sources is more than one. We present an O(m log n + n2)- time algorithm for the case of two sources and an O(mn)-time algorithm for the case of more than two sources.

(3)

The rest of the paper is organized as follows. We first formally define the notations and the problem in Section 2. In Section 3, we propose an O(m log n+n2)-time algorithm for the two-sources case. Then we propose an O(mn)-time algorithm for the multiple- sources case in Section 4. Finally, concluding remarks are given in Section 5.

2 Preliminaries

By G = (V, E, w), we denote a graph G with vertex set V , edge set E, and edge weight (length) function w. In this paper, we consider only undirected graphs with nonnegative edge lengths. For any graph G, the vertex set and edge set are denoted by V (G) and E(G) respectively. Let T be a spanning tree of G. For any e ∈ E(T ), the removal of e cuts T into two subtrees, of which the vertex sets form a bipartition (V1, V2) of V (G).

By C(e), we denote the cut set of the bipartition, i.e., the set of edges with one endpoint in V1 and the other endpoint in V2. For convenience, we assume that e /∈ C(e). It is clear that if C(e) 6= ∅, then the two subtrees can be connected to form another spanning tree of G by inserting any edge in the cut set. We use Te/f to denote the new spanning tree obtained by replacing an edge e with another edge f ∈ C(e).

For u, v ∈ V (G), the distance between u and v in G is denoted by dG(u, v), which is the total length of the edges in a shortest path between the two vertices. For U ⊂ V (G), let DG(v, U ) =Pu∈U dG(v, u) denote the total distance from v to all vertices in U . For a subgraph H, we also use DG(v, H) to denote DG(v, V (H)). A source (vertex) is a distinguished vertex in V (G). For a given set S of source vertices, the routing cost of a spanning tree T is denoted by c(T, S), which is the total distance from sources to all vertices, i.e., c(T, S) =Ps∈SDT(s, T ). When there is no confusion, we also simply use c(T ) for the routing cost. For an edge e ∈ E(T ), the swap cost is defined by χ(T, e) = minf ∈C(e)c(Te/f, S), which is the minimum routing cost of any spanning tree obtained by replacing e with another edge. The swap edge problem is formally defined

(4)

as follows:

Problem: Swap Edges for a Routing Tree (SERT)

Instance: A graph G = (V, E, w), a spanning tree T of G, and a set S ⊂ V of sources.

Goal: For each e ∈ E(T ), find χ(T, e).

In case that C(e) is empty for some e, we say that there is no swap edge for e and the cost χ(T, e) = ∞. Since the swap edges will be implicitly determined when minimizing the swap costs, we shall focus on the swap costs only. In the remaining paragraphs, we shall assume that G, T , and S are the input data of the SERT problem.

3 Two-sources case

In this section, we discuss the two-sources case of the SERT problem. Let S = {s1, s2} ⊂ V be the set of two specified source vertices and P = (s1 = r0, r1, r2, . . . , rk= s2) be the path between the two sources in T . The routing cost of T in this case is defined by

c(T, S) = X

v∈V

DT(v, S) = X

v∈V

(dT(v, s1) + dT(s2, v)) .

Removing all the edges of P from T divides T into k + 1 subtrees. Let Ti denote the subtree containing ri and Vi= V (Ti) for 0 ≤ i ≤ k. Our method for computing the swap costs for all tree edges is divided into two parts: e /∈ E(P ) and e ∈ E(P ).

3.1 Edges not in the path

To compute the swap costs of edges in Ti, we treat all vertices not in Vi as a super node, and reduce the problem to the single-source case, as shown in Figure 1. Construct an auxiliary graph Gi= (Vi0, Ei0, w0i) by shrinking all vertices not in Vi to a created vertex s as follows.

• Vi0 = Vi∪ {s}, in which s /∈ V is a created node.

(5)









 





































Figure 1: The super node s for reduction to single-source SERT problem.

• The edge set Ei0 consists of two parts: The first part contains all the edges of which both endpoints are in Vi, and the other part contains the edges (s, v) if there exists an edge (v, u) crossing the cut (Vi, V − Vi) for any v ∈ Vi.

• For each edge (u, v) such that u, v ∈ Vi, set w0i(u, v) = 2w(u, v).

• wi0(s, ri) = DT(ri, S) and for each edge (v, s), v ∈ Vi − {ri}, set wi0(v, s) = minu /∈Vi{2w(u, v) + DT(u, S)}.

Let T0 be the spanning tree of Gi, which is obtained by inserting edge (s, ri) into Ti, and let s be the source of T0.

Lemma 1: For any vertex v ∈ Vi, DT(v, S) = dT0(v, s).

Proof:

dT0(v, s) = dT0(v, ri) + w0i(ri, s)

= 2dT(v, ri) + DT(ri, S) = dT(v, s1) + dT(v, s2)

(6)

Similarly, the following result can be easily shown by the definitions, and the proof is omitted.

Lemma 2: The swap costs of all edges in Tican be computed by solving the single-source SERT problem with input (Gi, T0, s).

Lemma 3: The swap costs for all edges not in P can be found in O(n2) time.

Proof: To compute the swap costs, for each Vi, we construct the auxiliary graph and then solve the single-source SERT problem. First we compute dT(v, S) for every v ∈ V by traversing T twice: one for computing dT(v, s1) and the other for dT(v, s2). Also the set Vi for each i can be found by traversing the tree in linear time. To construct Gi, we traverse Ti in a depth first search order. By storing the graph in an adjacent list, all the auxiliary graphs can be constructed in O(n + m) time since each edge is checked twice.

Since the single-source SERT problem for Gi can be solved in O(|V (Gi)|2) time [7], the total time complexity is O(n2).

3.2 Edges in the path

In the following, we focus on how to find out the swap costs for the edges in P = (s1 = r0, r1, r2, . . . , rk= s2). Let ei = (ri, ri+1) and ni = |Vi|. Let Yiand ¯Yibe the two subtrees obtained by removing the edge ei from T , in which s1 ∈ V (Yi). Also let Ni = |V (Yi)|.

Note that V (Yi) =Sj≤iVj and Ni =Pj≤inj. For any f ∈ C(ei) and H = Te/f, we have

c(H) = (DH(s1, Yi) + DH(s2, ¯Yi)) + (DH(s2, Yi) + DH(s1, ¯Yi)).

Obviously, DH(s1, Yi) = DT(s1, Yi) and DH(s2, ¯Yi) = DT(s2, ¯Yi) since they are not affected by the removal of ei. Let f = (x, y), as illustrated in Figure 2. By defini-

(7)

























































Figure 2: A swap edge for an edge (ri, ri+1) in the path between the two sources.

tion, DH(s2, Yi) = DT(x, Yi) + Ni(w(f ) + dT(y, s2)) and DH(s1, ¯Yi) = DT(y, ¯Yi) + (n − Ni)(w(f ) + dT(x, s1)). Let

δ(f, i) = DH(s2, Yi) + DH(s1, ¯Yi)

= DT(x, Yi) + DT(y, ¯Yi) + nw(f ) + NidT(y, s2) + (n − Ni)dT(x, s1), (1)

and our goal is to compute

χ(T, ei) = (DT(s1, Yi) + DT(s2, ¯Yi)) + min

f ∈C(ei)δ(f, i),

for every 0 ≤ i < k. By a na¨ıve method, δ(f, i) can be computed in O(n) time, which implies that the swap cost χ(T, ei) can be computed in O(mn) time. Since the number of edges in P may be up to Ω(n), it takes totally O(mn2) to compute all the swap costs.

In the following, we present an incremental method and show that the two-sources SERT problem can be solved in O(m log n + n2) time.

Suppose that x ∈ Vp and y ∈ Vq, p < q. Observe that, for p < i < q,

δ(f, i) − δ(f, i − 1)

= ¡DT(x, Yi) + DT(y, ¯Yi) + nw(f ) + NidT(y, s2) + (n − Ni)dT(x, s1)¢

¡DT(x, Yi−1) + DT(y, ¯Yi−1) + nw(f ) + Ni−1dT(y, s2) + (n − Ni−1)dT(x, s1)¢

(8)

= (DT(x, Yi) − DT(x, Yi−1)) + (DT(y, ¯Yi) − DT(y, ¯Yi−1)) +(Ni− Ni−1)dT(y, s2) + ((n − Ni) − (n − Ni−1))dT(x, s1)

= DT(x, Vi) − DT(y, Vi) + nidT(y, s2) − nidT(x, s1).

Since DT(x, Vi) − DT(y, Vi) = ni(dT(ri, x) − dT(ri, y)), we have

δ(f, i) − δ(f, i − 1)

= ni(dT(ri, x) − dT(ri, y) + dT(y, s2) − dT(x, s1))

= ni(dT(ri, x) − dT(x, s1) + dT(y, s2) − dT(ri, y))

= ni(dT(ri, rp) − dT(rp, s1) + dT(rq, s2) − dT(ri, rq)) . (2)

It implies that δ(f, i) can be computed from δ(f, i−1) in constant time if all the required distances are available after a preprocessing stage. Consequently all the swap edges can be found in O(mn) time by computing δ(f, i) for each f and each i. In the following, we propose an efficient method to find the edge minimizing δ(f, i) without calculating δ(f, i) for all the edges crossing the cut.

For any edge (x, y) in which x ∈ Vp and y ∈ Vq, we say that x is the left endpoint and y is the right endpoint if p < q. In the following, we shall assume that x is in Vp, p < k. Let Ex denote the set of all edges with left endpoint x. Letf (i) = δ(f, i). Ourb approach is to compute a function Fx defined by

Fx(i) = min

f ∈Ex

f (i).b

Once the function Fx for each vertex x is determined, the minimized δ(f, i) can be found by taking the minimum of Fx(i) for all x. Since Fxis defined by the minimum of a set of functions, it can be regarded as a piecewise function. To determine Fx, it is required to find the consecutive intervals and to determine which of the functionsf is the minimumb for each interval.

(9)

For two discrete functionsfb1 andfb2, we say the two functions intersect in the interval [l1, l2] if fb1(l1) < fb2(l1) and fb1(l2) > fb2(l2), or vice versa. If fb1(l1) < fb2(l1) and [l1, l2] is an intersection interval, the insertion point is the minimum i such thatfb1(i) >fb2(i).

Define right(f ) = q if the right endpoint of f is in Vq. We shall show some properties which are crucial for our algorithm.

Lemma 4: For two edges f1 and f2in Ex, if right(f1) = right(f2), thenfb1 andfb2never intersect. Furthermore, by an O(n2)-time preprocessing, we can determine which of the two functions is the smaller in constant time.

Proof: Let f1 = (x, y1), f2 = (x, y2), and right(f1) = q. By (2), fb1(i) −fb1(i − 1) = fb2(i) −fb2(i − 1) for any p < i < q. That is, the difference betweenfb1 and fb2 is fixed in the domain, thus they never intersect.

By (1),

fb1(i) −fb2(i) = Ni(dT(y1, s2) − dT(y2, s2)) + n(w(x, y1) − w(x, y2))

+DT(y1, ¯Yi) − DT(y2, ¯Yi),

and

DT(y1, ¯Yi) − DT(y2, ¯Yi)

= (n − Ni− nq)(dT(rq, y1) − dT(rq, y2)) + DT(y1, Vq) − DT(y2, Vq).

In a preprocessing stage, we compute the following:

• dT(u, v) for any u, v ∈ V .

• For each vertex v, find i such that v ∈ Vi.

• ni= |Vi| and Ni= |V (Yi)| for each i.

• DT(v, Vi) for each i and each v ∈ Vi.

(10)

The preprocessing can be done in O(n2) time. After the preprocessing stage, we can computefb1(i) −fb2(i) in constant time and determine the smaller one.

Lemma 5: If f1, f2 ∈ Ex and right(f2) < right(f1), the difference (fb2(i) −fb1(i)) is monotonically increasing as i increases for any p ≤ i < right(f2).

Proof: Let right(f2) = q and right(f1) = j. For any p < i < q,

(fb2(i) −fb1(i)) − (fb2(i − 1) −fb1(i − 1))

= (fb2(i) −fb2(i − 1)) − (fb1(i) −fb1(i − 1))

= ni(dT(ri, rp) − dT(rp, s1) + dT(rq, s2) − dT(ri, rq))

−ni(dT(ri, rp) − dT(rp, s1) + dT(rj, s2) − dT(ri, rj))

= ni((dT(rq, s2) − dT(rj, s2)) + (dT(ri, rj) − dT(ri, rq)))

= ni(dT(rq, rj) + dT(rq, rj))

= 2nidT(rq, rj) ≥ 0.

It follows that (fb2(i) −fb1(i)) ≥ (fb2(i − 1) −fb1(i − 1)). That is, the difference is mono- tonically increasing as i increases.

By Lemma 4, for each q > p, at most one edge with right endpoint in Vq needs to be considered, and all the other edges in Ex can be eliminated. Let Ex0 = {fi|1 ≤ i ≤ h} be the set of edges that should be taken into consideration, in which right(fi) > right(fi+1) for each i. Starting at Fb1 =fb1, our algorithm iteratively computes Fbi = min{Fbi−1,fbi} for i from 2 to h, and by definition Fx=Fbh.

Let p = α0 < α1 < . . . < αt ≤ k. We denote the piecewise function Fbi by St

j=1j,fbg(j)), in which g(j) ≤ i andFbi(λ) =fbg(j)(λ) for each j and any λ ∈ [αj−1+ 1..αj]. We say that [αj−1+ 1..αj] is the j-th interval ofFbi.

(11)

Lemma 6: For any i, the function fbi intersects Fbi−1 at most once. If they intersect,fbi must appear at the first interval ofFbi.

Proof: By definition, Fbi−1 = minj<ifbj, and right(fi) < right(fj) for any j < i. By Lemma 5, the difference (fbi(λ) −fbj(λ)) is monotonically increasing as λ increases. That is, iffbi(λ) >Fbi−1(λ) for some λ, we can conclude that fbi0) >Fbi−10) for any λ0 > λ, and the result follows.

Based on Lemma 6, the merging algorithm for computing Fbi is designed as follows.

For convenience, letf (λ) = ∞ for any λ ≥ right(f ).b

Algorithm Merge(Fbi−1,fbi)

Input: An edge fi = (x, y) and a piecewise function Fbi−1=Stj=1j,fbg(j)) stored in a link list L.

Output: Fbi stored in L.

1: if Fbi−1(p) ≤ fi(p)

2: return; /* no intersection */

3: Scan L from the head so as to find the smallest αj such that Fbi−1j) < fij);

4: Use binary search to find the intersection point λ in [αj−1, αj];

5: Remove all intervals before the j-th interval from L;

6: Break the j-th interval by inserting (λ − 1,fbi) at the head of L;

7: return L.

The algorithm for computing the swap costs for all edges in the path is as follows.

(12)

Algorithm Two SERT P

Input: A graph G = (V, E, w), a spanning tree T and two source vertices s1 and s2. Assume that G is stored in an adjacency list;

Output: χ(T, e) for each e in the path between the two sources;

1: Compute the following:

1.1: the path P = (r0, r1, . . . , rk) between s1 and s2; 1.2: dT(u, v) for any u, v ∈ V ;

1.3: for each vertex v do find i such that v ∈ Vi; 1.4: ni= |Vi| and Ni= |V (Yi)| for each i;

1.5: DT(v, Vi) for each i and each v ∈ Vi;

1.6: DT(v, Yi) and DT(v, ¯Yi) for each vertex v and each i;

2: for each vertex x do

3: Find Ex by scanning the adjacency list;

4: Sort the edges f in Ex such that right(f ) are in a non-increasing order;

5: Construct E0x= {fi|1 ≤ i ≤ h} by eliminating the useless edges as described in Lemma 4;

6: Fb1 ←fb1; and create a link list L with one element (right(f1),fb1);

7: for i ← 2 to h do

Fbi← Merge(Fbi−1,fbi);

8: Compute Fx(i) for each ei in P ; 9: for each ei in P

Find χ(T, ei) = minxFx(i);

Lemma 7: In algorithm Two SERT P, Step 1 can be done in O(n2) time.

Proof: It is obvious that Step 1.1 can be done in linear time. As shown in Lemma 4,

(13)

Steps 1.2–1.5 takes O(n2) time. Now let’s calculate the time complexity of Step 1.6 as follows. Observe that DT(v, Y0) = n0dT(v, r0) + DT(r0, V0) and that DT(v, Yi) = DT(v, Yi−1) + nidT(v, ri) + DT(ri, Vi) for i > 0. Since all the required values are available before this step, DT(v, Yi) for all i can be done in O(n) time. Similarly, the distances DT(v, ¯Yi) for all i can also be found by an incremental method. Therefore, the total time complexity for Step 1 is O(n2).

The next result is straightforward by (1).

Lemma 8: After Step 1, the value δ(f, i) for any edge f and any i can be computed in constant time.

Lemma 9: The time complexity of algorithm Two SERT P is O(m log n + n2) time.

Proof: First, by Lemma 7, Step 1 can be completed in O(n2) time. Let’s analyze the time for the loop in Steps 2–8. Step 3 takes the linear time O(|Ex|), and the sorting at Step 4 can be completed in O(|Ex| log |Ex|) time. By Lemma 4, Step 5 can be also done in O(|Ex|) time. Step 6 takes only constant time. By Lemma 8, Step 8 takes O(n) time.

To analyze the time complexity of Step 7, we consider the Merge algorithm first.

In Merge, we check the intervals one by one until we find the intersecting interval.

Once the interval is found, a binary search is employed to find the intersecting point.

Obviously, the binary search needs at most O(log n) comparisons between the values of two functions. Since, by Lemma 8, the function values can be found in constant time, the binary search takes O(log n) time. To show the time complexity of Steps 3 and 5 in Merge, we use an amortized analysis. Let Li denote the number of intervals of Fbi and βi denote the number of intervals checked while mergingfbi. We have that

Li = Li−1− βi+ 2.

(14)

Summing up for i from 2 to h, we obtain

Lh = L1X

i

βi+ 2(h − 1).

Since Lh≥ 1 and L1 = 1, X

i

βi = L1+ 2(h − 1) − Lh≤ 2h − 2.

That is, the total number of checked intervals is O(|Ex0|). Since checking for an interval takes only constant time by Lemma 8, the total time complexity of Step 7 in Algorithm Two SERT P is O(|Ex0| log n).

In summary, the time complexity of the whole loop for each x is O(|Ex| log |Ex|).

SincePx∈V |Ex| = m, summing up for all vertices, the total time complexity of the loop is O(m log n). Finally, since Step 9 can be easily done in O(n2) time, we conclude that the total time complexity of the algorithm is O(m log n + n2).

The next theorem summarizes the result in this section, which directly follows Lem- mas 3 and 9.

Theorem 10: The two-sources SERT problem can be solved in O(m log n + n2) time.

4 Multiple-sources case

In this section, we consider the case where there are more than two sources. By def- inition, the routing cost of a tree T with source set S can be calculated by c(T, S) = P

s∈SDT(s, V (T )). Since there is no limit on the number of sources, a direct method for computing the routing cost of a tree will take O(n2) time even when the all-to-all distances are already known. For each edge e in E(T ), if we compute c(Te/f, S) for every f in the cut set, the time complexity for finding the swap cost χ(T, e) will be up to

(15)

O(mn2), and consequently it takes O(mn3) to find the swap costs for all edges in T . We shall present an O(mn) time algorithm for the SERT problem with multiple sources.

First we introduce a new formula for computing the routing cost of a tree. Let e = (u1, u2) ∈ E(T ). As mentioned previously, removing e from T will result in two subtrees. Let T1 and T2 be the two subtrees, in which u1 ∈ V (T1). Let Vi = V (Ti) and Ei = E(Ti) for i = 1, 2. Let S1 and S2 denote the sets of sources in V1 and V2, respectively.

Apparently, there are |S1| × |V2| paths from a source in S1 to a vertex in V2. Similarly the number of paths from a source in S2 to a vertex in V1 is |S2| × |V1|. By defining the routing load l(T, e) = |S1| × |V2| + |S2| × |V1|, we have the following formula.

c(T, S) = X

e∈E(T )

l(T, e)w(e). (3)

The routing cost of an edge e is defined by l(T, e)w(e). The above property shows that the routing cost of T can be calculated by summing up the routing costs of all the tree edges. Based on (3), we can compute the routing cost of a tree in O(n) time when the routing costs of all edges are available. All we need to know is the routing load of each edge. By rooting T at an arbitrary vertex and traversing the tree in post-order, we can easily compute the numbers of sources and the numbers of vertices in both sides of every edge. Thus, the routing loads of all edges can be obtained in O(n) time.

To solve the multiple-sources SERT problem, our algorithm finds the swap cost of each edge individually. For each edge e, we calculate the routing cost of Te/f for each edge f crossing the cut. We shall show that, after a preprocessing stage, the routing cost of Te/f can be computed in constant time.

For any edge f ∈ C(e), by (3), we have

c(Te/f, S) = X

e0∈E1

l(Te/f, e0)w(e0) + l(Te/f, f )w(f ) + X

e0∈E2

l(Te/f, e0)w(e0), (4)

(16)

















Figure 3: Yv is the subtree of Y rooted at a vertex v.

in which l(Te/f, f ) = l(T, e) since e and f are crossing the same cut.

To reduce the computation time, one difficulty is that the routing load of an edge p in a tree Te/f is not fixed but depends on f . The following simple observation is crucial for our algorithm. For each edge e0 ∈ E(T ) − {e}, there are only two possible values of l(Te/f, e0) for all f ∈ C(e), depending on which side of e0 the swap edge f is connected to.

In the following, we shall give a procedure for computing function γ1(e, v) for each v ∈ V1, which is defined to be the total routing cost of all edges in E1 subject to that the swap edge f is connected to v. By a similar procedure, we can compute function γ2(e, v), which is defined to be the total routing cost of all edges in E2 subject to that the swap edge f is connected to v. Once the two functions are completed, the routing cost of Te/f for any f can be calculated in constant time.

Let Y be the tree obtained by rooting T1 at u1. By Yv, we denote the subtree of Y rooted at a vertex v. For an edge (u, v) ∈ E(Y ), we assume that u is the parent of v in Y , as shown in Figure 3.

Let nv and sv denote the numbers of vertices and sources, respectively, in the subtree

(17)

Yv. For any e0 = (u, v) ∈ E(Y ), define

¯l1(e0) = (sv(n − nv) + (|S| − sv)nv)w(e0), (5)

which is the routing cost of e0 if the swap edge is connected to any vertex not in V (Yv).

Similarly, define

¯l2(e0) = ((sv+ |S2|)(|V1| − nv) + (|S1| − sv)(nv+ |V2|))w(e0), (6)

which is the routing cost of e0 if the swap edge is connected to any vertex in V (Yv).

Then, by definition, the value γ1(e, v) can be calculated by

γ1(e, v) = X

e0∈P/

¯l1(e0) + X

e0∈P

¯l2(e0),

in which P is the path between v and the root u1. Clearly, for the root u1,

γ1(e, u1) = X

e0∈E(Y )

¯l1(e0), (7)

and, for any child v of a vertex u,

γ1(e, v) = γ1(e, u) − ¯l1(u, v) + ¯l2(u, v). (8)

By (7) and (8), we can compute γ1(e, v) for all vertices v in Y by traversing Y twice: a post-order traversal for computing γ1(e, u1), and then a preorder traversal for computing γ1(e, v) from the value of its parent for every other vertex v. The whole algorithm is as follows.

Algorithm Multiple SERT

Input: A graph G = (V, E, w) and a spanning tree T and the source vertex set S.

Output: χ(T, e) for each e ∈ E(T ).

1: for each tree edge e = (u1, u2) do

(18)

2: Find the two subtrees T1 and T2; 3: Construct Y by rooting T1 at u1;

4: Traverse Y in a post-order to find sv and nv for each v;

5: Compute ¯l1(e0) for each e0 ∈ E(Y ) by (5);

6: Compute ¯l2(e0) for each e0 ∈ E(Y ) by (6);

7: Compute γ1(e, u1) =Pe0∈E(Y )¯l1(e0) by traversing Y in a post-order;

8: Traverse Y in a preorder to find γ1(e, v) by (8) for each v ∈ V1− {u1};

9: Use the steps similar to Steps 3–8 to find γ2(e, v) for each v ∈ V2; 10: for each f = (x, y) ∈ C(e) do

c(Te/f) ← γ1(e, x) + l(T, e)w(f ) + γ2(e, y) 11: Find χ(T, e) = minfc(Te/f).

Theorem 11: The multiple-sources SERT problem can be solved by Multiple SERT in O(mn) time.

Proof: The correctness follows directly from the above explanation. It remains to show the time complexity of Multiple SERT is O(mn). Clearly, Steps 2–9 can be done in O(n) time. The time complexity of Steps 10 and 11 is O(m). Since there are n − 1 edges in the tree, the total time complexity is O(mn).

5 Concluding Remarks

In this paper, we propose algorithms for finding the swap cost of every edge of a multiple- sources routing tree. Our algorithms take O(m log n + n2) and O(mn) time for the two- sources case and the multiple-sources case, respectively. It is easy to see that the swap edges have been implicitly found by the algorithms.

(19)

The algorithms developed in this paper can be easily extended to the case of weighted routing cost, in which we are given a nonnegative weight r(v) for each vertex v, and the routing cost of v is defined by r(v)DT(v, S). Note that it includes the case that not all vertices are destinations by setting zero weight to vertices which are not destinations.

The swap edge problem we defined in this paper is to minimize the total, or equiv- alently the average, length of every path from a source to a destination. We are also interested in the swap edge problem with respect to other criteria [4, 7]. Another inter- esting problem about survivability is to find the most vital edge of a shortest path or a minimum spanning tree [2, 5, 6].

Acknowledgements

We thank the reviewers for their helpful comments. Bang Ye Wu was supported in part by NSC grants 93-2213-E-366-001 and 93-2213-E-366-014, Taiwan. Chih-Yuan Hsiao and Kun-Mao Chao were supported in part by NSC grants 92-2213-E-002-059 and 93-2213- E-002-029, Taiwan.

References

[1] A. Di Salvo and G. Proietti, Swapping a failing edge of a shortest paths tree by minimizing the average stretch factor, (SIROCCO’04), LNCS 3104, 99–110, 2004.

[2] B. Dixon, M. Rauch, and R.E. Tarjan, Verification and sensitivity analysis of mini- mum spanning trees in linear time, SIAM Journal on Computing, 21(6), 1184–1192, 1992.

[3] M. Gr¨otschel, C.L. Monma, and M. Stoer, Design of survivable networks, Handbook in OR and MS, Vol.7, Elsevier, Amsterdam, 617–672, 1995.

(20)

[4] G. F. Italiano and R. Ramaswami, Maintaining spanning trees of small diameter, Algorithmica, 22(3), 275–304, 1998.

[5] K. Iwano and N. Katoh, Efficient algorithms for finding the most vital edge of a minimum spanning tree, Information Processing Letters, 48(5) , 211–213, 1993.

[6] E. Nardelli, G.Proietti, and P. Widmayer, A faster computation of the most vital edge of a shortest path, Information Processing Letters, 79(2), 81–85, 2001.

[7] E. Nardelli, G.Proietti, and P. Widmayer, Swapping a failing edge of a single source shortest paths tree is good and fast, Algorithmica, 35(1), 56–74, 2003.

[8] B.Y. Wu, A polynomial time approximation scheme for the two-source minimum routing cost spanning trees, Journal of Algorithms, 44, 359–378, 2002.

[9] B.Y. Wu, Approximation algorithms for the optimal p-source communication span- ning tree, Discrete Applied Mathematics, 143, 31–42, 2004.

[10] B.Y. Wu and K.-M. Chao, Spanning Trees and Optimization Problems, Chapman

& Hall / CRC Press, 2004.

[11] B.Y. Wu, K.-M. Chao, and C.Y. Tang, Approximation algorithms for some optimum communication spanning tree problems, Discrete Applied Mathematics, 102, 245–

266, 2000.

[12] B.Y. Wu, G. Lancia, V. Bafna, K.-M. Chao, R. Ravi and C.Y. Tang, A polynomial time approximation scheme for minimum routing cost spanning trees, SIAM Journal on Computing, 29, 761–778, 1999.

參考文獻

相關文件

When we know that a relation R is a partial order on a set A, we can eliminate the loops at the vertices of its digraph .Since R is also transitive , having the edges (1, 2) and (2,

Primal-dual approach for the mixed domination problem in trees Although we have presented Algorithm 3 for finding a minimum mixed dominating set in a tree, it is still desire to

(c) If the minimum energy required to ionize a hydrogen atom in the ground state is E, express the minimum momentum p of a photon for ionizing such a hydrogen atom in terms of E

Then, it is easy to see that there are 9 problems for which the iterative numbers of the algorithm using ψ α,θ,p in the case of θ = 1 and p = 3 are less than the one of the

Miroslav Fiedler, Praha, Algebraic connectivity of graphs, Czechoslovak Mathematical Journal 23 (98) 1973,

Given a connected graph G together with a coloring f from the edge set of G to a set of colors, where adjacent edges may be colored the same, a u-v path P in G is said to be a

The vertex-cover problem is to find a vertex cover of minimum size in a given undirected graph. • 此問題的decision版本為NP-Complete

If P6=NP, then for any constant ρ ≥ 1, there is no polynomial-time approximation algorithm with approximation ratio ρ for the general traveling-salesman problem...