# Global

##

### Members

#### (constant) compound

Create a new compound node. Each compound node is itself a graph that can contain further nodes.

Source:
  - graph/basic.js, line 38

#### (constant) equal

Compares two graphs for structural equality.

Source:
  - graph/basic.js, line 29

#### (constant) rePath

Updates all pathes in the graph.

Source:
  - graph/internal.js, line 126

### Methods

#### addComponent(comp, graph) → {PortGraph}

Add a component to the graph. [Performance O(|V| + |E|)]

##### Parameters:

Name | Type | Description
--- | --- | ---
`comp` | Component | The component object that should be added.
`graph` | PortGraph | The graph.

Source:
  - graph/component.js, line 66

##### Returns:

A new graph that includes the component.

Type
  PortGraph

#### addEdge(edge, graph) → {PortGraph}

Add an edge to the graph.

##### Parameters:

Name | Type | Description
--- | --- | ---
`edge` | Edge | The edge that should be added. This needn't be in standard format.
`graph` | PortGraph | The graph.

Source:
  - graph/edge.js, line 154

##### Throws:

If:

- the edge already exists
- ports that the edge connects do not exists
- nodes that the edge connects do not exists
- the edge is not in normalizable form.

Type
  Error

##### Returns:

A new graph containing the edge.

Type
  PortGraph

#### addNode(node, graph) → {PortGraph}

Add a node to the graph (at the root level), returns a new graph. [Performance O(|V| + |E|)]

##### Parameters:

Name | Type | Description
--- | --- | ---
`node` | Node | The node object that should be added. If the node already exists in the graph it will be copied. The node object must contain at least one valid ports. This functions checks if the node has ports AND if every port is a valid port (i.e. has a name as `port` and the port type (output/input) as `kind`).
`graph` | PortGraph | The graph.

Source:
  - graph/node.js, line 197

##### Returns:

A new graph that includes the node.

Type
  PortGraph

#### addNodeByPath(parentPath, node, graph) → {PortGraph}

Add a node at a specific path.

##### Parameters:

Name | Type | Description
--- | --- | ---
`parentPath` | CompoundPath | A compound path identifying the location in the compound graph.
`node` | Node | The node to add to the graph.
`graph` | PortGraph | The graph that is the root for the nodePath

Source:
  - graph/node.js, line 142

##### Returns:

A new graph that contains the node at the specific path.

Type
  PortGraph

#### addNodeIn(parentLoc, node, graph) → {PortGraph}

Add a node in a given compound node.

##### Parameters:

Name | Type | Description
--- | --- | ---
`parentLoc` | Location | A location identifying the parent for the new node.
`node` | Node | The node to add to the graph.
`graph` | PortGraph | The graph

Source:
  - graph/node.js, line 160

##### Returns:

A new graph that contains the node as child of `parentLoc`.

Type
  PortGraph

#### addNodeTuple(node, graph) → {PortGraph}

Add a node an return an array of the graph and id.

##### Parameters:

Name | Type | Description
--- | --- | ---
`node` | Node | The node object that should be added. If the node already exists in the graph it will be copied.
`graph` | PortGraph | The graph.

Source:
  - graph/node.js, line 241

##### Returns:

A new graph that includes the node and the id as an array in [graph, id].

Type
  PortGraph

#### allowsReferences() → {boolean}

Checks whether the graph allows references to components. This is usally disabled after the graph is resolved. Resolving a graph replaces all references with their components.

Source:
  - graph/basic.js, line 46

##### Returns:

True if the graph allows references, false otherwise.

Type
  boolean

#### applyChangeSet(graph, changeSet) → {Graphlib}

Apply a changeSet on the given graph.

##### Parameters:

Name | Type | Description
--- | --- | ---
`graph` | Object | The graph in JSON format that should be changed.
`changeSet` | ChangeSet | The change set that should be applied.

Source:
  - changeSet.js, line 211

##### Throws:

If the change set is no valid change set it throws an error.

Type
  Error

##### Returns:

A new graph with the applied change set graph.

Type
  Graphlib

