# Scripting API for Graph Backend

The data structure properties dialog allows access to configure settings specific to the Graph backend. There, with Graph Type you can select the type of the graph. The meaning of these types is as follows:

- Graph: Graph at which same edges (with respect to start and end points) may not exist multiple times.

- Multigraph: Graph at which same edges (with respect to start and end points) may exist multiple times.

## Graph Data Structure

A graph objects holds the information of a data structure of type Graph.

### Properties

- name :

  The unique name of this data structure.

### Methods

nodes()

  Return list all nodes in the graph.

          array nodes

nodes(type)

  Return list all nodes in the graph of specified type.

          array nodes
          int type

edges()

  Return list all edges in the graph.

          array edges

edges(type)

  Return list all edges in the graph of specified type.

          array edges
              int type

createNode(type)

  Create a new node of the specified type and return the created node. If the type is not registered, no node is created.

          GraphNode createNode
              int type

createNode()

  Create a new node of default type and return the created node.

          GraphNode createNode

createEdge(from, to, type)

  Create an edge from node "from" to node "to" of the specified type and return the created edge. If the type is not registered, no edge is created.

          GraphEdge createEdge
              GraphNode from
              GraphNode to
              int type

createEdge(from, to)

  Create an edge from node "from" to node "to" of default type and return the created edge.

          GraphEdge createEdge
              GraphNode from
              GraphNode to

distances(from)

  Returns an array of shortest path lengths from this node to every other node in the graph.

          Array distances
              GraphNode from

## Graph Node

A node is the data element of a graph.

### Properties

- width :

  The size of this data element.

- x :

  The x-coordinate of this data element.

- y :

  The y-coordinate of this data element.

- id :

  The unique identifier of this data element.

- color :

  The color of this data element stated as hexadecimal value.

### Methods

neighbors()

  Return list all nodes connected to this node. This method respects if edges are directed.

          array neighbors

edges()

  Return a list of all edges (incoming and outgoing) of this node.

          array edges

edges(type)

  Return a list of all edges (incoming and outgoing) of this node of a specified type.

          array edges
              int type

inEdges()

  Return a list of incoming edges of this node.

          array inEdges

inEdges(type)

  Return a list of all incoming edges of this node of a specified type.

          array inEdges
              int type

outEdges()

  Return a list of all outgoing edges of this node.

          array outEdges

outEdges(type)

  Return a list of all outgoing edges of this node of a specified type.

          array outEdges
              int type

edgesTo(target)

  Return a list of all edges of this node to the specified node.

          array edgesTo
              GraphNode target

## Graph Edge

An Edge is the connection of two GraphNodes. Edges can be directed or undirected, depending on their type.

### Properties

- width :

  The width of the connection.

- directed :

  If true, the connection is directed. Otherwise is connection is undirected.

- from :

  Start of the connection.

- to :

  End of the connection

- color :

  ID of the connection type.

### Methods

remove()

  Remove this connection.

          void remove

add_property(name, value)

  Add a new property to the connection.

          void add_property
              string name
              string value

remove_property(name)

  Remove an existing property from the connection.

          void remove_property
              string name