Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Ganeti.HTools.Graph
Description
Algorithms on Graphs.
This module contains a few graph algorithms and the transoformations needed for them to be used on nodes.
For more information about Graph Coloring see: http://en.wikipedia.org/wiki/Graph_coloring http://en.wikipedia.org/wiki/Greedy_coloring
LF-coloring is described in: Welsh, D. J. A.; Powell, M. B. (1967), "An upper bound for the chromatic number of a graph and its application to timetabling problems", The Computer Journal 10 (1): 85-86, doi:10.1093comjnl10.1.85 http://comjnl.oxfordjournals.org/content/10/1/85
DSatur is described in: Brelaz, D. (1979), "New methods to color the vertices of a graph", Communications of the ACM 22 (4): 251-256, doi:10.1145/359094.359101 http://dx.doi.org/10.1145%2F359094.359101
Also interesting: Klotz, W. (2002). Graph coloring algorithms. Mathematics Report, Technical University Clausthal, 1-9. <http://www.math.tu-clausthal.de/Arbeitsgruppen/Diskrete-Optimierung publications2002/gca.pdf>
Synopsis
- type Color = Int
- type VertColorMap = IntMap Color
- type ColorVertMap = IntMap [Int]
- emptyVertColorMap :: VertColorMap
- colorInOrder :: Graph -> [Vertex] -> VertColorMap
- colorLF :: Graph -> VertColorMap
- colorDsatur :: Graph -> VertColorMap
- colorDcolor :: Graph -> VertColorMap
- isColorable :: Graph -> Bool
- colorVertMap :: VertColorMap -> ColorVertMap
- verticesByDegreeDesc :: Graph -> [Vertex]
- verticesByDegreeAsc :: Graph -> [Vertex]
- neighbors :: Graph -> Vertex -> [Vertex]
- hasLoop :: Graph -> Bool
- isUndirected :: Graph -> Bool
Types
type VertColorMap = IntMap Color #
Vertex to Color association.
type ColorVertMap = IntMap [Int] #
Color to Vertex association.
Creation
emptyVertColorMap :: VertColorMap #
Empty color map.
Coloring
colorInOrder :: Graph -> [Vertex] -> VertColorMap #
Color greedily all nodes in the given order.
colorLF :: Graph -> VertColorMap #
Color greedily all nodes, larger first.
colorDsatur :: Graph -> VertColorMap #
Color greedily all nodes, highest saturation, then highest degree. This is slower than "colorLF" as we must dynamically recalculate which node to color next among all remaining ones but produces better results.
colorDcolor :: Graph -> VertColorMap #
Color greedily all nodes, highest number of colored neighbors, then highest degree. This is slower than "colorLF" as we must dynamically recalculate which node to color next among all remaining ones but produces better results.
isColorable :: Graph -> Bool #
Check whether a graph is colorable.
Color map transformations
colorVertMap :: VertColorMap -> ColorVertMap #
ColorVertMap from VertColorMap.
Vertex characteristics
verticesByDegreeDesc :: Graph -> [Vertex] #
vertices of a graph, sorted by ascending degree.
verticesByDegreeAsc :: Graph -> [Vertex] #
vertices of a graph, sorted by descending degree.
isUndirected :: Graph -> Bool #
Check whether a graph is undirected