#### applyChangeSetInplace(graph, changeSet) → {Graphlib}

Apply a changeSet on the given graph inplace.

##### Parameters:

Name | Type | Description
--- | --- | ---
`graph` | PortGraph | The graph that should be changed.
`changeSet` | ChangeSet | The change set that should be applied.

Source:
  - changeSet.js, line 236

##### Throws:

If the change set is no valid change set it throws an error.

Type
  Error

##### Returns:

The changed graph. Currently the changes are all made inplace so the return value is equal to the input graph.

Type
  Graphlib

#### applyChangeSets(graph, changeSets) → {Graphlib}

Apply an array of changeSets on the given graph. All changes are applied sequentially.

##### Parameters:

Name | Type | Description
--- | --- | ---
`graph` | PortGraph | The graph that should be changed.
`changeSets` | Array.<ChangeSet> | The change sets that should be applied. The order might influence the resulting graph, they are processesed sequentially.

Source:
  - changeSet.js, line 223

##### Throws:

If the change set is no valid change set it throws an error.

Type
  Error

##### Returns:

A new graph with the applied change set graph.

Type
  Graphlib

#### areConnected(nodeFrom, nodeTo, graph) → {boolean}

Checks whether the two nodes or ports are connected via an edge.

##### Parameters:

Name | Type | Description
--- | --- | ---
`nodeFrom` | Location | The starting point of our connection.
`nodeTo` | Location | The target of our connection.
`graph` | PortGraph | The graph in which we want to find the connection.

Source:
  - graph/connections.js, line 44

##### Returns:

True if the graph has an edge going from "nodeFrom" to "nodeTo".

Type
  boolean

#### atomics(graph) → {Array.<References>}

Gets a list of all atomic nodes.

##### Parameters:

Name | Type | Description
--- | --- | ---
`graph` | PortGraph | The graph.

Source:
  - graph/queries.js, line 29

##### Returns:

A list of all defined atomci nodes in the graph.

Type
  Array.<References>

#### clone(graph) → {PortGraph}

Creates a new graph that has the exact same nodes and edges.

##### Parameters:

Name | Type | Description
--- | --- | ---
`graph` | PortGraph | The graph to clone

Source:
  - graph/basic.js, line 19

##### Returns:

A clone of the input graph.

Type
  PortGraph

#### component(graph, comp) → {Component}

Returns the component with the given component id. [Performance O(|V|)]

##### Parameters:

Name | Type | Description
--- | --- | ---
`graph` | PortGraph | The graph.
`comp` | Component | string | The component or its component id.

Source:
  - graph/component.js, line 26

##### Throws:

If the queried component does not exist in the graph.

Type
  Error

##### Returns:

The component in the graph

Type
  Component

#### componentIds(graph) → {Array.<string>}

Returns a list of component ids. [Performance O(|V|)]

##### Parameters:

Name | Type | Description
--- | --- | ---
`graph` | PortGraph | The graph.

Source:
  - graph/component.js, line 22

##### Returns:

A list of component ids.

Type
  Array.<string>

#### components(graph)

Returns a list of defined components. Components are not part of the program flow, but are defined procedures that can be used in the resolve process.

##### Parameters:

Name | Type | Description
--- | --- | ---
`graph` | PortGraph | The graph.

Source:
  - graph/component.js, line 13

#### compounds(graph) → {Array.<References>}

Gets a list of all compound nodes.

##### Parameters:

Name | Type | Description
--- | --- | ---
`graph` | PortGraph | The graph.

Source:
  - graph/queries.js, line 20

##### Returns:

A list of all defined compound nodes in the graph.

Type
  Array.<References>

#### createConnection() → {Array.<ChangeSet>}

Creates a change set that adds edges to connect nodes in succession. All nodes, except the first and last, must be compound nodes.

Source:
  - changeSet.js, line 112

##### Returns:

An array of change sets that inserts the edges between the nodes. The change set will generate |stations| - 1 edges.

Type
  Array.<ChangeSet>

#### disallowReferences() → {PortGraph}

