aonyx/graph/node

Types

Represents a node in the graph identified by a key and containing an optional value.

pub type Node(key, value) {
  Node(
    key: key,
    value: option.Option(value),
    outgoing: set.Set(key),
    incoming: set.Set(key),
  )
}

Constructors

  • Node(
      key: key,
      value: option.Option(value),
      outgoing: set.Set(key),
      incoming: set.Set(key),
    )
pub type NodeKey(key) {
  NodeKey(key: key)
}

Constructors

  • NodeKey(key: key)

Values

pub fn get_key(node: Node(a, b)) -> NodeKey(a)

Extracts the key from a node.

pub fn get_neighbors(node: Node(a, b)) -> Set(a)

Returns a set union of keys of all direct neighbors of a given node in both directions.

pub fn get_neighbors_in(node: Node(a, b)) -> Set(a)

Returns a set of keys of all direct neighbors of a given node via incoming edges.

pub fn get_neighbors_out(node: Node(a, b)) -> Set(a)

Returns a set of keys of all direct neighbors of a given node via outgoing edges.

pub fn new(key: a) -> Node(a, b)

Creates a node with the given key, without a value.

pub fn with_incoming(
  node: Node(a, b),
  incoming: List(a),
) -> Node(a, b)

Sets the incoming edges of a node.

pub fn with_outgoing(
  node: Node(a, b),
  outgoing: List(a),
) -> Node(a, b)

Sets the outgoing edges of a node.

pub fn with_value(node: Node(a, b), value: b) -> Node(a, b)

Sets the value of a node.

pub fn without_value(node: Node(a, b)) -> Node(a, b)

Clears the value of a node.

Search Document