Copyright © 2021 by K4.org
  (v.0.48.124)

This Design wraps the Graphology graph theory library. The graph can be created either by supplying the nodeData and edgeData, or by directly calling addNode and edgeNode to build the graph.

Index

Rules

clearHandle

clearHandle: Any

This clears the handle to ensure that dependencies are updated when a state change is made to the graph.

Flags : None. (Note this is uncached)

Expression : R.model.unbindSlot(this, 'graphHandle')

edgeData

edgeData: Array

An array of edge descriptions, where each edge is an array of three items: a source index, a target index, and an object containing custom data for the edge. The indexes are into the nodeData array. For a weighted graph, the custom data should contain a property with the weightAttributeName, for use by the algorithms to compute the cost of routes. This can only be supplied if nodeData is supplied. This is optional; if no edges are supplied, the graph starts without any, and they can be created using calls to addEdge or addDirectedEdge.

Flags : cached, parameter

Default expression : []

graphHandle

graphHandle: Boolean

Internal dependency magnet for graph-changing methods.

Flags : cached

Expression : true

graphInstance

graphInstance: Any

The graph object, an instance of a Graphology graph. Do not reference this directly, call getGraph() to obtain the graphology object.

Flags : cached

Expression : const Graph = require('graphology'); const graph = new Graph(); const nodes = this.nodeData.map((n,i) => { const name = this.nodeNameFunction(i, n); return graph.addNode(name, { data: n }); }); const edges = this.edgeData.map(e => { const data = e.length === 3 ? e[2] : undefined; const node0 = this.nodeNameFunction(e[0]); const node1 = this.nodeNameFunction(e[1]); if (this.isDirected) { return graph.addDirectedEdge(node0, node1, data); } else { return graph.addUndirectedEdge(node0, node1, data); } }); return graph;

isDirected

isDirected: Boolean

If true, creates directed edges when building the graph.

Flags : cached, parameter

Default expression : false

nodeData

nodeData: Array

An array of data objects, one for each node. The objects do not have any required content. This is optional; if no nodes are supplied, the graph starts empty, and can be created using calls to addNode.

Flags : cached, parameter

Default expression : []

weightAttributeName

weightAttributeName: String

The name of the weight attribute in the edge data, for used in weighted graphs.

Flags : cached, parameter

Default expression : "weight"

Methods

addDirectedEdge

  • addDirectedEdge(): String
  • Adds a directed edge from source to target, with optional associated data. Returns the edge name.

    Flags : method (Note this is uncached)

    Returns String

addEdge

  • addEdge(): String
  • Adds an undirected edge between source and target, with optional associated data. Returns the edge name.

    Flags : method (Note this is uncached)

    Returns String

addNode

  • addNode(): String
  • Adds a named node to the graph, with associated data, and returns its name. The name must be unique in the graph.

    Flags : method (Note this is uncached)

    Returns String

getGraph

  • getGraph(): Any
  • Method to access the internal graph object.

    Flags : method (Note this is uncached)

    Returns Any

isEdgeOnPath

  • isEdgeOnPath(): Boolean
  • Returns whether the given edge, identified by the two nodes it connects, is in the path, given by an array of nodes in order of traversal. Such a path can be returned by shortestPath.

    Flags : method (Note this is uncached)

    Returns Boolean

isNodeOnPath

  • isNodeOnPath(): Boolean
  • Returns whether the given node, identified by its name, is in the path, given by an array of nodes in order of traversal. Such a path can be returned by shortestPath.

    Flags : method (Note this is uncached)

    Returns Boolean

minimumSpanningTree

  • minimumSpanningTree(): Any
  • Returns the set of edges that define a minimum spanning tree on the current graph.

    Flags : method (Note this is uncached)

    Returns Any

nodeNameFunction

  • nodeNameFunction(): String
  • The function to use to compute the name of a node, given the node index and data. This function must produce a unique name for every node in the graph. Override this to provide your own node-naming function.

    Flags : method (Note this is uncached)

    Returns String

shortestPath

  • shortestPath(): Array
  • Returns the shortest path from startNode to endNode as an ordered array of node names. If there is no shortest path, an empty array is returned.

    Flags : method (Note this is uncached)

    Returns Array