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
-
Edge( from: key, to: key, label: option.Option(label), weight: option.Option(Float), )
Values
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)