Yog.Pathfinding.Utils (YogEx v0.70.0)

Copy Markdown View Source

Shared types and utilities for pathfinding algorithms.

Summary

Types

Represents a path through the graph with its total weight.

Functions

Extracts nodes from a path.

Creates a path tuple from nodes and total weight.

Extracts total weight from a path.

Types

path(e)

@type path(e) :: {:path, [Yog.node_id()], e}

Represents a path through the graph with its total weight.

Functions

nodes(arg)

@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]

path(nodes, total_weight)

@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}

total_weight(arg)

@spec total_weight(path(any())) :: any()

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