graphvix v0.4.0 Graphvix.Cluster

Graphvix.Cluster provides functions for adding, updating, and deleting clusters in a graph.

Summary

Functions

Adds a node or nodes to an existing cluster

Deletes the cluster with the provided cluster_id

Find the cluster in the graph that has the provided cluster_id

Create a new cluster

Removes a node or nodes from an existing cluster

Types

node_id_or_ids()
node_id_or_ids :: pos_integer | [pos_integer]

Functions

add(cluster_id, nodes)
add(pos_integer, node_id_or_ids) :: map

Adds a node or nodes to an existing cluster.

iex> {c_id, c} = Cluster.new
iex> {n_id, n} = Node.new
iex> {n2_id, n2} = Node.new

# Adding a single node
iex> Cluster.add(c_id, n_id)

# Adding multiple nodes
iex> Cluster.add(c_id, [n_id, n2_id])
delete(cluster_id)
delete(pos_integer) :: :ok

Deletes the cluster with the provided cluster_id.

iex> {c_id, c} = Cluster.new
iex> Cluster.delete(c_id)
find(cluster_id)
find(pos_integer) :: map | nil

Find the cluster in the graph that has the provided cluster_id.

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

iex> {c_id, c} = Cluster.new
iex> Cluster.find(c_id) #=> returns `c`
new(nodes \\ [])
new(node_id_or_ids | nil) :: {pos_integer, map}

Create a new cluster.

The cluster is empty by default, but can be provided with nodes already part of it.

iex> {n_id, n} = Node.new
iex> {n2_id, n2} = Node.new

# Passing no node ids
iex> Cluster.new
{3, %{ node_ids: [] }

# Passing a single node id
iex> Cluster.new(n_id)
{3, %{ node_ids: [1] }

# Passing multiple node ids
iex> Cluster.new([n_id, n2_id])
{3, %{ node_ids: [1, 2] }
remove(cluster_id, nodes)
remove(pos_integer, node_id_or_ids) :: map

Removes a node or nodes from an existing cluster.

iex> {n_id, n} = Node.new
iex> {n2_id, n2} = Node.new
iex> {c_id, c} = Cluster.new([n_id, n2_id])

# Removing a single node
iex> Cluster.remove(c_id, n_id)

# Removing multiple nodes
iex> Cluster.remove(c_id, [n_id, n2_id])