graph.spad line 4817 [edit on github]
allows us to model weighted graphs This graph assigns a weight to each arrow. This is used when calculating say, lowest 'cost' routes. An arrow with a higher weight is more 'costly' in some way and therefore we try to choose the minimum weight. For arrows in series the overall weight is the sum of the individual weights. For arrows in parallel the overall weight is the minimum of the individual weights. I
may change this in future to allow different cost metrics to be plugged in.
tensor product : the tensor product G*H
of graphs G
and H
is a graph such that the vertex set of G*H
is the Cartesian product V
(G
) times V
(H
); and any two vertices (u
, u') and (v
, v'
) are adjacent in G
times H
if and only if u' is adjacent with v'
and u
is adjacent with v
.
addWArrow!(s, name, n1, n2, w)
adds a weighted arrow to the graph s
, where name
is name
of the arrow, w
is weight of the arrow, n1
is starting point of the arrow, n2
is endpoint of the arrow.
Cartesian product: the vertex set of G
o
H
is the Cartesian product V
(G
) times V
(H
) and any two vertices (u
, u') and (v
, v'
) are adjacent in G
o
H
if and only if either u
= v
and u' is adjacent with v'
in H
, or u' = v'
and u
is adjacent with v
in G
.
as Cartesian product but returns %.
as tensor product but returns %.
coerce FinitePoset
to graph
the shortest distance between 'a' and 'b'
in terms of weight.
the cumulative weight of a given route. The route is given in terms of a sequence of arrow indexes.
the cumulative weight of a given route. The route is given in terms of a sequence of node indexes.
The elements of the returned array will represent the distance weights between vertices. if there is no connection between the vertices then the element will be set to "disjoint"
weightedGraph(poset)
constructs graph from a partially ordered set. This will be a graph with, at most, one arrow between any two nodes.
constructor for graph with given list of object names. Use this version of the constructor if you don't
intend to create diagrams and therefore don't
care about x
, y
coordinates. more objects and arrows can be added later if required.
constructor for graph with given objects and adjacency matrix.
weightedGraph(obs, ars)
constructs graph with objects obs
and arrows ars. This constructor just has pure abstract graph information without decoration information.
constructor for graph with given objects and arrows more objects and arrows can be added later if required.
constructor for graph with given objects more objects and arrows can be added later if required.
weightedGraph(ob, ar)
constructs graph with objects on and arrows ar. More objects and arrows can be added later if required.
FiniteGraph(S)