Compute the graph coloring. Assign a color to each vertex such that no adjacent vertices have the same color. Return a model object with total number of colors used as well as the color ID for each vertex in the graph. This algorithm is greedy and is not guaranteed to find the minimum graph coloring. It is also not deterministic, so successive runs may return different answers.
- graph : SGraph
The graph on which to compute the coloring.
- verbose : bool, optional
If True, print progress updates.
- out : GraphColoringModel
>>> g = turicreate.load_sgraph('http://snap.stanford.edu/data/email-Enron.txt.gz', format='snap') >>> gc = turicreate.graph_coloring.create(g)
We can obtain the
color idcorresponding to each vertex in the graph
>>> color_id = gc['color_id'] # SFrame
We can obtain the total number of colors required to color the graph
>>> num_colors = gc['num_colors']