Skip to content
/ nx2tikz Public

Export NetworkX graphs to TikZ directly

License

Notifications You must be signed in to change notification settings

johnyf/nx2tikz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

nx2tikz is a package for exporting networkx graphs directly to TikZ, letting TikZ itself layout the graph. Its purpose is to avoid the pydot -> GraphViz -> dot2tex -> dot2texi toolchain, because it is very fragile and inflexible.

Usage

Either import nx2tikz or invoke it from the command line. The input is a Python module that contains a function graph that returns a networkx graph.

To write a tikzpicture as a file:

nx2tikz --input example.py --output out.tex --format tikz

When you include such pictures in your main document, remember to import the necessary TikZ packages in the preamble, and compile with LuaTeX.

To compile with lualatex an image as a PDF file:

nx2tikz --input example.py --output out --format pdf

Installation

Use setuptools:

python setup.py install

the package can be imported, or invoked from the command line as nx2tikz (creates an entry point).

References

[1] Jannis Pohlmann Configurable graph drawing algorithms for the TikZ graphics description language Diplomarbeit, Universitat zu Lubeck, 2011

[2] Till Tantau Graph drawing in TikZ Journal of graph algorithms and applications Vol.17, No.4, pp.495--513, 2013 DOI:10.7155/jgaa.00301 slides

License

BSD-3, see LICENSE file.