# Revision history [back]

### Graph coloring and sagetex

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?

 2 retagged FrédéricC 4968 ●3 ●41 ●107

### Graph coloring and sagetex

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?