from gafferdot import Graph, Node g = Graph() # Add nodes to the graph n1 = Node("A") n2 = Node("B") n3 = Node("C") n4 = Node("D") # Add edges to the graph g.add_edge(n1, n2) g.add_edge(n2, n3) g.add_edge(n3, n4) # Render the graph g.render("my_graph.png")
from gafferdot import Graph, Node g = Graph() # Add nodes to the graph with custom attributes n1 = Node("A", shape="box", style="filled", fillcolor="lightblue") n2 = Node("B", shape="oval") # Add edges to the graph g.add_edge(n1, n2) # Render the graph g.render("my_graph.png")This code creates a directed graph with custom node attributes, including different shapes and colors for each node. Overall, Python Gaffer Dot is a useful package library for creating and visualizing directed graphs in Python. It provides a simple and intuitive interface for creating and manipulating graphs, and offers a range of customization options for node and edge attributes.