Zog.Pathfinding (Zog v0.1.0)

View Source

Native pathfinding algorithms backed by Zog (Zig) via Zigler.

Summary

Functions

Computes the shortest path and its weight between two nodes using the A* algorithm.

Computes the shortest path and its weight between two nodes using Bellman-Ford algorithm.

Computes the shortest path and its weight between two nodes using Dijkstra's algorithm.

Computes all-pairs shortest paths using the Floyd-Warshall algorithm.

Checks if a target node is reachable from a start node using BFS traversal.

Computes all-pairs shortest paths using Johnson's Algorithm.

Functions

astar(builder, start_label, goal_label, x_coords, y_coords, heuristic \\ :euclidean)

@spec astar(
  Zog.SoA.t(),
  Zog.SoA.label(),
  Zog.SoA.label(),
  map() | list(),
  map() | list(),
  atom()
) ::
  {:ok, {[Zog.SoA.label()], float()}} | {:error, :no_path}

Computes the shortest path and its weight between two nodes using the A* algorithm.

bellman_ford(builder, start_label, goal_label)

@spec bellman_ford(Zog.SoA.t(), Zog.SoA.label(), Zog.SoA.label()) ::
  {:ok, {[Zog.SoA.label()], float()}}
  | {:error, :no_path}
  | {:error, :negative_cycle}

Computes the shortest path and its weight between two nodes using Bellman-Ford algorithm.

dijkstra(builder, start_label, goal_label)

@spec dijkstra(Zog.SoA.t(), Zog.SoA.label(), Zog.SoA.label()) ::
  {:ok, {[Zog.SoA.label()], float()}} | {:error, :no_path}

Computes the shortest path and its weight between two nodes using Dijkstra's algorithm.

floyd_warshall(builder)

@spec floyd_warshall(Zog.SoA.t()) ::
  {:ok, [[float() | :infinity]]} | {:error, :negative_cycle}

Computes all-pairs shortest paths using the Floyd-Warshall algorithm.

floyd_warshall(arg1, arg2, arg3, arg4)

@spec floyd_warshall(
  0..18_446_744_073_709_551_615,
  [0..4_294_967_295] | <<_::_*32>>,
  [0..4_294_967_295] | <<_::_*32>>,
  [float()] | <<_::_*64>>
) :: term()

is_reachable(builder, start_label, goal_label)

@spec is_reachable(Zog.SoA.t(), Zog.SoA.label(), Zog.SoA.label()) :: boolean()

Checks if a target node is reachable from a start node using BFS traversal.

johnsons(builder)

@spec johnsons(Zog.SoA.t()) ::
  {:ok, [[float() | :infinity]]} | {:error, :negative_cycle}

Computes all-pairs shortest paths using Johnson's Algorithm.

johnsons(arg1, arg2, arg3, arg4)

@spec johnsons(
  0..18_446_744_073_709_551_615,
  [0..4_294_967_295] | <<_::_*32>>,
  [0..4_294_967_295] | <<_::_*32>>,
  [float()] | <<_::_*64>>
) :: term()

nif_astar(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)

@spec nif_astar(
  0..18_446_744_073_709_551_615,
  [0..4_294_967_295] | <<_::_*32>>,
  [0..4_294_967_295] | <<_::_*32>>,
  [float()] | <<_::_*64>>,
  0..4_294_967_295,
  0..4_294_967_295,
  [float()] | <<_::_*64>>,
  [float()] | <<_::_*64>>,
  term()
) :: term()

nif_bellman_ford(arg1, arg2, arg3, arg4, arg5, arg6)

@spec nif_bellman_ford(
  0..18_446_744_073_709_551_615,
  [0..4_294_967_295] | <<_::_*32>>,
  [0..4_294_967_295] | <<_::_*32>>,
  [float()] | <<_::_*64>>,
  0..4_294_967_295,
  0..4_294_967_295
) :: term()

nif_dijkstra(arg1, arg2, arg3, arg4, arg5, arg6)

@spec nif_dijkstra(
  0..18_446_744_073_709_551_615,
  [0..4_294_967_295] | <<_::_*32>>,
  [0..4_294_967_295] | <<_::_*32>>,
  [float()] | <<_::_*64>>,
  0..4_294_967_295,
  0..4_294_967_295
) :: term()

nif_is_reachable(arg1, arg2, arg3, arg4, arg5, arg6)

@spec nif_is_reachable(
  0..18_446_744_073_709_551_615,
  [0..4_294_967_295] | <<_::_*32>>,
  [0..4_294_967_295] | <<_::_*32>>,
  [float()] | <<_::_*64>>,
  0..4_294_967_295,
  0..4_294_967_295
) :: term()