Stops references from being inserted into the graph. After references are disallowed they cannot and should not be reallowed.

Source:
  - graph/basic.js, line 56

##### Throws:

If the graph has references it throws an error. Only graphs without references can disallow them.

Type
  Error

##### Returns:

The graph given as an argument where references are now disallowed.

Type
  PortGraph

#### edge() → {Edge}

Returns the queried edge. This needn't be in standard format.

Source:
  - graph/edge.js, line 232

##### Throws:

If the edge is not contained in the graph.

Type
  Error

##### Returns:

The edge as it is stored in the graph.

Type
  Edge

#### edges(graph) → {Array.<Edges>}

Returns a list of edges in the graph. Each edge also has an extra field identifying the parent node to which the edge belongs in the hierarchy.

##### Parameters:

Name | Type | Description
--- | --- | ---
`graph` | PortGraph | The graph.

Source:
  - graph/edge.js, line 27

##### Returns:

A list of edges.

Type
  Array.<Edges>

##### Example

Getting the edges in a graph

    edges(graph) // -> [{from: ..., to: ..., layer: ..., parent: '#...'}, ...]

#### empty() → {PortGraph}

Returns a new empty graph.

Source:
  - graph/basic.js, line 67

##### Returns:

A new empty port graph.

Type
  PortGraph

#### flow() → {function}

##### Parameters:

Name | Type | Description
--- | --- | ---
`...args` | function | Array | An arbitrary number of arguments of that are either functions that take one argument and return this argument. Or an array of functions that each take an argument and return one. The functions must be composable.

Source:
  - graph/flow.js, line 5

##### Returns:

A function that takes an object that is fed into the first function in the arguments.

Type
  function

#### fromJSON(jsonGraph) → {PortGraph}

Adds the API to the JSON document to work with the graph.

##### Parameters:

Name | Type | Description
--- | --- | ---
`jsonGraph` | object | The json representing the port graph.

Source:
  - graph/convert.js, line 20

##### Returns:

The port graph with its functions.

Type
  PortGraph

#### fromString()

Creates a location object from the string representation

Source:
  - location.js, line 65

#### get(key, loc, graph)

Get a property of a node.

##### Parameters:

Name | Type | Description
--- | --- | ---
`key` | String | The key of the property like 'recursion'
`loc` | Location | The location identifying the node for which the property is queried.
`graph` | PortGraph | The graph.

Source:
  - graph/node.js, line 258

##### Returns:

The value of the property or undefined if the property does not exist in the node.

##### Example

    * var graph = ...
    var newGraph = Graph.set({property: value}, '#nodeIDOrLocation', graph)
    // you can get the value via get in the newGraph
    var propertyValue = Graph.get('property', '#nodeIDOrLocation', graph)

#### hasComponent(graph, comp) → {boolean}

Checks whether the graph has a component with the given component id. [Performance O(|V|)]

##### Parameters:

Name | Type | Description
--- | --- | ---
`graph` | PortGraph | The graph.
`comp` | Component | string | The component or its component id you want to check for.

Source:
  - graph/component.js, line 44

##### Returns:

True if the graph has a component with the given component id, false otherwise.

Type
  boolean

#### hasEdge() → {boolean}

Checks whether the graph has the given edge.

Source:
  - graph/edge.js, line 220

##### Returns:

True if the edge is contained in the graph, false otherwise.

Type
  boolean

#### hasNode(loc, graph) → {boolean}

Checks whether the graph has a node. [Performance O(|V|)]

##### Parameters:

Name | Type | Description
--- | --- | ---
`loc` | Location | A location identifying the node
`graph` | PortGraph | The graph.

Source:
  - graph/node.js, line 112

##### Returns:

True if the graph has a node with the given id, false otherwise.

Type
  boolean

#### identifies()

Checks whether a location identifies the given object. This is true if for example the location points to a node and the other object is the node. Or if the other object is simply the ID of the node. It also identifies a node if the location specifies the port. If you don't want this behavior use equals (it is the strict version of identifies).

Source:
  - location.js, line 182

##### Returns:

