Here, Spira’s algorithm(29) is described. In Spira’s algorithm, a priority queue is proposed to facilitate a few operations, such as finding and deleting the minimum key and updating key values. Spira also applied the same ideas as Dantzig. The edges from each vertex v ∈ V are sorted in non-decreasing order that takes O(n2log n) time for a complete n vertices graph. A
pointer is also maintained for the sorted list. A pointer P (v) always points to the current edge and it will be moved by one in update to get to the next edge.
Spira’s algorithm maintains the solution set, denoted by S, which is the set of vertices to which shortest paths have so far been established by the algorithm, in a priority queue Q. The key for u in the queue, key(u), is given by key(u) = d[u] + c(u, ce(u)), where d[u] is the known shortest distance from the source to u.
Compared to Dantzig’s, Spira’s allows a candidate of u ∈ S to be in S, which is a non-clean candidate. To expand S, this algorithm works similarly to Dantzig’s but does not require u to be updated with the new unlabelled candidate.
The queue is initialized with one element of s, the source. Let key(s) = c(s, t), where edge(s, t) is the shortest edge from s. Obviously t is included in the solution set as the second member. In general, suppose u is the minimum of the queue, that is, key(u) is minimum in the queue. If v = ce(u) is not in S, it can be included in S with d[v] = key(u), and then included in Q with key(v) = d[v] + c(v, w), where (v, w) is the shortest edge from v.
Regardless of whether the above v is in S or not, the pointer on the edge list from u is advanced to the next element because edge (u, v) is no longer useful, which means that this edge is not going to be examined for other shortest paths.
The priority queue Q needs to support find-min, increase-key and insert operations ef- ficiently, which is expressed by the repertory (find-min, increase-key, insert ). Spira used a tournament tree for a priority queue in his algorithm, which supports the first operation in O(1) time and the last two operations in O(log n) time. In this thesis, a more common data structure is used, ordinary binary heap, which supports the same set of operations with the same time complexity. All pointers for edge lists are initialized to 0. To point to the first member in the edge list, P [v] = 1. The sorted list of edges for each vertex starts from index 1. The algorithm for the single source problem follows.
4.3 Simple Scanning by One
Algorithm 6 Spira’s algorithm to solve SSSP problem
1: procedure Single source(n) 2: for v ∈ V do d[v] = ∞;
3: ce(s) = next of ce(s); t = ce(s) ; . t is the first candidate of s
4: d[s] = 0 ; F = {s} ; d[t] = c(s, t);
5: organise F in a priority with key(s) = c(s, t);
6: S = ∅;
7: while |S| < n do
8: find u in F with minimum key;
9: v = ce(u); 10: if v /∈ S then 11: S = S ∪ {v}; 12: spira update(v); 13: spira update(u); 14: end
15: procedure spira update(v)
16: ce(v) = next of ce(v), . scanning effort
17: w = ce(v);
18: d[w] = min {d[w], d[v] + c(v, w)};
19: key(v) = d[v] + c(v, w); 20: if v is in a heap then
21: increase-key(v); . increase-key v with key(v)
22: else
23: insert(v); F = F ∪ {v}; . insert(v)
24: reorganize F into the heap with new key(v);
j
size = n - j
v
u
u
u
v’
S
u
size = j
v’
v’
v’
v’
Figure 4.3: Some intermediate stage during the expansion of S in Spira’s algorithm
For the analysis, the endpoint independence model is used for the probabilistic assumption. In this model, when the edge list is scanned, any vertex appears independently with a probability of n1. When there are less than n edges, it is assumed that edges with costs of infinity, randomly and independently attached at the end of the list. This model was chosen as it is commonly used for the average case analysis.
Let U = (T1, . . . , Tn−1) be the times for expanding the solution set by one at each stage of
the size. Let EX be the expectation operator over the sample space of random variable(s) X.
Then, ignoring some overhead time between expansion processes, the expected value EU[T ] of
the total time T = T1, . . . , Tn−1
EU[T ] = EU[T1+ . . . + Tn−1] = EU[T1] + . . . + EU[Tn−1].
From the theorem of total expectation, EY[EX[X|Y ]] = EX,Y[X], where X|Y is the condi-
tional random variable of X conditioned by Y . In this analysis, X represents a particular Ti,
Y is for the rest and (X, Y ) for U . The fact that EX[X|Y ] is the same for all Y is used from
the endpoint independence. This idea enables us to localize analysis in each stage of expansion, and will be used in later sections for various analyses.
To analyze Spira’s, let Tj represent the expansion of the solution set, S from size j to j + 1
where |S| = j. At the j-th stage, the heap contains j candidates. The probability that v is outside S at line 10 is n−jn from the endpoint independence. The number of executions of find-min at line 8 is given by the reciprocal of this probability; that is, n−jn , which corresponds to the above EX[E[X|Y ]]. Note that EX[X|Y ] = EY[X|Y ] in this scenario, since n−jn does not