This library uses the LaTeX package pgf/tikz to produce graphs. It integrates with IJulia, outputting SVG images to the notebook.
Pkg.add("Images")
Pkg.clone("https://github.com/sisl/TikzPictures.jl")
Pkg.clone("https://github.com/sisl/TikzGraphs.jl")
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:
using TikzGraphs
using TikzGraphs
using TikzPictures
using Graphs
g = simple_graph(4)
add_edge!(g, 1, 2)
add_edge!(g, 2, 3)
add_edge!(g, 3, 4)
add_edge!(g, 1, 4)
TikzGraphs.plot(g) # You can just use plot(g) if TikzGraphs was loaded after Graphs
You can save your graphs to PDF, SVG, and TEX.
t = TikzGraphs.plot(g)
save(PDF("graph"), t)
save(SVG("graph"), t)
save(TEX("graph"), t)
You can also specify the labels.
TikzGraphs.plot(g, ["A", "B", "C", "D"])
You can use different layouts (currently just Layered [default] and Spring are supported).
TikzGraphs.plot(g, Layouts.Spring())
Gradually, more functionality from pgf/tikz will be migrated into this package. Eventually, this package will support different layout options, annotations, styles, etc.