Graph coloring and sagetex

asked 2014-04-08 02:22:55 +0200

dazedANDconfused gravatar image

updated 2015-01-14 14:06:43 +0200

FrédéricC gravatar image

If I type this code into a Sage Cell Server, I get a coloring of graph:

from sage.graphs.graph_coloring import vertex_coloring
g = graphs.Grid2dGraph(3,3)
p = g.coloring()
g.show(dist=1,vertex_size=250, graph_border=False, figsize=[15,15],partition=p)

I want to get a nice looking version into a LaTeX document using sagetex. When I type this inside a sagesilent block:

from sage.graphs.graph_coloring import vertex_coloring
g = graphs.Grid2dGraph(3,3)
p = g.coloring()
g.set_latex_options(graphic_size=(5,5), tkz_style = 'Custom',vertex_size = 0.2, edge_thickness = 0.04, edge_color = 'black',vertex_labels=False)

and then call: \sage{g} outside of the sagesilent block, the graph is no longer colored. I tried lots of variations, such as \sage{g.show(partitions=True)} but with no success. What's the correct way to get the graph coloring to show up in the LaTeX document?

edit retag flag offensive close merge delete