Hyperpaths and shortest hyperpaths

14
HYPERPATHS AND SHORTEST HYPERPATHS Sang Nguyen l Stefano Pallottino- ABSTRACT A generalization of the concept of a path in a directed graph, called a hyperpath, is the object of this paper. Fundamental properties of a path are generalized for a hyperpath. In particular, the shortest hyperpath problem is studied for a subclass of hyperpaths. Shortest hyperpath properties are derived from the classical one, and efficient algorithms are presented in detail. Sommario: L'oggetto di questo lavoro e una generalizzazione del concetto di cammino in un grafo orientato: l'ipercammino. Vengono presentate Ie pili importanti proprieta degli ipercammini come generalizzazione delle proprieta dei camrnini. In particolare viene studiato il problema della ricerca dell'ipercammino minimo. Vengono mostrate le proprieta relative e vengono descritti diversi algoritmi per la determinazione degli iper- cammini minirni, oltre che la loro complessita computazionale. Introduction In this paper we investigate a multipath concept on a directed graph - called a hyperpath. In broad terms, a hyperpath connecting two points is an acyclic graph with a single source and a single sink, paired with a given vector of real arc values. Such a concept plays a crucial role in transit networks with overlapping routes (see for example [6]). Following a brief recall of the classical properties of a path, we derive a definition of a hyperpath from a relaxation of the definition of a path, and examine the principal properties of a hyperpath. From this point on, we focus our attention on an important particular case where components of the hyperpath characteristic vector are defined locally in terms of arc attributes. The problem of determining shortest hyperpaths from every node to a specified destination node is then investigated. Potential efficient shortest hyperpath algorithms are developed and analysed. I Departement d'infonnatique et de recherche operationnelle, Universite de Montreal, Canada. 2 Istitato per Ie Applieazioni del Calcolo "Mauro Picone", Consiglio Nazionale delle Ricerche, Roma, Italy.

Transcript of Hyperpaths and shortest hyperpaths

HYPERPATHS ANDSHORTEST HYPERPATHS

Sang Nguyen l

Stefano Pallottino-

ABSTRACT

A generalization of the concept of a path in a directed graph, called a

hyperpath, is the object of this paper. Fundamental properties of a path are generalized

for a hyperpath. In particular, the shortest hyperpath problem is studied for a subclass

of hyperpaths. Shortest hyperpath properties are derived from the classical one, and

efficient algorithms are presented in detail.

Sommario: L'oggetto di questo lavoro euna generalizzazione del concetto di cammino

in un grafo orientato: l'ipercammino. Vengono presentate Ie pili importanti proprieta

degli ipercammini come generalizzazione delle proprieta dei camrnini. In particolare

viene studiato il problema della ricerca dell'ipercammino minimo. Vengono mostrate le

proprieta relative e vengono descritti diversi algoritmi per la determinazione degli iper­

cammini minirni, oltre che la loro complessita computazionale.

Introduction

In this paper we investigate a multipath concept on a directed graph ­ called a hyperpath. In broad

terms, a hyperpath connecting two points is an acyclic graph with a single source and a single sink,

paired with a given vector of real arc values. Such a concept plays a crucial role in transit networks with

overlapping routes (see for example [6]).

Following a brief recall of the classical properties of a path, we derive a definition of a hyperpath from a

relaxation of the definition of a path, and examine the principal properties of a hyperpath.

From this point on, we focus our attention on an important particular case where components of the

hyperpath characteristic vector are defined locally in terms of arc attributes. The problem of determining

shortest hyperpaths from every node to a specified destination node is then investigated. Potential

efficient shortest hyperpath algorithms are developed and analysed.

I Departement d'infonnatique et de recherche operationnelle, Universite de Montreal, Canada.

2 Istitato per Ie Applieazioni del Calcolo "Mauro Picone", Consiglio Nazionale delle Ricerche, Roma, Italy.

259

2. Path and hyperpath formulations

2.1 A path formulation