True if the location identifies the object stored in other.

#### idToPath(id, graph) → {CompoundPath|null}

Returns the path that points to the node in the graph by its id. The id is preserved when moving or editing nodes. The path might change. To fixate a node one can use the ID.

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | string | The id of the node
`graph` | PortGraph | The graph to search in

Source:
  - graph/internal.js, line 68

##### Returns:

The path to the node with the given ID.

Type
  CompoundPath | null

#### incidents(loc, graph) → {Array.<Edge>}

All incident edges to the given input.

##### Parameters:

Name | Type | Description
--- | --- | ---
`loc` | Location | The node or port.
`graph` | PortGraph | The graph

Source:
  - graph/connections.js, line 114

##### Returns:

An array of all incident edges to the given location.

Type
  Array.<Edge>

#### inIncident(target, graph) → {Edge}

Gets the ingoing incident edge to a port. Each port can only have one ingoing edge.

##### Parameters:

Name | Type | Description
--- | --- | ---
`target` | Location | The node or port to which the edge is incident. This is the target node or port of the edge.
`graph` | PortGraph | The graph

Source:
  - graph/connections.js, line 86

##### Returns:

The ingoing incident edge.

Type
  Edge

#### inIncidents(target, graph) → {Array.<Edge>}

Gets all ingoing incident edges to a port

##### Parameters:

Name | Type | Description
--- | --- | ---
`target` | Location | The port to which the edges are incident. This is the target node or port of each edge.
`graph` | PortGraph | The graph

Source:
  - graph/connections.js, line 76

##### Returns:

An array of all ingoing (i.e. pointsTo(port)) incident edges.

Type
  Array.<Edge>

#### insertComponent(value) → {ChangeSet}

Creates a change set that creates a new component.

##### Parameters:

Name | Type | Description
--- | --- | ---
`value` | Object | The new component.

Source:
  - changeSet.js, line 48

##### Returns:

A change set containing the new component.

Type
  ChangeSet

#### insertEdge(newEdge) → {ChangeSet}

Creates a change set that inserts a new edge into the edge list

##### Parameters:

Name | Type | Description
--- | --- | ---
`newEdge` | Object | The edge that should be inserted.

Source:
  - changeSet.js, line 84

##### Returns:

A change set containing the insertion operation.

Type
  ChangeSet

#### insertNode(value) → {ChangeSet}

Creates a change set that creates a new node.

##### Parameters:

Name | Type | Description
--- | --- | ---
`value` | Object | The new node.

Source:
  - changeSet.js, line 35

##### Returns:

A change set containing the new node.

Type
  ChangeSet

#### isChangeSet(changeSet)

Checks whether a value is a change set or not.

##### Parameters:

Name | Type | Description
--- | --- | ---
`changeSet` |  | The value that should be checked.

Source:
  - changeSet.js, line 133

##### Returns:

True if it is a changeSet, false otherwise.

#### isFrom(target, graph, edge) → {boolean}

Checks whether an edge is from a given source.

##### Parameters:

Name | Type | Description
--- | --- | ---
`target` | Location | The source the edge should come from. This can either be a node or a port.
`graph` | PortGraph | The graph
`edge` | Edge | The edge to check

Source:
  - graph/connections.js, line 23

##### Returns:

True if the edge comes from the source, false otherwise.

Type
  boolean

#### isPortNotation()

A port notation can have every of the other notations for the node and as such it is necessary to check first if it is a port notation. The symbol '@' is only used in port notations.

Source:
  - location.js, line 20

#### location(loc, graph) → {Location}

Create a new location from a given object

##### Parameters:

Name | Type | Description
--- | --- | ---
`loc` |  | Any processable form of location. TODO: list alle formats.
`graph` | PortGraph | The graph in which the location is valid.

Source:
  - location.js, line 133

##### Returns:

A location object

Type
  Location

#### mergeNodes(oldNode, newNode, graph, cbopt) → {PortGraph}

