aonyx/graph/edge

Types

Represents an edge going from one node to another.

pub type Edge(key, label) {
  Edge(
    from: key,
    to: key,
    label: option.Option(label),
    weight: option.Option(Float),
  )
}

Constructors

pub type EdgeKey(key) {
  EdgeKey(from: key, to: key)
}

Constructors

  • EdgeKey(from: key, to: key)

Values

pub fn get_key(edge: Edge(key, label)) -> EdgeKey(key)

Extracts the key from an edge.

pub fn new(from: key, to: key) -> Edge(key, label)

Creates an edge with the given from and to node keys, without label or weight.

Examples

new("A", "B")
// -> Edge(from: "A", to: "B", label: None, weight: None)
pub fn with_label(
  edge: Edge(key, label),
  label: label,
) -> Edge(key, label)

Sets the label of an edge.

Examples

new("A", "B") |> with_label("connects to")
// -> Edge(from: "A", to: "B", label: Some("connects to"), weight: None)
pub fn with_weight(
  edge: Edge(key, label),
  weight: Float,
) -> Edge(key, label)

Sets the weight of an edge.

Examples

new("A", "B") |> with_weight(5.0)
// -> Edge(from: "A", to: "B", label: None, weight: Some(5.0))
pub fn without_label(edge: Edge(key, label)) -> Edge(key, label)

Clears the label of an edge.

Examples

let edge = new("A", "B") |> with_label("connects to")
without_label(edge)
// -> Edge(from: "A", to: "B", label: None, weight: None)
pub fn without_weight(edge: Edge(key, label)) -> Edge(key, label)

Clears the weight of an edge.

Examples

let edge = new("A", "B") |> with_weight(5.0)
without_weight(edge)
// -> Edge(from: "A", to: "B", label: None, weight: None)
Search Document