Consider an oriented graph G =(N, A). As usual a simple path p from node r to node s is a finite

sequence of distinct arcs of the form:

(1)

Path p is elementary if it does not traverse any node more than once. An elementary path p is com­

pletely described by a boolean arc­vector :i'=(xij) where xij=1, ifP traverses (iJ), and 0, otherwise.

If we express every component .xij as a product of two boolean variables it and 1tij:

xij=it1tij , V(iJ) e A,

then the node­vector Y' and the arc­vector 1tP must satisfy:

Yr' = 1

(2)

(3)

VieN­{r}

for i = r

Vi e N-{s}

for i = s

(4)

(5)

e {O,l} (6)

where BS(l) and FS(i) denote, the sets of arcs entering and leaving node i e N, respectively.

If a path arc­vector 1t is given, then a boolean node vector y(1t) can be determined dynamically from

equations (3) and (4) by a topological search on the graph starting at node r and ending at node s ,

Such vector y(1t) is called a derived node­vector. A boolean vector 1t= (1tij)' such that the pair

(y(1t), 1t) satisfies the system (3)­(6), completely specifies an elementary path p from r to s «r­s)path).

For this reason, such an arc­vector 1t will be called the characteristic vector of the defined path:

(7)

where

Np = {i e N Iit > OJ, Ap = {(iJ) e A l1tij > O}

2.2 Path relaxation: a hyperpath

In the previous section, we described a rather elaborate definition of an elementary path in a graph. This

allows us to formally present a hyperpath as a continuous relaxation of the boolean characteristic vector

1tp•

260

Consider replacing equations (5) and (6) by:

{I ,

L 1tij=(iiJEFS(.) 0,

if Yt> 0 Vi e N - {s}

otherwise (8)

(9)

Note that (9) leads to similar relaxation for the derived node-vector yP(1tP) and :J!'. We now have all

the ingredients to introduce formally the concept of hyperpath.

Definition 1. A subgraph Gh = (Nh, Ah) induced by the doublet (Y\1th) , 1th) satisfying (3)-(4) and (8)-

(9) is a hyperpath h connecting rand s.

Obviously an (r-s) path is also a hyperpath. It is straightforward to show that Gh has the following

characteristics:

1) Gh is acyclic*;

2) Gh admits a unique source r and a unique sink s: Ah (l BS(r) = Ah (l FS(s) = 0 ;

3) every node i e Nh, and every arc (iJ) e Ah, belong to at least one (r-s) path in Gh•

From a network flow point of view, xt, l may be interpreted as the arc and node flows resulting from

sending a single unit of flow from r to s, and 1tt is the proportion of the flow traversing node i on arc

(iJ). On the other hand, for probabilistic applications, given the subgraph Gh, 1tt may be interpreted as

the conditional probability of traversing arc (iJ) from node i:

1tt =Prob{ traversing (iJ) e Ah lie Nh } ,

and consequently y7 and xt are the probability of traversing node i and arc (iJ), respectively.

2.3 A multipath description

Let Ph be the set of all paths p connecting rand s in graph Gh. Let us introduce the following mul-

tipath characterisation of the (r--s) hyperpath (Gh, 1th) . For every elementary path p e Ph' define:

(10)

where 8ijp =1, if path p traverses arc (iJ), and 0, otherwise; 0° is defined as 1. Components of J'and i can now be derived from that of roh :

• A cycle is understood here as a closed path.

261

(11)

(12)

where Oip = 1, if P traverses node i, and 0, otherwise.

The path attribute may be interpreted either as the proportion of a unit flow on path p, or the proba­

bility of traversing path p.

Let XII C Nil such that node r e XII and s t XII' Let D(Xh) and I(Xh) denote, respectively, the sets of

arcs leaving and entering XII' Define

(13)

as the net flow out of set Xh, it is easy to show that:

Proposition 1.

2.4 The hyperpath cost

"«XJt> = L 0); =1,pEP.

(14)

It is now assumed that associated with every arc (iJ) e A are two real values aij and bij' where aij

represents the ordinary arc cost. For every node i, there is also a node traversing cost wf. which varies

among hyperpaths. Furthermore, it will be assumed that is given by a real valued function of vectors

band rr!'

(15)

such that any two hyperpaths h' and h" with identical arc­set Ah, n FS(i) =All" n FS(i) have equal

traversing costs at node i: wf' =wf. This also implies that w; =O. for any (r-s) hyperpath h.

The cost of a given hyperpath h is now defined as:

Note that if h is an elementary path, then (16) reduces to

Ch = L 0ij.(aij +(ii)£A

(16)

(17)

and from the assumption made on function g(b, 7th) , wf =g(bij) where j is the successor of i on path h.

Consequently, (17) has the traditional form:

262

Ch = '"£.J l) IJ(iJ)£A

For general hyperpaths, there is an alternate cost expression in terms of path costs:

Proposition 2.

where

is the cost incurred on (r-s) path p of Gi;

2.5 Concatenation of sub-hyperpaths

(18)

(19)

(20)

In the classical case, it is trivial to express a path p connecting rand s as a concatenation of two sub-

paths p'ri and p"is for any node i e p. And the additivity of the path costs holds:

(21)

This equality is frequently used in the derivation of a dynamic approach for computing the path cost.

For the hyperpath case, such a decomposition is less trivial.

Definition 2. A hyperpath h' is a sub-hyperpath of h if and only if

(22)

It is easy to prove the following.

Proposition 3. For every node i of h, there exists a unique sub-hyperpath connecting i and s.

This property permits the design of a dynamic approach for computing the hyperpath cost, and conse-

quently shortest hyperpaths. Let fh(i) denote the set of arcs leaving node i in hyperpath (Gh, 7th) . Let

h(j) be the unique sub-hyperpath connecting node j efh(r) and s, and ChU,s) its cost, then clearly:

Ch = L + arj + ChU,s)),(rJ)£!.(r)

