From 295750603d878669a2e32e1a28279954d1440f88 Mon Sep 17 00:00:00 2001 From: James Foster <38274066+jd-foster@users.noreply.github.com> Date: Thu, 21 Nov 2024 22:15:32 +1100 Subject: [PATCH] Add section on utility functions for paths (#409) Give short descriptions of utility functions (as mentioned in the first paragraph) that complement the main shortest path algorithms. --- docs/src/first_steps/paths_traversal.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/src/first_steps/paths_traversal.md b/docs/src/first_steps/paths_traversal.md index 573f5a95b..5cdaca79a 100644 --- a/docs/src/first_steps/paths_traversal.md +++ b/docs/src/first_steps/paths_traversal.md @@ -33,11 +33,17 @@ The following properties always hold for shortest path algorithms implemented he - The distance from a vertex to itself is always `0`. - The distance between two vertices with no connecting edge is always `Inf` or `typemax(eltype(distmx))`. -The [`dijkstra_shortest_paths`](@ref), [`desopo_pape_shortest_paths`](@ref), [`floyd_warshall_shortest_paths`](@ref), [`bellman_ford_shortest_paths`](@ref), and [`yen_k_shortest_paths`](@ref) functions return path states (subtypes of `Graphs.AbstractPathState`) that contain various information about the graph learned during traversal. +The [`dijkstra_shortest_paths`](@ref), [`desopo_pape_shortest_paths`](@ref), [`floyd_warshall_shortest_paths`](@ref), [`bellman_ford_shortest_paths`](@ref), and [`yen_k_shortest_paths`](@ref) functions return _path states_ (subtypes of `Graphs.AbstractPathState`) that contain various information about the graph learned during traversal. The corresponding state types (with the exception of `YenState`) have the following common fields: - `state.dists` holds a vector with the distances computed, indexed by source vertex. - `state.parents` holds a vector of parents of each vertex on the shortest paths (the parent of a source vertex is always `0`). `YenState` substitutes `.paths` for `.parents`. -In addition, with the appropriate optional arguments, [`dijkstra_shortest_paths`](@ref) will return information on all possible shortest paths available from the source. \ No newline at end of file +In addition, with the appropriate optional arguments, [`dijkstra_shortest_paths`](@ref) will return information on all possible shortest paths available from the source. + +## Utility functions + +- Once a path state is found using a shortest path algorithm, some or all of the paths can be obtained using [`enumerate_paths`](@ref). +- A longest path within a directed acyclic graph can be found with [`dag_longest_path`](@ref). +- In the case of a graph with some edges having negative weights, the existence of a cycle whose edges sum to a negative value can be detected with [`has_negative_edge_cycle_spfa`](@ref).