fgl-5.8.3.0: Martin Erwig's Functional Graph Library

Safe Haskell | Safe-Inferred
Language | Haskell98

Data.Graph.Inductive.Query.SP

Description

Shortest path algorithms

Synopsis

- spTree :: (Graph gr, Real b) => Node -> gr a b -> LRTree b
- sp :: (Graph gr, Real b) => Node -> Node -> gr a b -> Maybe Path
- spLength :: (Graph gr, Real b) => Node -> Node -> gr a b -> Maybe b
- dijkstra :: (Graph gr, Real b) => Heap b (LPath b) -> gr a b -> LRTree b
- type LRTree a = [LPath a]
- data Heap a b

# Documentation

spTree :: (Graph gr, Real b) => Node -> gr a b -> LRTree b Source #

Tree of shortest paths from a certain node to the rest of the (reachable) nodes.

Corresponds to `dijkstra` applied to a heap in which the only known node is the starting node, with a path of length 0 leading to it.

The edge labels of type `b` are the edge weights; negative edge weights are not supported.

sp Source #

Arguments

:: (Graph gr, Real b) |
=> Node | Start
-> Node | Destination
-> gr a b |
-> Maybe Path |

Shortest path between two nodes, if any.

Returns `Nothing` if the destination is not reachable from the start node, and ``Just` path` otherwise.

The edge labels of type `b` are the edge weights; negative edge weights are not supported.

spLength Source #

Arguments

:: (Graph gr, Real b) |
=> Node | Start
-> Node | Destination
-> gr a b |
-> Maybe b |

Length of the shortest path between two nodes, if any.

Returns `Nothing` if there is no path, and ``Just` length` otherwise.

The edge labels of type `b` are the edge weights; negative edge weights are not supported.

dijkstra Source #

Arguments

:: (Graph gr, Real b) |
=> Heap b (LPath b) | Initial heap of known paths and their lengths.
-> gr a b |
-> LRTree b |

Dijkstra's shortest path algorithm.

The edge labels of type `b` are the edge weights; negative edge weights are not supported.

type LRTree a = [LPath a] Source #

data Heap a b Source #

#### Instances

Instances details

(Read a, Read b) => Read (Heap a b) Source # |
Instance details Defined in Data.Graph.Inductive.Internal.Heap Methods readsPrec :: Int -> ReadS (Heap a b) Source # readList :: ReadS [Heap a b] Source # readPrec :: ReadPrec (Heap a b) Source # readListPrec :: ReadPrec [Heap a b] Source #
(Show a, Show b) => Show (Heap a b) Source # |
Instance details Defined in Data.Graph.Inductive.Internal.Heap Methods showsPrec :: Int -> Heap a b -> ShowS Source # show :: Heap a b -> String Source # showList :: [Heap a b] -> ShowS Source #
(NFData a, NFData b) => NFData (Heap a b) Source # |
Instance details Defined in Data.Graph.Inductive.Internal.Heap Methods rnf :: Heap a b -> () Source #
(Eq a, Eq b) => Eq (Heap a b) Source # |
Instance details Defined in Data.Graph.Inductive.Internal.Heap Methods (==) :: Heap a b -> Heap a b -> Bool Source # (/=) :: Heap a b -> Heap a b -> Bool Source #