Shared types and utilities for pathfinding algorithms.
Summary
Functions
Extracts nodes from a path.
Creates a path tuple from nodes and total weight.
Extracts total weight from a path.
Types
@type path(e) :: {:path, [Yog.node_id()], e}
Represents a path through the graph with its total weight.
Functions
@spec nodes(path(any())) :: [Yog.node_id()]
Extracts nodes from a path.
Examples
iex> path = Yog.Pathfinding.Utils.path([:a, :b, :c], 10)
iex> Yog.Pathfinding.Utils.nodes(path)
[:a, :b, :c]
@spec path([Yog.node_id()], any()) :: path(any())
Creates a path tuple from nodes and total weight.
Examples
iex> Yog.Pathfinding.Utils.path([:a, :b, :c], 10)
{:path, [:a, :b, :c], 10}
Extracts total weight from a path.
Examples
iex> path = Yog.Pathfinding.Utils.path([:a, :b, :c], 10)
iex> Yog.Pathfinding.Utils.total_weight(path)
10