Class Graph

class graph.Graph

This class represents an InstantTerra graph.

>>> from wysilab import InstantTerra
>>> it = InstantTerra()
>>> graph = it.project.graph  # Get the graph

class graph.NodeLocation

This enum represents the location of a node relative to another node.

  • Top

  • TopRight

  • Right

  • BottomRight

  • Bottom

  • BottomLeft

  • Left

  • TopLeft

Graph.get_node_count()

Returns

Number of nodes in the graph.

Return type

int

Returns the number of nodes in the graph.

>>> graph.get_node_count()
3

Graph.get_all_nodes()

Returns

List of nodes.

Return type

list (of Nodes)

Returns the list of nodes in the graph.

>>> graph.get_all_nodes()
[Perlin noise, Apply curve, Export terrain]

Graph.get_node_models()

Returns

List of node models.

Return type

list (of NodeModels)

Returns the list of node models.

>>> node_models = graph.get_node_models()

Graph.get_node_links(node)

Parameters

node (Node)

Returns

List of links.

Return type

list (of Links)

Returns the list of node links.

>>> graph.get_node_links(perlin_noise)
[Link: [ Perlin noise ]-------- LinkType.Terrain ------->[ Apply curve ]]

Graph.add_node(api_node_type, (x, y))

Parameters
  • api_node_type (ApiNodeType)

  • tuple of location (Tuple)

Returns

The created node.

Return type

Node

Creates and returns the node on the graph.

>>> node = graph.add_node(ApiNodeType.PERLIN_NOISE, (10,10))
>>> node
Perlin noise

Graph.add_node_from_model(node_model, (x, y))

Parameters
  • node_model (NodeModel)

  • tuple of location (Tuple)

Returns

The created node.

Return type

Node

Creates and returns the node on the graph.

>>> node = graph.add_node_from_model(perlin_node_model, (10,10))
>>> node
Perlin noise

Graph.add_node_next_to(api_node_type, node_location, previous_node)

Parameters
Returns

The created node.

Return type

Node

Creates and returns the node on the graph next to the specified node.

>>> node = graph.add_node_next_to(ApiNodeType.PERLIN_NOISE, NodeLocation.Right, previous_node)
>>> node
Perlin noise

Graph.add_node_from_model_next_to(node_model, node_location, previous_node)

Parameters
Returns

The created node.

Return type

Node

Creates and returns the node on the graph next to the specified node.

>>> node = graph.add_node_from_model_next_to(perlin_node_model, NodeLocation.Right, previous_node)
>>> node
Perlin noise

Graph.remove_node(node_to_remove)

Parameters

node_to_remove (Node)

Removes the node from the graph.

>>> graph.remove_node(node_to_remove)

Graph.add_link(start_node, start_connector, end_node, end_connector)

Parameters
Returns

The created link.

Adds a link between nodes

>>> graph.add_link(start_node, start_connector, end_node, end_connector)

Graph.add_link_using_name(start_node, start_connector_name, end_node, end_connector_name)

Parameters
Returns

The created link.

Adds a link between nodes, using the connector name

>>> graph.add_link_using_name(start_node, start_connector_name, end_node, end_connector_name)

Graph.get_node_links(Node)

Parameters

node (Node)

Returns

Links.

Gets all links connected to the node

>>> graph.get_node_links(perlin_noise)

Graph.remove_link(Link)

Parameters

node (Node)

Remove a link

>>> graph.remove_link(perlin_link)

Graph.is_available()

Returns

True if the graph exists, otherwise False.

Return type

bool

Returns the status of the graph.

>>> graph.is_available()
True
>>> it.project.close()  # Close the current project
>>> graph.is_available()
False

Copyright © 2022 · All Rights Reserved · Wysilab