Merges the contents of a node with the given data. This CAN destroy the structure of the graph so be cautious and prefer updateNode whenever possible.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`oldNode` | Node |  | The old node that should get updated
`newNode` | Object |  | New values for the old node as an object that gets merged into the node.
`graph` | PortGraph |  | The graph
`cb` | Callback | <optional> | A callback function that is called with the newly inserted node.

Source:
  - graph/internal.js, line 99

##### Returns:

The new graph with the merged nodes.

Type
  PortGraph

#### meta(graph) → {object}

Returns the meta information encoded in the graph

##### Parameters:

Name | Type | Description
--- | --- | ---
`graph` | PortGraph | The graph.

Source:
  - graph/meta.js, line 10

##### Returns:

An object with all meta information keys.

Type
  object

#### node(loc, graph) → {Node}

Returns the node at the given location. [Performance O(|V|)]

##### Parameters:

Name | Type | Description
--- | --- | ---
`loc` | Location | A location identifying the node.
`graph` | PortGraph | The graph.

Source:
  - graph/node.js, line 81

##### Throws:

If the queried node does not exist in the graph.

Type
  Error

##### Returns:

The node in the graph

Type
  Node

#### nodeBy(fn, graph) → {Node|undefined}

Find a node using a predicate.

##### Parameters:

Name | Type | Description
--- | --- | ---
`fn` | function | A function that decides for each node if it should be rejected or not
`graph` | PortGraph | The graph

Source:
  - graph/internal.js, line 64

##### Returns:

The first node that matches the predicate.

Type
  Node | undefined

#### nodeByPath(path, graph) → {Node|undefined}

Returns a node that is located at a specific path in the graph.

##### Parameters:

Name | Type | Description
--- | --- | ---
`path` | CompoundPath | The path to the wanted node.
`graph` | PortGraph | The graph

Source:
  - graph/internal.js, line 51

##### Returns:

The node or undefined if the path does not exist.

Type
  Node | undefined

#### nodeNames(graph) → {Array.<string>}

Returns a list of node names. [Performance O(|V|)]

##### Parameters:

Name | Type | Description
--- | --- | ---
`graph` | PortGraph | The graph.

Source:
  - graph/node.js, line 77

##### Returns:

A list of node names.

Type
  Array.<string>

#### nodes(graph, predicateopt) → {Array.<Nodes>}

Returns a list of nodes on the root level.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`graph` | PortGraph |  | The graph.
`predicate` | function | <optional> | An optional function that filters nodes. If no predicate function is given, all nodes are returned.

Source:
  - graph/internal.js, line 18

##### Returns:

A list of nodes.

Type
  Array.<Nodes>

#### nodes(graph) → {Array.<Nodes>}

Returns a list of nodes on the root level.

##### Parameters:

Name | Type | Description
--- | --- | ---
`graph` | PortGraph | The graph.

Source:
  - graph/node.js, line 21

##### Returns:

A list of nodes.

Type
  Array.<Nodes>

#### nodesBy(predicate, graph) → {Array.<Nodes>}

Returns a list of nodes on the root level selected by a given predicate.

##### Parameters:

Name | Type | Description
--- | --- | ---
`predicate` | function | A function that filters nodes.
`graph` | PortGraph | The graph.

Source:
  - graph/node.js, line 32

##### Returns:

A list of nodes.

Type
  Array.<Nodes>

#### nodesDeep(graph) → {Array.<Node>}

Get all nodes at all depths. It will go into every compound node and return their nodes and the nodes of their compound nodes, etc.

##### Parameters:

Name | Type | Description
--- | --- | ---
`graph` | PortGraph | The graph to work on

Source:
  - graph/internal.js, line 40

##### Returns:

A list of nodes.

Type
  Array.<Node>

#### nodesDeep(graph) → {Array.<Node>}

Get all nodes at all depths. It will go into every compound node / lambda node and return their nodes and the nodes of their compound nodes, etc.

##### Parameters:

Name | Type | Description
--- | --- | ---
`graph` | PortGraph | The graph to work on

Source:
  - graph/node.js, line 54

##### Returns:

A list of nodes.

Type
  Array.<Node>

