Python library for generating dot programming language for creating graphviz graphs from python OO style code.
Project description
Pygraphv
Pygraphv - python library for generating dot programming language for creating graphviz graphs from python OO style code.
Examples
Basic graph:
from pygraphv.graph import Graph
from pygraphv.node import Node
from pygraphv.style import GraphStyle
# Chose one of this
# You can look at difference in Graphviz docs
# digraph = Digraph("Digraph")
graph = Graph("Graph")
# Adds node with name A, that has child node B
a = Node("A")
graph.add_node(a)
graph.add_node(Node("B"), parent=a)
# Generates .dot file for your graph and saves it in "Your first graph.dot"
# And renders it to svg file, needs dot compiler installed and added to path
graph.render("Your first graph")
Styles:
from pygraphv.graph import Digraph
from pygraphv.style import *
from pygraphv.node import Node
# Now digraph example
# Only difference to regular graph is arrows at ends of connections
graph = Digraph("Graph", styles=[GraphStyle(bgcolor="lightblue"), GraphStyle(href="github.com/farkon00")])
# Adds node with name A, that has child node B
a = Node("A", styles=NodeStyle(color="red", shape="box"))
graph.add_node(a)
graph.add_node(Node("B"), label="Styled edge", parent=a, styles=EdgeStyle(arrowhead="box"))
# Generates .dot file for your graph and saves it in "Styles.dot"
# And renders it to svg file, needs dot compiler installed and added to path
graph.render("Styles")
Clusters:
from pygraphv.graph import Graph, Cluster
from pygraphv.style import *
from pygraphv.node import Node
graph = Graph("Graph")
# Adds node with name A, that has child node B
a = Node("A")
graph.add_node(a)
graph.add_node(Node("B"), parent=a)
# Creates cluster and adds cycle of 3 nodes, connected to node A
# Can be compressed to one style object
# But you can use GraphStyle on clusters
cluster = Cluster("Cluster", styles=(GraphStyle(bgcolor="lightgreen"), ClusterStyle(style="dotted")))
node1 = Node("1")
cluster.add_node(node1)
a.children.append(node1)
cluster.add_node(Node("2"), parent=node1)
cluster.add_node(Node("3"), parent=node1)
graph.add_node(node1.children[-1].node, parent=node1.children[-2].node)
graph.add_subgraph(cluster)
# Generates .dot file for your graph and saves it in "Clusters.dot"
# And renders it to svg file, needs dot compiler installed and added to path
graph.render("Clusters")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pygraphv-0.1.tar.gz
(6.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pygraphv-0.1.tar.gz.
File metadata
- Download URL: pygraphv-0.1.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bb4673776ad47146aec53c7c3a5745c91993f88375f8642beed587d46547a1b
|
|
| MD5 |
ede79274aae0586e8b6367f350b721ec
|
|
| BLAKE2b-256 |
aed19a1dfd262ac91feba3dceef6db76d3ad364d06f2ba13a04e3c79bd485194
|
File details
Details for the file pygraphv-0.1-py3-none-any.whl.
File metadata
- Download URL: pygraphv-0.1-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75a59d541924193ab6f210b0e42df8f5761362b99ca1244f7912c511677ba8ee
|
|
| MD5 |
90e76bd0360640699dbda7a926cbc87a
|
|
| BLAKE2b-256 |
1e8b99a5e7f16ccbda4b6cf31997ee2d6b177212b597d385f0633e741158e028
|