Skip to main content

Downloads Documentation Status

Need To Graph

N2G is a library to generate diagrams in yWorks graphml or Diagrams drawio formats or produce JSON data compatible with 3d-force-graph JSON input syntax allowing 3D visualization.

Demo

Why?

To save your time on producing consistently looking, editable diagrams of arbitrary size and complexity in a programmatic way helping to satisfy your "Need To Graph" desire.

How?

Not a secret that many applications use XML structured text to save their diagrams content, then why not to do the opposite - produce XML structured text that applications can open and understand and work with. N2G does exactly that, it takes structured data - csv, dictionary, list or api calls and gives back XML text that can be opened and edited by application of choice.

What?

All formats supported so far have very similar API capable of:

  • adding nodes and links with various attributes such as shape, labels, urls, data, styles
  • bulk graph creation using from_x methods supporting lists, dictionaries or csv data
  • existing nodes and links attributes manipulation and update
  • loading existing XML diagram files for processing and modification
  • deletion of nodes and links from diagrams
  • comparing two diagrams to highlight the difference between them
  • layout your diagram with algorithms available in igraph library
  • returning results in text format or saving directly into the file

Reference documentation for more information.

What it's not?

N2G is not a magic bullet that will produce perfect diagrams for you, it can help to simplify the process of adding elements to your diagrams. However, (manual) efforts required to put all the elements in positions where they will satisfy your inner sense of perfection, as a result, keep in mind that (normally) the more elements you have on your diagram, the more efforts required to make it looks good.

Quite unlikely it would ever be a tool with support of all capabilities available in subject applications, however, feature requests are welcomed.

Example

from N2G import yed_diagram

diagram = yed_diagram()
sample_list_graph = [
    {'source': {'id': 'SW1', 'top_label': 'CORE', 'bottom_label': '1,1,1,1'}, 'src_label': 'Gig0/0', 'target': 'R1', 'trgt_label': 'Gig0/1'},
    {'source': {'id': 'R2', 'top_label': 'DC-PE'}, 'src_label': 'Gig0/0', 'target': 'SW1', 'trgt_label': 'Gig0/2'},
    {'source': {'id':'R3', 'bottom_label': '1.1.1.3'}, 'src_label': 'Gig0/0', 'target': 'SW1', 'trgt_label': 'Gig0/3'},
    {'source': 'SW1', 'src_label': 'Gig0/4', 'target': 'R4', 'trgt_label': 'Gig0/1'},
    {'source': 'SW1', 'src_label': 'Gig0/5', 'target': 'R5', 'trgt_label': 'Gig0/7'},
    {'source': 'SW1', 'src_label': 'Gig0/6', 'target': 'R6', 'trgt_label': 'Gig0/11'}
]
diagram.from_list(sample_list_graph)
diagram.dump_file(filename="Sample_graph.graphml", folder="./")

Disclaimer

Author of this module not affiliated with any of the application Vendors mentioned so far. The choice of formats to support was primarily driven by the fact of how much functionality available in particular application for free. Moreover, this module does not use any aforementioned (diagramming) applications in any programmatic way to produce its results, in other words, none of the aforementioned applications required to be installed on the system for this (N2G) module to work.

Contributions

Feel free to submit an issue, to report a bug or ask a question, feature requests are welcomed or buy Author a coffee

Metadata

Release files for n2g 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for n2g 0.3.3
File Size Uploaded
N2G-0.3.3.tar.gz 462.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for n2g 0.3.3
File Interpreter ABI Platform
N2G-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 943.3 kB

Release files / N2G-0.3.3.tar.gz

Download URL N2G-0.3.3.tar.gz
Size 462.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e19d955291c6baf5bd917c0def1ea1f1b2b9aab00131134fd0cb86d0e227f573
BLAKE2b-256 checksum
How to use checksums
89d6d5bc677554fa7708b2f7cb425e99a7a7a76a86240e1261b35502b24667ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.14 CPython/3.9.13 Windows/10

Release files / N2G-0.3.3-py3-none-any.whl

Download URL N2G-0.3.3-py3-none-any.whl
Size 481.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20e942c4d0de4412d03fd75e87189304e7c15fc87ab172fb01209eb19b782554
BLAKE2b-256 checksum
How to use checksums
597a4213c9c5efdc5f4f85b73819128108186ec1d1b8252bf85087608b331f6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.14 CPython/3.9.13 Windows/10

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

1 release file

0.1.2

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page