- What is the project's
"
*graph*"? - Retrieving the number of nodes in the graph
- Retrieving all nodes in the graph
- Adding a node on the graph
- Adding a node on the graph next to another one
- Removing a node from the graph
- Adding a link between two nodes
- Adding a link between two nodes using the connector name
- Removing a link

The project's `graph`

represents all nodes of your project.

```
// Create an instance of InstantTerra
InstantTerra instantTerra = new InstantTerra();
// Get the current graph
Graph graph = instantTerra.GetProject().GetGraph();
```

```
// Returns the numbers of nodes in the graph
int numberOfNodes = graph.GetNodeCount();
Console.WriteLine(number_of_nodes);
```

See `GetNodeCount()`

in the documentation.

```
// Returns the list of nodes in the graph
List<Node> listOfNodes = graph.GetAllNodes();
```

The `GetAllNodes()`

method lists the `nodes`

of the graph.

Tip

More information about the nodes is found in the section Accessing node data.

```
// Add a node in the graph
Node newNode = graph.AddNode(ApiNodeType.PerlinNoise, 10, 10);
```

The ```
AddNode(ApiNodeType, int,
int)
```

method creates a node on
the graph at the specified location, and returns the new node.

```
// Add a node in the graph next to another one
Node newNode = graph.AddNodeNextTo(ApiNodeType.PerlinNoise, NodeLocation.Right, previousNode);
```

The `AddNodeNextTo(ApiNodeType, NodeLocation, Node)`

method creates a node on the graph
next to a specified node, and returns the new node.

```
// Remove a node from the graph
graph.RemoveNode(nodeToRemove);
```

The `RemoveNode()`

method removes the node from
the graph.

```
// Get connectors
Connector startConnector = perlinNode.GetConnectors()[ConnectorMode.Output][0]; # Has only one output connector
Connector endConnector = applyCurveNode.GetConnectors()[ConnectorMode.Input][0]; # Has only one output connector
// Add a link between two nodes
Link link = graph.AddLink(perlinNode, startConnector, applyCurveNode, endConnector);
```

The ```
AddLink(Node startNode,
Connector startConnector, Node
endNode, Connector endConnector)
```

method creates a link between
two nodes of the graph.

```
// Add a link between two nodes
Link link = graph.AddLinkUsingName(perlinNode, "output_terrain_1", applyCurveNode, "input_terrain_1");
```

The ```
AddLinkUsingName(Node startNode, string
startConnectorName, Node endNode, string endConnectorName)
```

method creates a link
between two nodes of the graph.

```
// Remove a link
graph.RemoveLink(perlin_link);
```

The `RemoveLink(Link)`

method removes the
link.

Copyright © 2021 · All Rights Reserved · Wysilab