Version & licenses
Creative Commons License

Path.S

Guyslain Naves
  1. module type S =
  2. sig

  3. module G: Graph.S (* we repeat the module sent to the functor, for typing reasons *)

  4. type t (** the type of path in a graph *)

  5. (** a path without edge in a given graph *)
  6. val empty: G.graph -> G.vertex -> t

  7. (** The graph in which the path exists *)
  8. val graph : t -> G.graph

  9. (** Checks if a path has no edge *)
  10. val is_empty : t -> bool

  11. (** The set of edges in a path *)
  12. val edge_set : t -> G.E.t

  13. (** Add an edge at the beginning of a path *)
  14. val add_first : G.edge -> t -> t

  15. (** Add an edge at the end of a path *)
  16. val add_last : t -> G.edge -> t

  17. (** the first vertex of a path *)
  18. val first_vertex : t -> G.vertex

  19. (** the last vertex of a path *)
  20. val last_vertex : t -> G.vertex

  21. (** the extremities of a path, first vertex first, last vertex second *)
  22. val endpoints : t -> G.vertex * G.vertex

  23. (** The first edge of a path, if any (raise Invalid_arg otherwise) *)
  24. val first_edge : t -> G.edge

  25. (** The last edge of a path. *)
  26. val last_edge : t -> G.edge

  27. (** Removing the first edge of a path *)
  28. val remove_first : t -> t

  29. (** Removing the last edge of a path *)
  30. val remove_last : t -> t

  31. (** Fold a function over all the edges of a path, from first to last.
  32. Edges are given as triples vertex, edge, vertex where the two vertices
  33. are the endpoints of the edge given in order of appearance on the path
  34. *)
  35. val fold : ('a -> G.vertex -> G.edge -> G.vertex -> 'a) -> 'a -> t -> 'a

  36. (** Same as [fold], in backward direction *)
  37. val fold_backward : (G.vertex -> G.edge -> G.vertex -> 'a -> 'a) -> t -> 'a -> 'a

  38. (** [concat path1 path2] is the path obtained by the union of [path1] and [path2].
  39. [path1] and [path2] must have disjoint edge sets, and
  40. the last vertex of [path1] must be the first vertex of [path2].
  41. *)
  42. val concat : t -> t -> t

  43. (** [rev_concat path1 path2] is the path obtained by the union of [path1] and [path2].
  44. Direction of [path1] is reversed. First vertices of [path1] and [path2] nust be the same.
  45. *)
  46. val rev_concat: t -> t -> t

  47. (** Reverse the direction of the path, first vertex becomes last...*)
  48. val reverse : t -> t

  49. end