Skip to main content

NodeGraph

Classes

Graph of nodes, implements node-based programming pattern Notable contemporary examples include:

  • SideFX Houdini
  • Blender - geometry nodes, shaders
  • Unreal Engine - blueprints
  • Grasshopper

Members

NodeGraph

Graph of nodes, implements node-based programming pattern Notable contemporary examples include:

  • SideFX Houdini
  • Blender - geometry nodes, shaders
  • Unreal Engine - blueprints
  • Grasshopper

Kind: global class
See: https://en.wikipedia.org/wiki/Node_graph_architecture

nodeGraph.version ⇒ number

Gets incremented every time structure of the graph changes, meaning nodes or connections are added/removed Unsigned integer value

Kind: instance property of NodeGraph
Read only: true

nodeGraph.on

Kind: instance property of NodeGraph
Read only: true

nodeGraph.isNodeGraph : boolean

Useful for type checks

Kind: instance property of NodeGraph
Read only: true
Example

if(graph.isNodeGraph === true){
// yep, that's a NodeGraph alright!
}

nodeGraph.reset()

Clear out all data from the graph

Kind: instance method of NodeGraph

nodeGraph.copy(other)

Perform a deep copy

Kind: instance method of NodeGraph

ParamType
otherNodeGraph

nodeGraph.clone() ⇒ NodeGraph

Kind: instance method of NodeGraph

nodeGraph.merge(other) ⇒ Object

Merge another graph into this one Supplied graph does not change as a result

Kind: instance method of NodeGraph
See: #mergeFragment

ParamType
otherNodeGraph

nodeGraph.mergeFragment(nodes, [connections]) ⇒ Object

Merge foreign nodes and associated connections into this graph New node instances and connections will be created to reflect these inside this graph NOTE: parameters on merged nodes are shallow copies NOTE: if IDs are available - copied nodes will have the same IDs as the originals

Kind: instance method of NodeGraph
Returns: Object - local created instances

ParamType
nodesArray.<NodeInstance>
[connections]Array.<Connection>

nodeGraph.traverseNodes(visitor, [thisArg])

Kind: instance method of NodeGraph

ParamType
visitorfunction
[thisArg]

nodeGraph.traverseConnections(visitor, [thisArg])

Kind: instance method of NodeGraph

ParamType
visitorfunction
[thisArg]

nodeGraph.getNodes() ⇒ Array.<NodeInstance>

Returns an array of all node instances NOTE: this array is a copy

Kind: instance method of NodeGraph

nodeGraph.getConnections() ⇒ Array.<Connection>

Returns an array of all connections NOTE: this array is a copy

Kind: instance method of NodeGraph

nodeGraph.hasNode(node) ⇒ boolean

Kind: instance method of NodeGraph

ParamType
nodeNodeInstance

nodeGraph.getNodesByDescription(description) ⇒ Array.<NodeInstance>

Kind: instance method of NodeGraph

ParamType
descriptionNodeDescription

nodeGraph.getNodesByDescriptionClass(Klass) ⇒ Array.<NodeInstance>

Kind: instance method of NodeGraph

ParamType
KlassType.<NodeDescription>

nodeGraph.getNode(id) ⇒ NodeInstance | undefined

Kind: instance method of NodeGraph

ParamType
idnumber

nodeGraph.getNodeSafe(id) ⇒ NodeInstance

Same as getNode but throw exception when node doesn't exist

Kind: instance method of NodeGraph
Throws:

  • if node doesn't exist
ParamType
idnumber

nodeGraph.getConnection(id) ⇒ Connection | undefined

Kind: instance method of NodeGraph

ParamType
idnumber

nodeGraph.getConnectionEndpoint(node_id, port_id) ⇒ NodeInstancePortReference | undefined

Kind: instance method of NodeGraph

ParamType
node_idnumber
port_idnumber

nodeGraph.createNode(node) ⇒ number

Kind: instance method of NodeGraph
Returns: number - ID of the new node

ParamType
nodeNodeDescription

nodeGraph.addNode(node)

Kind: instance method of NodeGraph

ParamType
nodeNodeInstance

nodeGraph.deleteNode(id) ⇒ boolean

Kind: instance method of NodeGraph
Returns: boolean - True if deleted, false if node was not found

ParamType
idnumber

nodeGraph.createConnectionByPortName(sourceNode, sourcePort, targetNode, targetPort) ⇒ number

Utility method to help in creation of connections Same as #createConnection, but ports are identified by their named instead

Kind: instance method of NodeGraph
Returns: number - connection ID

ParamType
sourceNodenumber
sourcePortstring
targetNodenumber
targetPortstring

nodeGraph.createConnection(sourceNode, sourcePort, targetNode, targetPort) ⇒ number

Kind: instance method of NodeGraph
Returns: number - ID of created or already existing connection
Throws:

  • if any node or port are not found
ParamType
sourceNodenumber
sourcePortnumber
targetNodenumber
targetPortnumber

nodeGraph.deleteConnection(id) ⇒ boolean

Kind: instance method of NodeGraph
Returns: boolean - True if deleted, false if connection was not found

ParamType
idnumber

nodeGraph.getConnectionsAttachedToNode(id, result) ⇒ number

Kind: instance method of NodeGraph
Returns: number - number of found connections

ParamTypeDescription
idnumber
resultArray.<number>IDs of attached connections

nodeAdded : Signal.<NodeInstance, number>

Kind: global variable
Read only: true

nodeRemoved : Signal.<NodeInstance, number>

Kind: global variable
Read only: true

connectionAdded : Signal.<Connection, number>

Kind: global variable
Read only: true

connectionRemoved : Signal.<Connection, number>

Kind: global variable
Read only: true