0% found this document useful (0 votes)
99 views3 pages

A Note On T W o Problems in Connexion With Graphs

This document summarizes two algorithms for solving problems related to graphs: 1) Constructing a minimum spanning tree that connects all nodes with the fewest total branch lengths. The algorithm uses three sets (branches in the tree, available branches, rejected branches) and iteratively adds the shortest available branch. 2) Finding the shortest path between two given nodes P and Q. The algorithm uses three node sets and branch sets, and iteratively transfers the closest available node to the known path set until Q is reached. The algorithms require storing only a small number of branches simultaneously, improving on other existing solutions.

Uploaded by

Swapnilghorpade
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views3 pages

A Note On T W o Problems in Connexion With Graphs

This document summarizes two algorithms for solving problems related to graphs: 1) Constructing a minimum spanning tree that connects all nodes with the fewest total branch lengths. The algorithm uses three sets (branches in the tree, available branches, rejected branches) and iteratively adds the shortest available branch. 2) Finding the shortest path between two given nodes P and Q. The algorithm uses three node sets and branch sets, and iteratively transfers the closest available node to the known path set until Q is reached. The algorithms require storing only a small number of branches simultaneously, improving on other existing solutions.

Uploaded by

Swapnilghorpade
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Numerische Mathematik ~, 269--271 (1959)

A Note on T w o Problems in Connexion with Graphs


By

E. W. DIJKSTRA
We consider n points (nodes), some or all pairs of which are connected by a branch; the length of each b r a n c h is given. We restrict ourselves to the case where at least one p a t h exists between any two nodes. We now consider two problems.

Problem 1. Constrnct the tree of minimum total length between the n nodes. (A tree is a graph with one and only one path between every two nodes.) In the course of the construction that we present here, the branches are subdivided into three sets: I. the branches definitely assignec~ to the tree under construction (they will form a subtree) ; II. the branches from which the next branch to be added to set I, will be selected ; I I I . the remaining branches (rejected or not yet considered).
The nodes are subdivided into two sets: A. the nodes connected b y the branches of set I, B. the remaining nodes (one and only one branch of set of these nodes), We start the construction b y choosing an arbitrary node of set A, and b y placing all branches t h a t end in this node with, set I is empty. From then onwards we perform the repeatedly.

I I will lead to each as the only member in set II. To start following two steps

Step 1. The shortest branch of set I I is removed from this set and added to set I. As a result one node is transferred from set B to set A. Step 2. Consider the branches leading from the node, t h a t has just been transferred to set A, to the nodes t h a t are still in set B. If the b r a n c h under consideration is longer than the corresponding branch in set I I , it is rejected; it it is shorter, it reptaces the corresponding branch in set I i , and the latter is rejected.
We then return to step I and repeat the process until sets I I and ]3 are empty. The branches in set I form the tree required. The solution given here is to be preferred to the solution given b y J . B . KRUSKAL [1] and those given b y H. LOBERMAN and A. WEINBERGER [2]. In their solutions all the -- possibly 89 -- branches are first of all sorted according to length. Even if the length of the branches is a computable function of the node coordinates, their methods demand that d a t a for all branches are stored simultaneously. Our m e t h o d only requires the simultaneous storing of
Numbs. N a t h . B d . 4. i9

270

E . W . DIJKSTRA:

the d a t a for a t most n branches, viz. the branches in sets I a n d I I a n d the branch u n d e r consideration in step 2. P r o b l e m 2. F i n d the p a t h of m i n i m u m t o t a l l e n g t h between two given nodes P a n d Q. W e use the fact t h a t , if R is a node on the m i n i m a l p a t h from P to Q, knowledge of t h e l a t t e r implies t h e knowledge of the m i n i m a l p a t h from P to R. I n t h e solution presented, the m i n i m a l p a t h s from P to the o t h e r nodes are c o n s t r u c t e d in order of increasing length u n t i l Q is reached. I n the course of the solution the nodes are s u b d i v i d e d into three sets: A. the nodes for which the p a t h of m i n i m u m length from P is k n o w n ; nodes will be a d d e d to this set in order of increasing m i n i m u m p a t h length from node P ; B. the nodes from which the n e x t node to be a d d e d to set A will be selected; this set comprises all those nodes t h a t are c o n n e c t e d to at least one node of set A b u t do not y e t belong to A themselves; C. the r e m a i n i n g nodes. The branches are also s u b d i v i d e d into three sets: I. the b r a n c h e s occurring in the m i n i m a l p a t h s from node P to the nodes in set A ; I I . the b r a n c h e s from which the n e x t b r a n c h to be placed in set I will be selected; one a n d o n l y one b r a n c h of this set will l e a d to each node in set B ; I I I . the r e m a i n i n g b r a n c h e s (rejected or not y e t considered). To s t a r t with, all nodes are in set C a n d all b r a n c h e s are in set I I I . W e now t r a n s f e r node P to set A a n d from then o n w a r d s r e p e a t e d l y perform the following steps.

Step 1. Consider all branches r connecting the node just t r a n s f e r r e d to set A w i t h nodes R in sets B or C. If node R belongs to set B, we i n v e s t i g a t e w h e t h e r t h e use of b r a n c h r gives rise to a s h o r t e r p a t h from P to R t h a n the known p a t h t h a t uses the corresponding b r a n c h in set I I . If this is not so, b r a n c h r is r e j e c t e d ; if, however, use of b r a n c h r results in a shorter connexion between P a n d R t h a n h i t h e r t o obtained, it replaces the corresponding b r a n c h in set I I a n d the l a t t e r is rejected. If the node R belongs to set C, it is a d d e d to set B a n d b r a n c h r is a d d e d to set I I . Step 2. E v e r y node in set B can be connected to node P in only one w a y if we restrict ourselves to b r a n c h e s from set I and one from set I I . In this sense each node in set B has a distance from node P : the node w i t h m i n i m u m distance from P is t r a n s f e r r e d from set B to set A, a n d the corresponding b r a n c h is t r a n s ferred from set I I to set I. W e t h e n r e t u r n to s t e p t a n d r e p e a t the process u n t i l node Q is t r a n s f e r r e d to set A. T h e n the solution has been found.
R e m a r k 1. The a b o v e process can also be a p p l i e d in the case where the length of a branch depends on the direction in which it is traversed. R e m a r k 2. F o r each b r a n c h in sets I a n d I I it is a d v i s a b l e to record its two nodes (in order of increasing d i s t a n c e from P), a n d the d i s t a n c e b e t w e e n P a n d t h a t node of the b r a n c h t h a t is furthest from P . F o r the b r a n c h e s of set I t h i s

Two Problems in Connexion with Graphs

27t

is the a c t u a l m i n i m u m distance, for the branches of set I I it is only the m i n i m u m t h u s far obtained. The solution given a b o v e is to be preferred to the solution b y L. R. FORD [3J as described b y C. BERGE [4~, for, irrespective of the n u m b e r of branches, we need not store the d a t a for all branches s i m u l t a n e o u s l y b u t only those for the b r a n c h e s in sets I a n d I I , a n d this n u m b e r is always less t h a n n. F u r t h e r m o r e , t h e a m o u n t of work to be done seems to be considerably less. References [1] KRUSKAL jr., J . B . : On the Shortest Spanning Subtree of a Graph and the Travelling Salesman Problem. Proc. Amer. Math. Soc. 7, 48--50 (1956). E21 LOBERMAN, H., and A. WEINBERGER: Formal Procedures for Connecting Terminals with a Minimum Total Wire Length. J. Ass. Comp. Mach. 4, 428--437 (1957). [8] FORD, L. R.: Network flow theory. Rand Corp. Paper, P-923, t956. [4] B~RoE, C. : Th~orie des graphes et ses applications, pp. 68-- 69. Paris : Dunod 1958. Mathematisch Centrum 2e Boerhaavestraat 49 Amsterdam-O

(Received June 11, 19.59)

19"

You might also like