WeightedGraph(S, W)¶
graph.spad line 4851 [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.
- *: (%, %) -> WeightedGraph(Product(S, S), W)
tensor product : the tensor product
G*Hof graphsGandHis a graph such that the vertex set ofG*His the Cartesian productV(G) timesV(H); and any two vertices (u, u’) and (v,v') are adjacent inGtimesHif and only if u’ is adjacent withv'anduis adjacent withv.
- +: (%, %) -> %
from FiniteGraph S
- addArrow!: (%, Record(name: String, arrType: NonNegativeInteger, fromOb: NonNegativeInteger, toOb: NonNegativeInteger, xOffset: Integer, yOffset: Integer, map: List NonNegativeInteger)) -> %
from FiniteGraph S
- addArrow!: (%, String, NonNegativeInteger, NonNegativeInteger) -> %
from FiniteGraph S
- addArrow!: (%, String, NonNegativeInteger, NonNegativeInteger, List NonNegativeInteger) -> %
from FiniteGraph S
- addArrow!: (%, String, S, S) -> %
from FiniteGraph S
- addObject!: (%, Record(value: S, posX: NonNegativeInteger, posY: NonNegativeInteger)) -> %
from FiniteGraph S
- addObject!: (%, S) -> %
from FiniteGraph S
- addWArrow!: (%, String, NonNegativeInteger, NonNegativeInteger, W) -> %
addWArrow!(s, name, n1, n2, w)adds a weighted arrow to the graphs, wherenameisnameof the arrow,wis weight of the arrow,n1is starting point of the arrow,n2is endpoint of the arrow.
- adjacencyMatrix: % -> Matrix NonNegativeInteger
from FiniteGraph S
- arrowName: (%, NonNegativeInteger, NonNegativeInteger) -> String
from FiniteGraph S
- arrowsFromArrow: (%, NonNegativeInteger) -> List NonNegativeInteger
from FiniteGraph S
- arrowsFromNode: (%, NonNegativeInteger) -> List NonNegativeInteger
from FiniteGraph S
- arrowsToArrow: (%, NonNegativeInteger) -> List NonNegativeInteger
from FiniteGraph S
- arrowsToNode: (%, NonNegativeInteger) -> List NonNegativeInteger
from FiniteGraph S
- cartesian: (%, %) -> WeightedGraph(Product(S, S), W)
Cartesian product: the vertex set of
GoHis the Cartesian productV(G) timesV(H) and any two vertices (u, u’) and (v,v') are adjacent inGoHif and only if eitheru=vand u’ is adjacent withv'inH, or u’ =v'anduis adjacent withvinG.
- closedCartesian: (%, %, (S, S) -> S) -> %
as Cartesian product but returns %.
- closedTensor: (%, %, (S, S) -> S) -> %
as tensor product but returns %.
- coerce: % -> OutputForm
from CoercibleTo OutputForm
- coerce: FinitePoset S -> %
coerce FinitePosetto graph
- cycleClosed: (List S, String) -> %
from FiniteGraph S
- cycleOpen: (List S, String) -> %
from FiniteGraph S
- deepDiagramSvg: (String, %, Boolean) -> Void
from FiniteGraph S
- diagramHeight: % -> NonNegativeInteger
from FiniteGraph S
- diagramsSvg: (String, List %, Boolean) -> Void
from FiniteGraph S
- diagramSvg: (String, %, Boolean) -> Void
from FiniteGraph S
- diagramWidth: % -> NonNegativeInteger
from FiniteGraph S
- distance: (%, NonNegativeInteger, NonNegativeInteger) -> Integer
from FiniteGraph S
- distanceMatrix: % -> Matrix Integer
from FiniteGraph S
- distanceWeighted: (%, NonNegativeInteger, NonNegativeInteger) -> Union(W, disjoint)
the shortest distance between ‘a’ and
'b'in terms of weight.
- flatten: DirectedGraph % -> %
from FiniteGraph S
- getArrowIndex: (%, NonNegativeInteger, NonNegativeInteger) -> NonNegativeInteger
from FiniteGraph S
- getArrows: % -> List Record(name: String, arrType: NonNegativeInteger, fromOb: NonNegativeInteger, toOb: NonNegativeInteger, xOffset: Integer, yOffset: Integer, map: List NonNegativeInteger)
from FiniteGraph S
- getVertexIndex: (%, S) -> NonNegativeInteger
from FiniteGraph S
- getVertices: % -> List Record(value: S, posX: NonNegativeInteger, posY: NonNegativeInteger)
from FiniteGraph S
- incidenceMatrix: % -> Matrix Integer
from FiniteGraph S
- inDegree: (%, NonNegativeInteger) -> NonNegativeInteger
from FiniteGraph S
- initial: () -> %
from FiniteGraph S
- isAcyclic?: % -> Boolean
from FiniteGraph S
- isDirected?: () -> Boolean
from FiniteGraph S
- isDirectSuccessor?: (%, NonNegativeInteger, NonNegativeInteger) -> Boolean
from FiniteGraph S
- isFixPoint?: (%, NonNegativeInteger) -> Boolean
from FiniteGraph S
- isFunctional?: % -> Boolean
from FiniteGraph S
- isGreaterThan?: (%, NonNegativeInteger, NonNegativeInteger) -> Boolean
from FiniteGraph S
- kgraph: (List S, String) -> %
from FiniteGraph S
- laplacianMatrix: % -> Matrix Integer
from FiniteGraph S
- latex: % -> String
from SetCategory
- loopsArrows: % -> List Loop
from FiniteGraph S
- loopsAtNode: (%, NonNegativeInteger) -> List Loop
from FiniteGraph S
- loopsNodes: % -> List Loop
from FiniteGraph S
- looseEquals: (%, %) -> Boolean
from FiniteGraph S
- map: (%, List NonNegativeInteger, List S, Integer, Integer) -> %
from FiniteGraph S
- mapContra: (%, List NonNegativeInteger, List S, Integer, Integer) -> %
from FiniteGraph S
- max: % -> NonNegativeInteger
from FiniteGraph S
- max: (%, List NonNegativeInteger) -> NonNegativeInteger
from FiniteGraph S
- merge: (%, %) -> %
from FiniteGraph S
- min: % -> NonNegativeInteger
from FiniteGraph S
- min: (%, List NonNegativeInteger) -> NonNegativeInteger
from FiniteGraph S
- nodeFromArrow: (%, NonNegativeInteger) -> List NonNegativeInteger
from FiniteGraph S
- nodeFromNode: (%, NonNegativeInteger) -> List NonNegativeInteger
from FiniteGraph S
- nodeToArrow: (%, NonNegativeInteger) -> List NonNegativeInteger
from FiniteGraph S
- nodeToNode: (%, NonNegativeInteger) -> List NonNegativeInteger
from FiniteGraph S
- outDegree: (%, NonNegativeInteger) -> NonNegativeInteger
from FiniteGraph S
- routeArrows: (%, NonNegativeInteger, NonNegativeInteger) -> List NonNegativeInteger
from FiniteGraph S
- routeArrowWeight: (%, List NonNegativeInteger) -> W
the cumulative weight of a given route. The route is given in terms of a sequence of arrow indexes.
- routeNodes: (%, NonNegativeInteger, NonNegativeInteger) -> List NonNegativeInteger
from FiniteGraph S
- routeNodeWeight: (%, List NonNegativeInteger) -> W
the cumulative weight of a given route. The route is given in terms of a sequence of node indexes.
- spanningForestArrow: % -> List Tree Integer
from FiniteGraph S
- spanningForestNode: % -> List Tree Integer
from FiniteGraph S
- spanningTreeArrow: (%, NonNegativeInteger) -> Tree Integer
from FiniteGraph S
- spanningTreeNode: (%, NonNegativeInteger) -> Tree Integer
from FiniteGraph S
- subdiagramSvg: (Scene SCartesian 2, %, Boolean, Boolean) -> Void
from FiniteGraph S
- terminal: S -> %
from FiniteGraph S
- unit: (List S, String) -> %
from FiniteGraph S
- weightedDistanceMatrix: % -> TwoDimensionalArray Union(W, disjoint)
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: (List Record(value: S, posX: NonNegativeInteger, posY: NonNegativeInteger), List Record(name: String, arrType: NonNegativeInteger, fromOb: NonNegativeInteger, toOb: NonNegativeInteger, xOffset: Integer, yOffset: Integer, map: List NonNegativeInteger)) -> %
constructor for graph with given objects and arrows more objects and arrows can be added later if required.
- weightedGraph: (List Record(value: S, posX: NonNegativeInteger, posY: NonNegativeInteger, weight: W), List Record(name: String, weight: W, fromOb: NonNegativeInteger, toOb: NonNegativeInteger, xOffset: Integer, yOffset: Integer, map: List NonNegativeInteger)) -> %
weightedGraph(ob, ar)constructs graph with objects on and arrows ar. More objects and arrows can be added later if required.
- weightedGraph: (List S, List List NonNegativeInteger) -> %
constructor for graph with given objects and adjacency matrix.
- weightedGraph: (List S, List Record(fromOb: NonNegativeInteger, toOb: NonNegativeInteger)) -> %
weightedGraph(obs, ars)constructs graph with objectsobsand arrows ars. This constructor just has pure abstract graph information without decoration information.
- weightedGraph: FinitePoset S -> %
weightedGraph(poset)constructs graph from a partially ordered set. This will be a graph with, at most, one arrow between any two nodes.
- weightedGraph: List Record(value: S, posX: NonNegativeInteger, posY: NonNegativeInteger, weight: W) -> %
constructor for graph with given objects more objects and arrows can be added later if required.
- weightedGraph: List S -> %
constructor for graph with given list of object names. Use this version of the constructor if you don
'tintend to create diagrams and therefore don'tcare aboutx,ycoordinates. more objects and arrows can be added later if required.