Members
(static, readonly) D
Constant "Down"
- Source:
(static, readonly) E
Constant "East"
- Source:
(static, readonly) eventsAvailable
Checks if SoupGraphs are able to register event listeners and dispatch events
- Source:
(static) graphBuilders
Automatic graph builders for often used topologies
- Source:
(static, readonly) N
Constant "North"
- Source:
(static, readonly) S
Constant "South"
- Source:
(static, readonly) U
Constant "Up"
- Source:
(static, readonly) W
Constant "West"
- Source:
nodes
An array of all node handles in the graph. This is not static, even though the documentation says so
- Source:
Methods
addEdge(properties)
Adds an edge between two nodes in the graph
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
properties |
object | Properties for the edge to add
Properties
|
- Source:
addNode(id, dataopt) → {string}
Adds a node to the graph
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
string | The handle to use for the node | |
data |
<optional> |
Any data to store in the node |
- Source:
Returns:
The handle of the node. Same as the "id" parameter
- Type
- string
getData(node)
Get the data held by a node
Parameters:
Name | Type | Description |
---|---|---|
node |
string | Handle for the node to get data from |
- Source:
Returns:
The data held by the node
getEdges(from, to) → {Array}
Gets an array of all edges going from a node to another node
Parameters:
Name | Type | Description |
---|---|---|
from |
string | Handle for the node to get edges from |
to |
string | Handle for the node to get edges to |
- Source:
Returns:
Array containing all edges currently going between the nodes in the direction specified
- Type
- Array
getEdgesFrom(node) → {Array}
Gets an array of all edges going from a node. Edges are read-only
Parameters:
Name | Type | Description |
---|---|---|
node |
string | Handle for the node to get edges from |
- Source:
Returns:
An array containing all current edges from the given node
- Type
- Array
getEdgesTo(node) → {Array}
Gets an array of all edges going to a node. Edges are read-only
Parameters:
Name | Type | Description |
---|---|---|
node |
string | Handle for the node to get edges to |
- Source:
Returns:
An array containing all current edges to the given node
- Type
- Array
getNamedEdgeFrom(node, name)
Gets an edge with a given name from a node
Parameters:
Name | Type | Description |
---|---|---|
node |
string | Handle for the node to get the edge from |
name |
string | Name of the edge to get |
- Source:
getNamedEdgeTo(node, name)
Gets an edge with a given name to a node
Parameters:
Name | Type | Description |
---|---|---|
node |
string | Handle for the node to get the edge to |
name |
string | Name of the edge to get |
- Source:
isValidNode(node) → {boolean}
Checks if a handle's node is in the graph
Parameters:
Name | Type | Description |
---|---|---|
node |
string | The node handle to check |
- Source:
Returns:
True if the node is in the graph, false otherwise
- Type
- boolean
load(json)
Loads a graph from JSON. May be used to add one graph to another, but will fail if this graph and the graph loaded contain nodes with the same IDs
Parameters:
Name | Type | Description |
---|---|---|
json |
string | JSON-representaion of a graph made with SoupGraph#save |
- Source:
- See:
-
- SoupGraph.graphBuilders#fromJSON
makeMaze()
Turns a SoupGraph into a maze. Please note that if the graph has unidirectional edges or disconnected graphs, the maze may become unsolvable
- Source:
removeEdge(edge)
Removes an edge from the graph
Parameters:
Name | Type | Description |
---|---|---|
edge |
SoupGraphEdge | The edge to remove |
- Source:
removeNode(node)
Removes a node from the graph. All edges to and from the node are removed along with it
Parameters:
Name | Type | Description |
---|---|---|
node |
string | Handle for the node to remove |
- Source:
save() → {string}
Saves a graph as JSON
- Source:
Returns:
JSON-representation of the graph
- Type
- string
setData(node, data)
Set the data held by a node
Parameters:
Name | Type | Description |
---|---|---|
node |
string | Handle for the node to set data to |
data |
The data to store in the node |
- Source: