{"id":16976270,"url":"https://github.com/johnyf/nx2tikz","last_synced_at":"2025-03-22T14:31:52.147Z","repository":{"id":19916395,"uuid":"23182207","full_name":"johnyf/nx2tikz","owner":"johnyf","description":"Export NetworkX graphs to TikZ directly","archived":false,"fork":false,"pushed_at":"2024-10-23T13:49:01.000Z","size":34,"stargazers_count":30,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-18T12:03:30.211Z","etag":null,"topics":["graphs","networkx","tikz"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johnyf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-21T09:51:43.000Z","updated_at":"2025-03-11T16:26:02.000Z","dependencies_parsed_at":"2022-07-13T23:10:38.218Z","dependency_job_id":null,"html_url":"https://github.com/johnyf/nx2tikz","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnyf%2Fnx2tikz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnyf%2Fnx2tikz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnyf%2Fnx2tikz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnyf%2Fnx2tikz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnyf","download_url":"https://codeload.github.com/johnyf/nx2tikz/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244972307,"owners_count":20540957,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphs","networkx","tikz"],"created_at":"2024-10-14T01:25:32.005Z","updated_at":"2025-03-22T14:31:51.819Z","avatar_url":"https://github.com/johnyf.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"About\n=====\n\n`nx2tikz` is a package for exporting [`networkx`](https://networkx.org)\ngraphs directly to [`TikZ`](https://en.wikipedia.org/wiki/PGF/TikZ), letting\n[`TikZ` itself layout the graph](https://doi.org/10.7155/jgaa.00301).\nThe generated TikZ code can be typeset using [LuaTeX](\n    https://en.wikipedia.org/wiki/LuaTeX).\nThe package can be used to convert a `networkx` graph to:\n- a PDF depicting the graph\n- LaTeX code for a `tikzpicture`, containing TikZ code describing the graph\n  (to be included in a LaTeX document)\n- LaTeX code for a complete LaTeX document,\n  containing TikZ code describing the graph\n\nThese are possible via two interfaces:\n- from Python by calling functions from `nx2tikz`, with a `networkx` graph\n  as argument\n- from the command line, by passing the name of a Python script that contains\n  a function that returns a `networkx` graph\n\nThe purpose of package `nx2tikz` is to avoid the:\ndump DOT file -\u003e\n[`GraphViz`](https://en.wikipedia.org/wiki/PGF/TikZ) -\u003e\n[`dot2tex`](https://github.com/kjellmf/dot2tex) -\u003e\n[`dot2texi`](https://github.com/kjellmf/dot2texisty) toolchain,\nbecause it is fragile.\n\n\nUsage\n=====\n\nThe package can be:\n- imported in Python, or\n- invoked from the command line.\n\n\n## using `nx2tikz` from Python\n\nThe Python package can be imported with\n\n```python\nimport nx2tikz\n```\n\nAssuming that `g` is an instance of a `networkx` graph, the following are\navailable:\n- `nx2tikz.dumps_tikz(g)` returns as string the code of a `tikzpicture`\n  environment that contains TikZ code describing the graph\n- `nx2tikz.dump_tikz(g, filename)` creates a file named `filename` that\n  contains the code of a `tikzpicture` environment that describes the graph\n- `nx2tikz.dump_pdf(g, filename)` creates a PDF file named `filename` that\n  contains a diagram of the graph. It calls `lualatex` to typeset the PDF file.\n\nRead also the docstrings of these functions for more information.\n\nAnother useful function is `nx2tikz.nx2tikz.dump_tex()`, which creates a LaTeX\nfile for a document to typeset a diagram of the graph (includes preamble).\n\n\n## using `nx2tikz` from the command line\n\nThe input on the command line is a Python module that contains a function\nnamed `graph`. The function `graph` should return a `networkx` graph.\n\nTo write a `tikzpicture` as a file:\n\n```shell\nnx2tikz --input example.py --output out.tex --format tikz\n```\n\nWhen you include such pictures in your main document, remember to import the\nnecessary TikZ packages in the preamble, for example:\n\n```latex\n\\usepackage{tikz}\n\\usetikzlibrary{graphs,graphs.standard,graphdrawing,quotes,shapes}\n\\usegdlibrary{force}\n```\n\nand compile with `lualatex`.\n\nTo directly compile with `lualatex` an image as a PDF file:\n\n```shell\nnx2tikz --input example.py --output out --format pdf\n```\n\nTo dump an entire LaTeX document, complete with preamble:\n\n```shell\nnx2tikz --input example.py --output out.tex --format tex\n```\n\nAn example for using `nx2tikz` is the Python script `examples/example.py`.\n\n\nInstallation\n============\n\nUsing [`pip`](https://pip.pypa.io):\n\n```shell\npip install .\n```\n\nThe package also installs in Python's `bin/` directory a script named `nx2tikz`\nas [entry point](\n    https://setuptools.readthedocs.io/en/latest/userguide/entry_point.html).\nThis script can be invoked from the command line, for example:\n\n```shell\nnx2tikz -h\n```\n\n\nReferences\n==========\n\n[1] Jannis Pohlmann\n    [Configurable graph drawing algorithms for the TikZ graphics description language](\n        https://www.tcs.uni-luebeck.de/downloads/papers/2011/2011-configurable-graph-drawing-algorithms-jannis-pohlmann.pdf)\n    Diplomarbeit, Universitat zu Lubeck, 2011\n\n[2] Till Tantau\n    [Graph drawing in TikZ](\n        https://www.emis.de/journals/JGAA/accepted/2013/Tantau2013.17.4.pdf)\n    Journal of graph algorithms and applications\n    Vol.17, No.4, pp.495--513, 2013\n    [DOI:10.7155/jgaa.00301](\n        https://doi.org/10.7155/jgaa.00301)\n    [slides](\n        https://www.tcs.uni-luebeck.de/downloads/mitarbeiter/tantau/2012-gd-presentation.pdf)\n\n\nLicense\n=======\n\n[BSD-3](https://opensource.org/licenses/BSD-3-Clause), see `LICENSE` file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnyf%2Fnx2tikz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnyf%2Fnx2tikz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnyf%2Fnx2tikz/lists"}