A simple functional graph library. Keys used to identify nodes can be any comparable and nodes can have any kind of metadata associated with them.
All operations that look at a single node are at most O(log n).
Operations that look at all elements in the graph are at most O(n log n).
Get the data associated with a specific node.
Get the data associated with a specific edge.
If you want to pass the edge as a 2-tuple instead, you can use getEdgeData from the Pair module.
Determine if a node identified by a key is in the graph.
Determine if an edge identified by a pair of keys is in the graph.
Get the set of incoming edges to a node.
Get the set of outgoing edges from a node.
Determine if the graph is empty.
Determine the number of nodes in the graph.
Get the keys for all nodes in the graph.
Get the (key, data) pair for each node in the graph.
Get the (from, to) pair for each edge in the graph.
Get the (from, to, Maybe edgeData) pair for each edge in the graph.
Determine if a graph contains any loops or cycles.
Create an empty graph.
Insert a node. Does not overwrite metadata if node already exists.
Update metadata for a node. Creates the node if it does not already exist.
Insert an edge between two nodes. Creates any nodes that do not already exist.
If you want to pass the edge as a 2-tuple instead, you can use insertEdge from the Pair module.
Insert an edge with some metadata between two nodes. Creates any nodes that do not already exist.
If you want to pass the edge as a 2-tuple instead, you can use insertEdgeData from the Pair module.
Remove a node by its key. No-op if node doesn't exist.
Remove the metadata associated with a specific node.
Remove an edge identified by its source and target keys. No-op if source, target or edge doesn't exist.
If you want to pass the edge as a 2-tuple instead, you can use removeEdge from the Pair module.
Remove the metadata associated with a specific edge.
If you want to pass the edge as a 2-tuple instead, you can use removeEdgeData from the Pair module.
Update the metadata associated with a specific node.
Update the metadata associated with a specific edge.
If you want to pass the edge as a 2-tuple instead, you can use updateEdge from the Pair module.
Apply a function to the data associated with each node in a graph.
Fold over the node keys and data in a graph, in order from lowest key to highest key.
Fold over the node keys and data in a graph, in order from highest key to lowest key.
Create a copy of the graph, only keeping nodes where the predicate function returned True.
Partition a graph into two parts. The left one, with the nodes where the predicate function returned True, and right one, where it returned False.
Join two graphs together. If an edge appears between two nodes in either of the graphs, it will be in the resulting graph. If a node identified by a specific key appears in any of the graphs, it will be in the resulting graph. If both graphs have metadata for the same node or edge, the metadata in the left graph will be used.
Create a graph based on the intersection of two graphs. If both graphs have the same node, edge or associated metadata, it will be in the resulting graph. If both graphs have metadata for the same node or edge, the metadata in the left graph will be used.
Get a list of all keys in postorder.
Get a topological sorting of the graph, if the graph doesn't contain any loops or cycles.
Returns the graph in Graphviz digraph format as a string.
Validate checks that all invariants in the graph are correct. Useful for debugging.
A directed graph.
(Graph Int String Float)is a graph that usesInts for identifying its nodes, and lets you store aStringon each node and aFloaton each edge.