First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

As long as you have tikz installed in your TeX installation, then sure, you can use tikz. See Sage's tutorial for information about how to tell Sage to use LaTeX to produce pictures in the notebook rather than jsMath or MathJax (these are the default, jsMath in older versions of Sage, MathJax in the most recent). Briefly:

from sage.graphs.graph_latex import setup_latex_preamble
setup_latex_preamble()
latex.add_to_jsmath_avoid_list('tikz')
view(g)

should do it. Read the referenced section of the tutorial and also the following section.

click to hide/show revision 2
No.2 Revision

As long as you have tikz installed in your TeX installation, then sure, you can use tikz. See Sage's tutorial for information about how to tell Sage to use LaTeX to produce pictures in the notebook rather than jsMath or MathJax (these are the default, jsMath in older versions of Sage, MathJax in the most recent). Briefly:

from sage.graphs.graph_latex import setup_latex_preamble
setup_latex_preamble()
latex.add_to_jsmath_avoid_list('tikz')
view(g)

should do it. Read the referenced section of the tutorial and also the following section.

Edit: using your vertex labels, I get a LaTeX error when I try this. So I modified your graph like this:

h1 = r"$\text{House 1}$"
h2 = r"$\text{House 2}$"
h3 = r"$\text{House 3}$"
w = r"$\text{Water}$"
e = r"$\text{Electricity}$"
ph = r"$\text{Phone Line}$"
f = {h1: [w, e, ph], h2: [w, e, ph], h3: [w, e]}
g = Graph(f)
from sage.graphs.graph_latex import setup_latex_preamble
setup_latex_preamble()
latex.extra_preamble()
latex.add_to_mathjax_avoid_list('tikz')
latex.engine('pdflatex')
view(g)

Unfortunately, with these vertex labels, g.plot(...) doesn't work anymore. There may be ways of tinkering with the graph to get both view (using LaTeX) and plot to work.