INTERFACEThis interface defines procedures for computing all the shortest paths in aASP ;
Graph.T
.
IMPORT Graph; TYPE Unweighted <: UnweightedPub; UnweightedPub = ROOT BRANDED OBJECT METHODS dist(READONLY from, to: CARDINAL): INTEGER; END; Weighted <: WeightedPub; WeightedPub = ROOT BRANDED OBJECT METHODS dist(READONLY from, to: CARDINAL): REAL; END;The methods have the following specifications:
If uw: Unweighted
, then dist(from, to)
returns the length of the
shortest path from the node with index from
to the node with index to
if there is such a path, and -1
otherwise. The length of a path is the
number of edges along that path, independent of their weights. The dist
method takes O(1) time.
If w: Weighted
, then dist(from, to)
returns the weight of the minimum
weight path from the node with index from
to the node with index to
if
there is such a path, and IEEE.Infinity
otherwise. The weight of a path
is the sum of the weights along it. The dist
method takes O(1) time.
PROCEDURE UnweightedFromGraph(g: Graph.Sparse): Unweighted;
Returns anUnweighted
object for determining the shortest path between any pair of nodes ing
.
PROCEDURE WeightedFromGraph(g: Graph.Sparse): Weighted;
Returns aWeighted
object for determining the minimum-weight path between any pair of nodes ing
.
END ASP.