#### nodesDeepBy(predicate, graph) → {Array.<Node>}

Get all nodes at all depths that fulfill the given predicate. It will go into every compound node and return their nodes and the nodes of their compound nodes, etc.

##### Parameters:

Name | Type | Description
--- | --- | ---
`predicate` | function | A function that filters nodes.
`graph` | PortGraph | The graph to work on

Source:
  - graph/node.js, line 59

##### Returns:

A list of nodes that fulfill the predicate.

Type
  Array.<Node>

#### outIncidents(source, graph) → {Array.<Edge>}

Gets all outgoing incident edges to a port. The given port or node is the source of each edge.

##### Parameters:

Name | Type | Description
--- | --- | ---
`source` | Location | The port from which the edge comes. This is the source node or port of the edge.
`graph` | PortGraph | The graph

Source:
  - graph/connections.js, line 96

##### Returns:

An array of all outgoing (i.e. isFrom(port)) incident edges.

Type
  Array.<Edge>

#### parent(loc, graph) → {Node}

Gets the parent of a node.

##### Parameters:

Name | Type | Description
--- | --- | ---
`loc` | Location | A location identifying the node whose parent is wanted.
`graph` | PortGraph | The graph.

Source:
  - graph/node.js, line 356

##### Returns:

The node id of the parent node or undefined if the node has no parent.

Type
  Node

#### parseCompoundPath(compoundPathStr) → {Array.<String>}

Converts a compound path string into its array representation. The seperate parts must be divided by a '»'.

##### Parameters:

Name | Type | Description
--- | --- | ---
`compoundPathStr` | String | A string reperesenting the compound path divded by '»'.

Source:
  - location.js, line 59

##### Returns:

An array of node IDs representing the compound path.

Type
  Array.<String>

#### pointsTo(target, graph, edge) → {boolean}

Checks whether an edge points to a given target.

##### Parameters:

Name | Type | Description
--- | --- | ---
`target` | Location | The target the edge should point to. This can either be a node or a port.
`graph` | PortGraph | The graph
`edge` | Edge | The edge to check

Source:
  - graph/connections.js, line 9

##### Returns:

True if the edge points to the target, false otherwise.

Type
  boolean

#### port(port, graph) → {Node}

Returns a port specified by the short notation or a port query object. [Performance O(|V|)]

##### Parameters:

Name | Type | Description
--- | --- | ---
`port` | Port | A port object or a short notation for a port.
`graph` | PortGraph | The graph.

Source:
  - graph/node.js, line 98

##### Throws:

If the queried port does not exist in the graph.

Type
  Error

##### Returns:

The actual port object with type information.

Type
  Node

#### predecessor(target, graph) → {Port}

Returns the predecessors for a node or a port. Each node can only have exactly one predecessor for every port.

##### Parameters:

Name | Type | Description
--- | --- | ---
`target` | Location | The target to which the predecessores points.
`graph` | PortGraph | The graph.

Source:
  - graph/connections.js, line 66

##### Returns:

The preceeding port

Type
  Port

#### predecessors(target, graph) → {Array.<Port>}

Returns a list of predecessors for a node or a port. Each node can only have exactly one predecessor for every port but this function always returns a list.

##### Parameters:

Name | Type | Description
--- | --- | ---
`target` | Location | The target to which the predecessores point.
`graph` | PortGraph | The graph.

Source:
  - graph/connections.js, line 55

##### Returns:

A list of ports with that are predecessors of `target`

Type
  Array.<Port>

#### query(loc, graph) → {function}

Create a query function for a location.

##### Parameters:

Name | Type | Description
--- | --- | ---
`loc` | Location | A location identifier.
`graph` | PortGraph | The graph in which the location is valid.

Source:
  - location.js, line 163

##### Returns:

A function that takes another location or location identifier and compares it to the specified location `loc`. See `Location.identifies`.

Type
  function

#### realizeEdgesForNode(loc, graph) → {Portgraph}

This goes through all edges that are connected to the given node and realizes them, if a node reference was replaced by an actual node. If it was replaced by another reference nothing will happen.