= + L + ChU,s)).(rJ)£FS(r)

(23)

Applying the above formula to all sub-hyperpaths of h having node s as their sink, leads to the follow-

ing dynamic program:

263

(24)

Since Gh is acyclic, it will be easy to scan all nodes i e Nh in a topological order, starting from node s,

in computing the cost Ch(r,s) of hyperpath h.

3. Shortest hyperpaths

If the characteristic vector 7th is exogeneously defined for every hyperpath h connecting rand s, finding

a shortest hyperpath amounts to simply computing explicitly the cost of each hyperpath and choosing the

one with the smallest cost. On the other hand, when the characteristic vector of any hyperpath h is a

function of the arc attributes, then finding a shortest hyperpath is not a trivial task.

In the sequel, we will study the shortest hyperpath problem for a subclass of hyperpaths which has

important applications in the traffic assignment problem on transit networks.

Consider the subclass of hyperpaths with characteristic vectors 7th and node traversing costs defined as

follows:

and

otherwise(25)

where bij > 0 for every (iJ) E A.

tkf

= g(b, 7th) = I I I: bij

(iJ) efi'}(26)

One can readily check that these definitions satisfy conditions (4) and (5) and the assumptions made on

function g(b, It is further assumed that arc costs Qij O.

Since common arcs of sub-hyperpaths of a given hyperpath h have equal characteristic values, one can

rewrite the previously defined dynamic program (24) as:

(27)

which is a prelude to the program for computing minimum hyperpath costs.

264

Let C*(i, s) denote the cost of a shortest hyperpath connecting nodes

analysis, we can now establish the following:

Proposition 4 (generalized Bellman's equations).

and s. From the preceding

The shortest cost vector C* is the unique solution of the following system of equations:

C*(s, s) = 0 (28)

{

l+ I: bij(aij+C*u,s»}

C*( . ) . __(...;.'J) f'---'-i-= _I,S = mm ,

r,O"S(,) :E bij(ii)£ri

Vi e N-{s}.

The proof of the above generalized Bellman's equations ([1]) follows closely that for the standard case.

Let

B(r;) = :E bij(ii)£ri

(29)

where r i FS(i) is any subset of arcs with tail node i. Consider two hyperpaths his and h'is with

identical common sub-hyperpaths, such that A(i)::J fh'U), Let T, =fh(i) and r'i =fh{i), and C(i,s) and

C'(i,s) denote the cost of his and that of h'is respectively. For these hyperpaths, we can write equation

(27) as

B(ri)CU,s) =1 + :E bij\aij+ CU,s»(ii)£r,

and

B(r'i) C'(i,s) =1 + :E bij\aij + CU,s».(iJ)Ef",

Rewriting r; as r'j U (T, - r'j), it follows that

B(Q C(i,s) = B(r'i) C'(i,s) + :E bij (aij + CU,s»(iJ)£r,f"j

and finally

BWj)(C(i,s) - C'(i,s» :E bij(aij+ CU,s) - C'(i,s».(jJ)£r,f"i

From symmetry, the following equation also holds:

B(r'j)(C(i,s) - C'(i,s» :E biiaij + CU,s) - C(i,s».(iJ)£r,f"i

(30)

(31)

(32)

The above equations imply that the cost of hyperpath his is strictly less than that of h'is, only if the right

hand sides of both (31) and (32) are strictly negative. In particular,

265

Proposition S. If a single arc (iJ) is added to the set r'j to form T, = r'j u {(iJ)}, then one of the

following statements holds:

1) aij+ C(j,s) < C(i,s) < C'(i,s)

2) aij+ C(j,s) =C(i,s) =C'(i,s)

3) aij+ C(j,s) > C(i,s) > C'(i,s).

A direct implication of this property is the following crucial characterisation of the arc set fh.(i) FS(I)

of a shortest hyperpath h*is.

Proposition 6. Let fh.(i) FS(i) be the set of arcs leaving node i of a shortest hyperpath h*js, then:

C*(i,s) aij+ C*(j,s), V(iJ) efh.(i)

and

C*(i,s) $; aij+ C*(j,s), V(iJ) tfh.(l).

Recall that a directed tree, rooted at node s , is an oriented graph on which every node j s is con­

nected to the roots by a unique path. Similarly,

Definition 3. A hypertree rooted at s is an oriented graph, on which every node distinct from s is

connected to s by a unique hyperpath.

A shortest hypertree, rooted at s, is therefore a hypertree formed by shortest hyperpaths.

266

4. Shortest hypertree algorithms

We now have all the ingredients to state a general procedure for finding a shortest hypertree, in a finite

number of iterations, and then suggest several efficient implementations.

General shortest hypertree procedure

initialisation. Determine a hypertree Ts' rooted at s ; Let C(i,s) denote the cost of the unique hyper­

path his on Ts' and T, the set of arcs of T, with common tail node i.

general step. While there exists a node i such that

C(i,s) > C'(i,s)

where

{

I + .L bi}{aij + C(j,s»}

C'( ' ) . (IJ)£r,i.s = rrun -----:=;----- ,r,O'S(I) B(r'j)

update the cost C(i,s) and arc set r j according to:

C(i,s) = C'(i,s)

{

I + L bij.ai}+C(j,S»}. (iJ)£ri

ri=arg mm .r;cps(l) B(r'i)

4.1 A label­correcting algorithm

(33)

(34)

(35)

To avoid unnecessary operations at each iteration of the general step, all nodes i e N that may satisfy

condition (33) are collected in a candidate list Q. If no initial hypertree T, is available, the following

default setting may be used:

- Q=N - {s};

­ T, = 0, C(s,s) = 0 ;

­ T, ={(i,s)} , C(i,s) =ais+ _1_, V(i,s) s BS(s) ;bis

­ T, =0, C(i,s) = + 00, V(i,s) t BS(s) .

Whenever a candidate node j is selected and removed from list Q- operation QOUT ­ its arc­set r jand label C(j,s) are updated according to (35) and (34). Every node i, such that

267

aij + CU,s) < C(i,s) , (iJ) E BSU) (36)

is then inserted into Q, if it is not already there - operation QIN. The following algorithm for determ-

ing a shortest hypertree (SHT), stated in a high level Pascal-like language, implements the above ideas.

Procedure SHT(s):

begincomment: initialisation;C(s,s) := 0;Q := N-{s};for each i E N dobeginr j := 0 ;C(i,s) := + cc

end;for each (i,s) E BS(s) dobeginr, := Hi,s)};C(i,s) := ais + libis

end;comment: fetch node j e Q, and find optimal r j, CU,s);while Q:F- 0 dobeginQOUTU, Q);FIND(rj,FS(j),CJ);comment: scanning for potential candidates;for each (iJ) e BS(j) doif aij + CU,s) < C(i,s) then QIN(i,Q)

