Copyright | Copyright © 2018 Kadena LLC. |
---|---|
License | MIT |
Maintainer | Lars Kuhtz <lars@kadena.io> |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
TODO
Synopsis
- type DenseAdjMatrix = Array U Ix2 Int
- type AdjacencySets = HashMap Int (HashSet Int)
- fromAdjacencySets :: AdjacencySets -> DenseAdjMatrix
- toAdjacencySets :: DenseAdjMatrix -> AdjacencySets
- newtype ShortestPathMatrix = ShortestPathMatrix (Array U Ix2 (Double, Int))
- floydWarshall :: Unbox a => Real a => Array U Ix2 a -> ShortestPathMatrix
- shortestPath :: ShortestPathMatrix -> Int -> Int -> Maybe [Int]
- distance :: ShortestPathMatrix -> Int -> Int -> Maybe Double
- diameter :: ShortestPathMatrix -> Maybe Double
- distMatrix_ :: Source r Ix2 Int => Array r Ix2 Int -> Array D Ix2 Double
- floydWarshall_ :: Array U Ix2 Double -> Array U Ix2 Double
- diameter_ :: Array U Ix2 Int -> Maybe Natural
- shortestPaths_ :: Array U Ix2 Int -> Array U Ix2 Double
Graph Representations
type AdjacencySets = HashMap Int (HashSet Int) Source #
Adjacency set representation of a directed graph.
Conversions
fromAdjacencySets :: AdjacencySets -> DenseAdjMatrix Source #
Assumes that the input is an undirected graph and that the vertex set is a prefix of the natural numbers.
toAdjacencySets :: DenseAdjMatrix -> AdjacencySets Source #
Converts an adjacency matrix into a graph in adjacnency set representation.
FloydWarshall Algorithm
newtype ShortestPathMatrix Source #
Shortest path matrix of a graph.
Instances
floydWarshall :: Unbox a => Real a => Array U Ix2 a -> ShortestPathMatrix Source #
Shortest path computation for integral matrixes.
shortestPath :: ShortestPathMatrix -> Int -> Int -> Maybe [Int] Source #
Compute a shortest path between two vertices of a graph from the shortest path matrix of the graph.
distance :: ShortestPathMatrix -> Int -> Int -> Maybe Double Source #
Compute the distance between two vertices of a graph from the shortest path matrix of the graph.
diameter :: ShortestPathMatrix -> Maybe Double Source #
Compute the diameter of a graph from the shortest path matrix of the graph.
Legacy exports
distMatrix_ :: Source r Ix2 Int => Array r Ix2 Int -> Array D Ix2 Double Source #
Floyd Warshall Without Paths (more efficient, by factor of 2).