This library uses the LaTeX package pgf/tikz to produce graphs. It integrates with IJulia, outputting SVG images to the notebook.
In [ ]:
Pkg.add("TikzGraphs")
In addition, you will need to install the following dependencies if you do not already have them on your system.
sudo apt-get install pdf2svg
. On Windows, you can download the binaries from http://www.cityinthesky.co.uk/opensource/pdf2svg/. Be sure to add pdf2svg to your path (and restart).Once these things are installed, you should be able to run the following:
In [1]:
using TikzGraphs
In [2]:
using TikzGraphs
using LightGraphs
g = DiGraph(4)
add_edge!(g, 1, 2)
add_edge!(g, 2, 3)
TikzGraphs.plot(g)
Out[2]:
In [3]:
add_edge!(g, 3, 4)
add_edge!(g, 1, 4)
TikzGraphs.plot(g)
Out[3]:
You can save your graphs to PDF, SVG, and TEX.
In [4]:
t = TikzGraphs.plot(g)
using TikzPictures # this is required for saving
TikzPictures.save(PDF("graph"), t)
TikzPictures.save(SVG("graph"), t)
TikzPictures.save(TEX("graph"), t)
You can also specify the labels.
In [5]:
TikzGraphs.plot(g, ["A", "B", "C", "D"])
Out[5]:
You can even use unicode.
In [6]:
TikzGraphs.plot(g, ["α", "β", "γ", "δ"])
Out[6]:
You can also have latex labels.
In [7]:
TikzGraphs.plot(g, [L"\int_0^\infty f(x) dx", L"\sqrt{2}", L"x^2", L"\frac{1}{2}"])
Out[7]:
You can have repeated labels.
In [8]:
TikzGraphs.plot(g, ["α", "β", "γ", "α"])
Out[8]:
You can use different layouts (currently just Layered [default], Spring, and SimpleNecklace are supported).
In [9]:
TikzGraphs.plot(g, Layouts.Spring())
Out[9]:
In [10]:
TikzGraphs.plot(g, Layouts.SimpleNecklace())
Out[10]:
Gradually, more functionality from pgf/tikz will be migrated into this package. Eventually, this package will support different layout options, annotations, styles, etc.