Module OgamlUtils.Graph.G

Output of Graph.Make
type t
Type of a graph
type vertex
Type of a vertex
val empty : t
Empty graph
val vertices : t -> int
Returns the number of vertices of a graph
val edges : t -> int
Returns the number of edges of a graph
val iter_vertices : t -> (vertex -> unit) -> unit
Iterates through all the vertices of a graph
val fold_vertices : t -> (vertex -> 'a -> 'a) -> 'a -> 'a
Folds through all the vertices of a graph
val iter_edges : t -> (vertex -> vertex -> unit) -> unit
Iterates through all the edges of a graph
val add_vertex : t -> vertex -> t
Adds a vertex to a graph
val add_edge : t -> ?cost:float -> vertex -> vertex -> t
Adds an edge with an optional cost to a graph (adds the vertices if needed)
val add : ?cost:float -> vertex -> vertex -> t -> t
Tail-call alias for add_edge (for easy composition)
val remove_edge : t -> vertex -> vertex -> t
Removes an edge from a graph (does nothing if the edge does not exist)
val remove_vertex : t -> vertex -> t
Removes a vertex from a graph (and all of its adjacent edges)
val neighbours : t -> vertex -> vertex list
Returns all the neighbours of a vertex
val iter_neighbours : t -> vertex -> (vertex -> unit) -> unit
Iterates through all the neighbours of a vertex
val merge : t -> t -> t
Merges two graphs
val dfs : t -> vertex -> (vertex -> unit) -> unit
dfs g s f iterates f through all the accessible vertices of g , starting from s using a dfs
val bfs : t -> vertex -> (vertex -> unit) -> unit
bfs g s f iterates f through all the accessible vertices of g , starting from s using a bfs
val dijkstra : t -> vertex -> vertex -> (float * vertex list) option
dijkstra g v1 v2 runs Dijkstra's algorithm on g from v1 to v2 and returns the minimal path as well as the distance between v1 and v2 , or None if v1 and v2 are not connected
val astar : t -> vertex -> vertex -> (vertex -> float) -> (float * vertex list) option
astar g v1 v2 f runs the A* algorithm on g from v1 to v2 with the heuristic f and returns the minimal path as well as the distance between v1 and v2 , or None if v1 and v2 are not connected