Graph of nodes and edges.
Convert the graph to a JSON-serializable format.
Return a new unique node identifier.
It that can be used to add a node to the graph.
Add a node to the graph and return it.
Remove a node from the graph and all edges connected to it.
Add an edge to the graph and return it.
Add all nodes and edges from another graph.
Note this doesn't check for duplicates, nor does it connect the graphs.
Return a new graph with all nodes re-identified.
Uses their unique, readable names where possible.
Find the single node that is not a target of any edge.
If there is no such node, or there are multiple, return None.
When drawing the graph, this node would be the origin.
Find the single node that is not a source of any edge.
If there is no such node, or there are multiple, return None.
When drawing the graph, this node would be the destination.
Remove the first node if it exists and has a single outgoing edge.
i.e., if removing it would not leave the graph without a "first" node.
Remove the last node if it exists and has a single incoming edge.
i.e., if removing it would not leave the graph without a "last" node.
Draw the graph as an ASCII art string.
Print the graph as an ASCII art string.
Draw the graph as a PNG image.
Draw the graph as a Mermaid syntax string.
Draw the graph as a PNG image using Mermaid.