Module cluster

Implements a cluster of nodes.

Copyright © (C) 2015, Pablo Lamela, Simon Thompson

Authors: Pablo Lamela Seijas (P.Lamela-Seijas@kent.ac.uk), Simon Thompson (S.J.Thompson@kent.ac.uk).

Description

Implements a cluster of nodes. The clusters save information about which parent-child relationships between its nodes. Clusters are assumed to have tree hierarchy (no loops), and, as such, a single root.

Data Types

cluster()

abstract datatype: cluster(NodeType)

Function Index

get_nodes/1 Returns a set with all the nodes in the Cluster.
get_root/1 Returns the root node of the Cluster.
has_node/2 Returns a boolean that indicates whether the Cluster contains the Node.
is_indirection_cluster/1 Returns whether the cluster is an indirection "fake" cluster or not.
make_indirection_cluster/0 Creates an indirection "fake" cluster.
merge_clusters/2 Takes two clusters and returns a new cluster containing all the nodes or the atom disjoint if they have no common nodes.
new_cluster/1 Creates a cluster with a single node.
new_parent_child_to_cluster/2 Creates a cluster with a Node and its ParentNode.
remove_split/2 Removes the Node from the Cluster an returns the resulting subclusters created, (those that were hold together by the removed node).
show_cluster/1 Returns a more readable version of custers.
show_cluster/2 Returns a more readable version of custers and takes a function that is suppoused to make the nodes in the clusters more readable.
size/1 Returns the number of nodes that the cluster has.

Function Details

get_nodes/1

get_nodes(Cluster::cluster(NodeType)) -> [NodeType]

Returns a set with all the nodes in the Cluster.

get_root/1

get_root(Cluster::cluster(NodeType)) -> OutNode::NodeType

Returns the root node of the Cluster.

has_node/2

has_node(Node::NodeType, Cluster::cluster(NodeType)) -> boolean()

Returns a boolean that indicates whether the Cluster contains the Node.

is_indirection_cluster/1

is_indirection_cluster(X1::cluster(term())) -> false | {true, reference()}

Returns whether the cluster is an indirection "fake" cluster or not.

make_indirection_cluster/0

make_indirection_cluster() -> {reference(), cluster(term())}

Creates an indirection "fake" cluster.

merge_clusters/2

merge_clusters(Cluster::cluster(Node), X2::cluster(Node)) -> {ok, cluster(Node)} | disjoint

Takes two clusters and returns a new cluster containing all the nodes or the atom disjoint if they have no common nodes. It assumes that the clusters contain subtrees that belong to global tree, and, as such, nor the individual clusters nor the result cluster should contain any loops, and no node should have several parents.

new_cluster/1

new_cluster(Node::NodeType) -> cluster(NodeType)

Creates a cluster with a single node.

new_parent_child_to_cluster/2

new_parent_child_to_cluster(Node::N, Node::N) -> cluster(N)

Creates a cluster with a Node and its ParentNode.

remove_split/2

remove_split(Node::NodeType, Cluster::cluster(NodeType)) -> [cluster(NodeType)]

Removes the Node from the Cluster an returns the resulting subclusters created, (those that were hold together by the removed node).

show_cluster/1

show_cluster(Clus::cluster(term())) -> #{}

Returns a more readable version of custers. This is done by transforming dicts and sets into lists.

show_cluster/2

show_cluster(Fun::fun((NodeType) -> any()), Cluster::cluster(NodeType)) -> #{}

Returns a more readable version of custers and takes a function that is suppoused to make the nodes in the clusters more readable. This is done by transforming dicts and sets into lists and by applying the supplied function to the nodes.

size/1

size(Cluster::cluster(term())) -> non_neg_integer()

Returns the number of nodes that the cluster has.


Generated by EDoc, Nov 5 2015, 16:30:19.