Graphs can be represented as an algebraic data type through four different primitives : empty,
singleton, union and product. Graphs produced with these primitives have the particularity
that they will never be in an inconsistent state, at the expense of possibly including some extra
meta-data that is not really needed. This module has a bunch of functions to help you work with
them!
Perform the union of two graphs. Vertices and edges will be unioned.
Perform the product of two graphs. Vertices will be unioned, and edges will be created from each vertex of the left graph to each vertex of the right graph.
Expand this graph to forlm a set of all edges.
Map a function onto a graph, creating a graph with transformed vertices.
Map a function onto a graph, and flatten the resulting graphs.
Reduce the vertices of a graph.
fold (+) 0 (fromList [ 1, 2, 3 ]) == 6Compact a graph, using the intuition that each vertex should result in a new vertex, and each inferred edge can be compacted into its own small sub-graph.
This removes duplicated edges, and does not find a minimal algebraic graph for a given set of edges andvertices.
Represents a directed graph of values. So
Graph (String)is a graph of strings andGraph (Int)is a graph of ints.