type t
Type of a graph
type t
type vertex
val empty : t
val vertices : t -> int
val edges : t -> int
val iter_vertices : t -> (vertex -> unit) -> unit
val fold_vertices : t -> (vertex -> 'a -> 'a) -> 'a -> 'a
val iter_edges : t -> (vertex -> vertex -> unit) -> unit
val add_vertex : t -> vertex -> t
val add_edge : t -> ?cost:float -> vertex -> vertex -> t
val add : ?cost:float -> vertex -> vertex -> t -> t
add_edge
(for easy composition)
val remove_edge : t -> vertex -> vertex -> t
val remove_vertex : t -> vertex -> t
val neighbours : t -> vertex -> vertex list
val iter_neighbours : t -> vertex -> (vertex -> unit) -> unit
val merge : t -> t -> t
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