endend SHT;

The procedure FIND determines the optimal arc-set r j with respect to the current labels C(k,s),

(k,s) e FS(j) and updates CU,s). This task can be performed with an efficient algorithm, based on pro-

position 6, in O(mj log mj) time, where mj =IFS(j)j. This algorithm works as follows. First, sort the

arcs of the forward star: FS(;) = W,k) E A} in non-decreasing order of values [ajk+ C(k,s)], and then

insert one arc at a time into r j, until no further improvement can be obtained for CU,s).

Procedure FIND (rj, FS(j), C, J):begincomment: sort the arcs in FS(j) in non-decreasing order of ajk+ C(k,s);SORT (FS(;), a, C);CU,s) := ajk1+ C(kJ, s) + lIbjk,;rj := W, kJ)};B(rj) := bjk1;(X:= 2;comment: scan the sequence of sorted arcs ;while (X mj and CU,s) > ajle", + C(ka, s) do

begincomment: add arc U, ka ) to r j and update CU,s);r j := r j U W, ka)} ;

268

b""Cfj,s) := Cfj,s) - (Cfj,s) - ape - C(kft, s» _J- ;" B(rj )

a:=a+lend

end FIND;

FIND can be executed in O(mj log mj) time using a heap-sort. Note that determining the optimal arc-

set rj may also be formulated as a boolean hyperbolic program for which there is already a greedy solu-

tion algorithm (see for example [4]).

To evaluate the complexity of SHT, let us assume that nodes in Q are selected in lexicographic order.

After every complete node selection cycle, at least one node i E N has received a permanent minimum

label C(i,s). This follows directly from the absence of negative cycles in G and thus limits the max-

imum number of node selection cycles to n = INI.

In every node selection cycle, three distinct operations are performed:

i) the selection of nodes in lexicographic order, which requires O(n) operations,