##### Parameters:

Name | Type | Description
--- | --- | ---
`loc` | Location | A location identifier for the node whose edges should be updated.
`graph` | Portgraph | The graph to perform the operation on

Source:
  - graph/edge.js, line 272

##### Returns:

A new graph in which the edges for the given node are realized (if possible).

Type
  Portgraph

##### Example

Where it is used, when modifying graphs.

    var graph = Graph.flow(
      Graph.addNode({ref: 'a', name: 'a', ports: []}),
      Graph.addNode({ref: 'b', name: 'b', ports: []}),
      Graph.addEdge({from: 'a@0', to: 'b@0'}),
      // the following command will call realizeEdgesForNode
      // it will replace the 0-th port in the edge with the 'outA' port.
      Graph.replaceNode('a', {componentId: 'a', ports: [{port: 'outA', kind: 'input', type: 'generic'}]})
      // the following command will call realizeEdgesForNode
      // it will replace the 0-th port in the edge with the 'outA' port.
      Graph.replaceNode('b', {componentId: 'b', ports: [{port: 'inB', kind: 'input', type: 'generic'}]})
    )()
    // after this the graph will have an edge {from: 'a@outA', to: 'b@inB'} and not {from: 'a@0', to: 'b@0'} anymore.

#### references(graph) → {Array.<References>}

Gets a list of all reference nodes.

##### Parameters:

Name | Type | Description
--- | --- | ---
`graph` | PortGraph | The graph.

Source:
  - graph/queries.js, line 11

##### Returns:

A list of all defined reference nodes in the graph.

Type
  Array.<References>

#### removeComponent(comp, graph) → {PortGraph}

Removes a component from the graph. [Performance O(|V| + |E|)]

##### Parameters:

Name | Type | Description
--- | --- | ---
`comp` | Component | string | The component that shall be removed, either the component object or the component id.
`graph` | PortGraph | The graph.

Source:
  - graph/component.js, line 82

##### Returns:

A new graph without the given component.

Type
  PortGraph

#### removeEdge(edge, graph) → {PortGraph}

Remove an edge in the graph

##### Parameters:

Name | Type | Description
--- | --- | ---
`edge` | Edge | The edge that should be removed. This needn't be in standard format.
`graph` | PortGraph | The graph

Source:
  - graph/edge.js, line 176

##### Throws:

If there is no such edge in the graph.

Type
  Error

##### Returns:

A new graph that does not contain the edge anymore.

Type
  PortGraph

#### removeEdge(edge) → {ChangeSet}

Creates a change set that removes the edge `edge`.

##### Parameters:

Name | Type | Description
--- | --- | ---
`edge` | Object | The edge to remove.

Source:
  - changeSet.js, line 102

##### Returns:

The change set containing the deletion operation.

Type
  ChangeSet

#### removeNode(loc, graph) → {PortGraph}

Removes a node from the graph. [Performance O(|V| + |E|)]

##### Parameters:

Name | Type | Description
--- | --- | ---
`loc` | Location | The location identifying the node to delete.
`graph` | PortGraph | The graph.

Source:
  - graph/node.js, line 294

##### Returns:

A new graph without the given node.

Type
  PortGraph

#### replaceNode(loc, newNode, graph) → {PortGraph}

Replace a node in the graph with another one. It tries to keep all edges. TODO: currently it will silently ignore the fact that edges are not valid anymore after replacing!

##### Parameters:

Name | Type | Description
--- | --- | ---
`loc` | Location | A location specifying the node to replace
`newNode` | Node | The new node that replaces the old one.
`graph` | PortGraph | The graph

Source:
  - graph/node.js, line 318

##### Returns:

A new graph in which the old node was replaces by the new one.

Type
  PortGraph

#### set(value, loc, graph) → {PortGraph}

Sets properties for node.

##### Parameters:

Name | Type | Description
--- | --- | ---
`value` | Object | The properties to set, e.g. `{recursion: true, recursiveRoot: true}`
`loc` | Location | The location identifying the node in which the property should be changed.
`graph` | PortGraph | The graph

