Legend:
Library
Module
Module type
Parameter
Class
Class type
Lazy graph polymorphic data structure
This module serves to represent directed graphs in a lazy fashion. Such a graph is always accessed from a given initial node (so only connected components can be represented by a single value of type ('v,'e) t).
The default equality considered here is (=), and the default hash function is Hashtbl.hash.
Lazy graph structure. Vertices, that have unique identifiers of type 'id, are annotated with values of type 'v, and edges are annotated by type 'e. A graph is a function that maps each identifier to a label and some edges to other vertices, or to Empty if the identifier is not part of the graph.
Lazy graph structure. Vertices, that have unique identifiers of type 'id, are annotated with values of type 'v, and edges are annotated by type 'e. A graph is a function that maps each identifier to a label and some edges to other vertices, or to Empty if the identifier is not part of the graph.
and('id, 'e) path = ('id * 'e * 'id) list
A reverse path (from the last element of the path to the first).
Basic constructors
It is difficult to provide generic combinators to build graphs. The problem is that if one wants to "update" a node, it's still very hard to update how other nodes re-generate the current node at the same time. The best way to do it is to build one function that maps the underlying structure of the type vertex to a graph (for instance, a concrete data structure, or an URL...).
Shortest path from the first node to nodes that satisfy goal, according to the given (positive!) distance function. The distance is also returned. ignore allows one to ignore some vertices during exploration. heuristic indicates the estimated distance to some goal, and must be
admissible (ie, it never overestimates the actual distance);
consistent (ie, h(X) <= dist(X,Y) + h(Y)). Both the distance and the heuristic must always be positive or null.
Shortest path from the first node to the second one, according to the given (positive!) distance function. ignore allows one to ignore some vertices during exploration. This raises Not_found if no path could be found.
val union :
?combine:('v->'v->'v)->('id, 'v, 'e)t->('id, 'v, 'e)t->('id, 'v, 'e)t
Lazy union of the two graphs. If they have common vertices, combine is used to combine the labels. By default, the second label is dropped and only the first is kept
val map :
vertices:('v->'v2)->edges:('e->'e2)->('id, 'v, 'e)t->('id, 'v2, 'e2)t
Map vertice and edge labels
val flat_map : ('id->'idSequence.t)->('id, 'v, 'e)t->('id, 'v, 'e)t
Replace each vertex by some vertices. By mapping v' to f v'=v1,...,vn, whenever v ---e---> v', then v --e--> vi for i=1,...,n. Optional functions can be used to transform labels for edges and vertices.
val filter :
?vertices:('id->'v-> bool)->?edges:('id->'e->'id-> bool)->('id, 'v, 'e)t->('id, 'v, 'e)t
Filter out vertices and edges that do not satisfy the given predicates. The default predicates always return true.
Same as collatz_graph, but also with reverse edges (n -> n*2, and n -> (n-1)/3 if n mod 3 = 1. Direct edges annotated with true, reverse edges with false