ii) the determination of optimal arc-sets, which requires

O(I:mi log mi) S O(m log n) operations,i£.N

iii) the scanning of the arcs in backward star BS(I), i E N, which require O(m) operations.

Since QIN and QOUT have constant complexity, algorithm SHT runs in O(mn log n) time. In the

shortest path nomenclature, the above SHT algorithm is a label-correcting one. Note that for shortest

path problems, label-correcting algorithms run in O(mn) time, therefore, the extra work required by SHT

is entirely due to the sorting of the forward star arc-sets. However, for expository purposes, we have

chosen to describe a procedure for determining the optimal sets r i, i e N, which does not exploit the

ordering of arcs in the previous sets r i . It is possible, as suggested in [5], to design updating pro-

cedures which fully exploit this ordering of arcs, and obviate the complete sorting of the forward star

arc-sets.

4.2 A label-setting algorithm

Consider node i, with its current label C(i,s) and corresponding arc-set r i . From proposition 5, if there

is an arc (iJ) e FS(i) such that

aij + Cfj,s) < C(i,s),

then adding (iJ) to r i will produce an improved label C(i,s). The value (aij + Cfj,s» may be con-

(37)

269

sidered as an arc label, and thus suggests an arc-selection based algorithm, which produces a shortest

hypertree after at most m arc selections.

Consider the following selection rule. At each iteration, arc (iJ) with the lowest arc label (aU+ C(j,s»

among all unscanned arcs with head node j e Q is selected:

aU+ C(j,s) =min min {aq + C(i',s)}.!£Q (t"J}f:JJS(1l

This rule ensures that label C(j,s) has reached its minimum value; since

C(j,s) S; C(k,s) + ajk Y(j,k) t rj

(38)

Note that one can initialise the procedure with empty sets r j , i e N, and whenever (37) occurs, with arc

(iJ) selected according to (38), then arc (iJ) becomes a permanent member of arc-set rio

To implement the above selection rule efficiently, one must consider a pre-ordering of the arcs of every

backward star B8(/), i e N, in non-decreasing order of arc attributes aji' Such pre-ordering is based on

an idea suggested in [2] (see also [3], algorithm SPTI). With such pre-ordering of arcs, it suffices to

maintain, for every node j toQ, a pointer to the first unscanned arc (iJ) toBS(j) in the pre-ordering.

When node j is selected, its arc pointer is updated as long as an unscanned arc (iJ) remains, otherwise

j is removed from list Q.

The following algorithm, denoted DSHT (Dantzig shortest hypertree), implements these ideas.

Procedure DSHT(s):

begincomment: initialisation;PREORDER (N,BS);

for each i e N dobeginr j := 0 ;B(r;) := 0;C(i,s) := +00

end;

Q := {s};C(s,s) := 0;

while Q '* 0 dobegincomment: select (i.j) with minimum arc label;

QOUT (j, Q, (iJ);

comment: check Bellman's condition;

270

if C(i,s) C(j,s) + aij thencomment: label updating;

if r, 0 thenbegin

comment: inserting first arc;r j := {(iJ)} ;B(rj) := bij;C(i,s) := C(j,s) + ajj + l/bij

endelse

begincomment: updating r j and C(i,s);r, := r, U «o».B(r;) := B(rj) + bij;C(i,s) := C(i,s}-{C(i,s)-C(j,s)-aij)b;jB(rj ) ;QIN(i,Q)

endend

end DSHT;

Procedure PREORDER sons the arcs in every backward star set in non-decreasing order of arc attributes

aij in O(m log n) time. Procedure QOUT determines the minimum label arc (ij) and updates the arc

pointer of node j or removes j from Q. Finally, procedure QIN inserts node into Q and sets the

arc pointer of node i to the first arc in the pre-sorted backward star set BS(i).

If list Q is implemented as an n-elements binary heap, then QOUT and QIN run in O(log n) time.

Since at most m arc selections are required, the complexity of DSHT is O(m log n), which is equal to

that of a binary heap algorithm for shortest path calculations.

Conclusion

This paper investigates a multipath concept on a directed graph, called here a hyperpath. It shows that

the principal properties of paths can be retrieved for hyperpaths. In particular, efficient shortest hyper-

path algorithms can be designed from the theory developped for shortest paths. It is believed that the

hyperpath concept may advantageously replace the standard path concept in many applications.

271

References

[1] R. Bellmann, "On a routing problem", Quaterly of Applied Mathematics 16 (1958) 87-90.

[2] G.B. Dantzig, Linear programming and extensions (Princeton University Press, Princeton, NJ,1963).

[3] G. Gallo and S. Pallottino, "Shortest path methods: a unifying approach", Mathematical Program­ming Study 26 (1986) 38-64.

[4] P.L. Hammer and S. Rudeanu, Boolean Methods in Operations Research (Springer-Verlag, NY,1968).

[5] S. Nguyen and S. Pallottino, "Assegnamento dei passeggeri ad un sistema di linee urbane: deter-minazione degli ipercamini minimi", Quaderno lAC 6, 1985.

[6] S. Nguyen and S. Pallottino, "Equilibrium traffic assignment for large scale transit networks",Quaderno lAC 14, 1985.