Source:
  - graph/node.js, line 222

##### Returns:

A graph in which the change is realized.

Type
  PortGraph

##### Example

    var graph = ...
    var newGraph = Graph.set({property: value}, '#nodeIDOrLocation', graph)
    // you can get the value via get in the newGraph
    var propertyValue = Graph.get('property', '#nodeIDOrLocation', graph)

#### setMetaKey(key, value, graph)

Sets the meta information in the graph for the given key to the value

##### Parameters:

Name | Type | Description
--- | --- | ---
`key` | string | The meta key for the value.
`value` |  | Any possible value for the key.
`graph` | PortGraph | The graph.

Source:
  - graph/meta.js, line 14

##### Returns:

A new graph with the applied changes.

#### setMetaKey(obj, graph) → {PortGraph}

Set meta information in the graph

##### Parameters:

Name | Type | Description
--- | --- | ---
`obj` | Object | An object with all keys that shall be changed.
`graph` | PortGraph | The graph.

Source:
  - graph/meta.js, line 27

##### Returns:

A new graph with the applied changes.

Type
  PortGraph

#### setPortName(loc, port, portUpdate, graph) → {PortGraph}

Updates a port of a node.

##### Parameters:

Name | Type | Description
--- | --- | ---
`loc` | Location | A location specifying the node to update.
`port` | port | The port name or its index.
`portUpdate` | Port | The new port object or parts of the new object (it will merge with the existing values).
`graph` | PortGraph | The graph

Source:
  - graph/node.js, line 340

##### Throws:

If the location does not specify a node in the graph.

Type
  Error

##### Returns:

A new graph in which the port has been updated.

Type
  PortGraph

#### successors(source, graph) → {Array.<Port>}

Get the successors of one node in the graph, optionally for a specific port.

##### Parameters:

Name | Type | Description
--- | --- | ---
`source` | Location | The source from which to follow the edges.
`graph` | PortGraph | The graph.

Source:
  - graph/connections.js, line 106

##### Returns:

A list of ports that succeed the node with their corresponding nodes.

Type
  Array.<Port>

#### toJSON(graph) → {object}

Returns a JSON object for the graph

##### Parameters:

Name | Type | Description
--- | --- | ---
`graph` | PortGraph | The graph to convert

Source:
  - graph/convert.js, line 56

##### Returns:

A JSON representation of the graph.

Type
  object

#### updateComponent(comp, merge, graph)

Update an existing component in the graph.

##### Parameters:

Name | Type | Description
--- | --- | ---
`comp` | Component | string | The component that will be update, either the component object or the component id.
`merge` | Object | Updated values of the component. It is not possible to change the component id with this method.
`graph` | PortGraph | The graph

Source:
  - graph/component.js, line 94

#### updateComponent(compId, mergeValue) → {ChangeSet}

Creates a change set to update a component with a given value

##### Parameters:

Name | Type | Description
--- | --- | ---
`compId` | string | The componentId of the component.
`mergeValue` | Object | An object that contains parts of a component that should be set. E.g. `{isType: true}` will update the field `isType` in the component and sets it to `true`.

Source:
  - changeSet.js, line 59

##### Returns:

A change set containing the operation.

Type
  ChangeSet

#### updateEdge(newEdge) → {ChangeSet}

Creates a change set that inserts a new edge into the edge list

##### Parameters:

Name | Type | Description
--- | --- | ---
`newEdge` | Object | The edge that should be inserted.

Source:
  - changeSet.js, line 93

##### Returns:

A change set containing the insertion operation.

Type
  ChangeSet

#### updateNode(node, mergeValue) → {ChangeSet}

Creates a change set to update a node with a given value

##### Parameters:

Name | Type | Description
--- | --- | ---
`node` | string | The identifier of the node.
`mergeValue` | Object | An object that contains parts of a node that should be set. E.g. `{recursive: true}` will update the field `recursive` in the node and sets it to `true`.

Source:
  - changeSet.js, line 26

##### Returns:

A change set containing the operation.

Type
  ChangeSet