graphvix v0.5.0 Graphvix.Node

Graphvix.Node provides functions for adding, updating, and deleting nodes in a graph.

Summary

Functions

Deletes the node with the provided node_id

Find the node in the graph that has the provided node_id

Create a new node with the given attrs and attach it to the active graph

Update the attributes of the node with the provided node_id

Types

label()
label :: atom | String.t

Functions

delete(node_id)
delete(pos_integer) :: :ok

Deletes the node with the provided node_id.

This will also remove any edges attached to the node, and remove it from any clusters it belongs to.

iex> {n_id, n} = Node.new(label: "Start")
iex> Node.delete(n_id)
find(node_id)
find(pos_integer) :: map | nil

Find the node in the graph that has the provided node_id.

Returns the node, or nil if it is not found.

iex> n = Node.new(label: "Start")
iex> Node.find(n.id) #=> returns `n`
new(label_or_attrs \\ [])
new(label | Keyword.t | nil) :: {pos_integer, map}

Create a new node with the given attrs and attach it to the active graph.

Returns a tuple containing the new node’s id and its map representation.

iex> Node.new(label: "Start")
{1, %{ attrs: [label: "Start"] }}
update(node_id, attrs)
update(pos_integer, Keyword.t) :: :ok

Update the attributes of the node with the provided node_id.

If nil is passed as a value in the attrs keyword list, it will remove the key entirely from the node’s attributes.

iex> n = Node.new(label: "Start")
iex> Node.update(n.id, color: "blue", label: nil)