GRAPH COLORING
----------------------------------------------------------------------
# M COLORING PROBLEM

from graphtheory.structures.edges import Edge
from graphtheory.structures.graphs import Graph
from graphtheory.coloring.nodecolorbt import BacktrackingNodeColoring

G = Graph()
# Add nodes and edges here.
# Set m_colors.
algorithm = BacktrackingNodeColoring(G, m_colors)
algorithm.run()
for node in G.iternodes():
    print ( "{} {}".format(node, algorithm.color[node]) )
----------------------------------------------------------------------
# VERTEX COLORING

from graphtheory.structures.edges import Edge
from graphtheory.structures.graphs import Graph
from graphtheory.coloring.nodecolorexact import ExactNodeColoring
from graphtheory.coloring.nodecolorus import UnorderedSequentialNodeColoring
from graphtheory.coloring.nodecolorrs import RandomSequentialNodeColoring
from graphtheory.coloring.nodecolorcs import ConnectedSequentialNodeColoring
from graphtheory.coloring.nodecolorsl import SmallestLastNodeColoring
from graphtheory.coloring.nodecolorlf import LargestFirstNodeColoring
from graphtheory.coloring.nodecolorslf import SLFNodeColoring
from graphtheory.coloring.nodecolorgis import GISNodeColoring
from graphtheory.coloring.nodecolorrlf import RLFNodeColoring
from graphtheory.coloring.nodecolorbrooks import BrooksNodeColoring

G = Graph()
# Add nodes and edges here.
# algorithm = ExactlNodeColoring(G)
# algorithm = UnorderedSequentialNodeColoring(G)
# algorithm = RandomSequentialNodeColoring(G)
# algorithm = ConnectedSequentialNodeColoring(G)
# algorithm = SmallestLastNodeColoring(G)
# algorithm = LargestFirstNodeColoring(G)
# algorithm = SLFNodeColoring(G)
# algorithm = GISNodeColoring(G)
# algorithm = RLFNodeColoring(G)
algorithm = BrooksNodeColoring(G)
algorithm.run()
for node in G.iternodes():
    print ( "{} {}".format(node, algorithm.color[node]) )
----------------------------------------------------------------------
# EDGE COLORING

from graphtheory.structures.edges import Edge
from graphtheory.structures.graphs import Graph
from graphtheory.coloring.edgecolorus import UnorderedSequentialEdgeColoring
from graphtheory.coloring.edgecolorrs import RandomSequentialEdgeColoring
from graphtheory.coloring.edgecolorrs import ConnectedSequentialEdgeColoring
from graphtheory.coloring.edgecolorlg import EdgeColoringWithLineGraph
from graphtheory.coloring.edgecolorntl import NTLEdgeColoring

G = Graph()
# Add nodes and edges here.
# algorithm = UnorderedSequentialEdgeColoring(G)
# algorithm = RandomSequentialEdgeColoring(G)
# algorithm = ConnectedSequentialEdgeColoring(G)
# algorithm = EdgeColoringWithLineGraph(G)
algorithm = NTLEdgeColoring(G)   # use Delta or Delta+1 colors
algorithm.run()
algorithm.show_colors()
for edge in G.iteredges():
    print ( "{} {}".format(edge, algorithm.color[edge]) )

# Edge coloring for complete graphs.
from graphtheory.structures.factory import GraphFactory
from graphtheory.coloring.edgecolorcomplete import CompleteGraphEdgeColoring
gf = GraphFactory(Graph)
G = gf.make_complete(10)   # K_10 graph
algorithm = CompleteGraphEdgeColoring(G)
algorithm.run()
algorithm.show_colors()
----------------------------------------------------------------------
EOF
