module SHGraph:Oriented hypergraphssig..end
This module provides an abstract datatypes and functions for manipulating hypergraphs, that is, graphs where edges relates potentially more than 2 vertices. The considered hypergraphs are oriented: one distinguishes for a vertex incoming and outgoing hyperedges, and for an hyperedge incoming (or origin) and outgoing (or destination) vertices.
Origin and destination vertices of an hyperedge are ordered (by using arrays), in contrast with incoming and outgoing hyperedges of a vertex.
A possible use of such hypergraphs is the representation of a (fixpoint) equation system, where the unknown are the vertices and the functions the hyperedges, taking a vector of unknowns as arguments and delivering a vector of results.
A last note about the notion of connectivity, which is relevant for operations
like depth-first-search, reachability and connex components notions. A
destination vertex of an hyperedge is considered as reachable from an origin
vertex through this hyperedge only if all origin vertices are reachable.
type ('a, 'b, 'c, 'd, 'e) t
val create : int -> 'a -> ('b, 'c, 'd, 'e, 'a) tcreate n data creates an hypergraph, using n for the initial size
of internal hashtables, and data for the user informationval clear : ('a, 'b, 'c, 'd, 'e) t -> unitval is_empty : ('a, 'b, 'c, 'd, 'e) t -> boolval size_vertex : ('a, 'b, 'c, 'd, 'e) t -> intval size_hedge : ('a, 'b, 'c, 'd, 'e) t -> intval size_edgevh : ('a, 'b, 'c, 'd, 'e) t -> intval size_edgehv : ('a, 'b, 'c, 'd, 'e) t -> intval size : ('a, 'b, 'c, 'd, 'e) t -> int * int * int * intsize graph returns (nbvertex,nbhedge,nbedgevh,nbedgehv)val attrvertex : ('a, 'b, 'c, 'd, 'e) t -> 'a -> 'cattrvertex graph vertex returns the information associated to the
vertex vertexval attrhedge : ('a, 'b, 'c, 'd, 'e) t -> 'b -> 'dattrhedge graph hedge returns the information associated to the
hyperedge hedgeval info : ('a, 'b, 'c, 'd, 'e) t -> 'einfo g returns the user-information attached to the graph gval is_vertex : ('a, 'b, 'c, 'd, 'e) t -> 'a -> boolval is_hedge : ('a, 'b, 'c, 'd, 'e) t -> 'b -> boolval succhedge : ('a, 'b, 'c, 'd, 'e) t -> 'a -> 'b Sette.tval predhedge : ('a, 'b, 'c, 'd, 'e) t -> 'a -> 'b Sette.tval succvertex : ('a, 'b, 'c, 'd, 'e) t -> 'b -> 'a arrayval predvertex : ('a, 'b, 'c, 'd, 'e) t -> 'b -> 'a arrayval succ_vertex : ('a, 'b, 'c, 'd, 'e) t -> 'a -> 'a Sette.tval pred_vertex : ('a, 'b, 'c, 'd, 'e) t -> 'a -> 'a Sette.tval add_vertex : ('a, 'b, 'c, 'd, 'e) t -> 'a -> 'c -> unitval add_hedge : ('a, 'b, 'c, 'd, 'e) t ->
'b -> 'd -> pred:'a array -> succ:'a array -> unitFailure exception is raised.val remove_vertex : ('a, 'b, 'c, 'd, 'e) t -> 'a -> unitval remove_hedge : ('a, 'b, 'c, 'd, 'e) t -> 'b -> unitval iter_vertex : ('a, 'b, 'c, 'd, 'e) t ->
('a -> 'c -> pred:'b Sette.t -> succ:'b Sette.t -> unit) -> unitf vertex attrvertex succhedges predhedges to all
vertices of the graph. succhedges (resp. predhedges) is the set of
successor (resp. predecessor) hyperedges of the vertexval iter_hedge : ('a, 'b, 'c, 'd, 'e) t ->
('b -> 'd -> pred:'a array -> succ:'a array -> unit) -> unitf hedge attrhedge succvertices predvertices to
all hyperedges of the graph. succvertices (resp. predvertices) is the
set of successor (resp. predecessor) vertices of the hyperedgefold versions of the previous functions.val fold_vertex : ('a, 'b, 'c, 'd, 'e) t ->
('a -> 'c -> pred:'b Sette.t -> succ:'b Sette.t -> 'f -> 'f) -> 'f -> 'fval fold_hedge : ('a, 'b, 'c, 'd, 'e) t ->
('b -> 'd -> pred:'a array -> succ:'a array -> 'f -> 'f) -> 'f -> 'fmap versions of the previous functions.val map : ('a, 'b, 'c, 'd, 'e) t ->
('a -> 'c -> pred:'b Sette.t -> succ:'b Sette.t -> 'f) ->
('b -> 'd -> pred:'a array -> succ:'a array -> 'g) ->
('e -> 'h) -> ('a, 'b, 'f, 'g, 'h) tval copy : ('a -> 'b -> 'c) ->
('d -> 'e -> 'f) ->
('g -> 'h) ->
('a, 'd, 'b, 'e, 'g) t -> ('a, 'd, 'c, 'f, 'h) tval transpose : ('a -> 'b -> 'c) ->
('d -> 'e -> 'f) ->
('g -> 'h) ->
('a, 'd, 'b, 'e, 'g) t -> ('a, 'd, 'c, 'f, 'h) tcopy, but hyperedges are reversed: successor vertices
and predecssor vertices are exchanged.val min : ('a, 'b, 'c, 'd, 'e) t -> 'a Sette.tval max : ('a, 'b, 'c, 'd, 'e) t -> 'a Sette.tval topological_sort : ('a, 'b, 'c, 'd, 'e) t -> 'a -> 'a listval topological_sort_multi : 'a -> 'b -> ('a, 'b, 'c, 'd, 'e) t -> 'a Sette.t -> 'a listval topological_sort_filter_multi : 'a ->
'b -> ('a, 'b, 'c, 'd, 'e) t -> ('b -> bool) -> 'a Sette.t -> 'a listf hedge
succ tells whether the given dependency should be taken into account or
not in the sort.val reachable : ('a, 'b, 'c, 'd, 'e) t -> 'a -> 'a Sette.t * 'b Sette.tval reachable_multi : 'a ->
'b -> ('a, 'b, 'c, 'd, 'e) t -> 'a Sette.t -> 'a Sette.t * 'b Sette.tval reachable_filter_multi : 'a ->
'b ->
('a, 'b, 'c, 'd, 'e) t ->
('b -> bool) -> 'a Sette.t -> 'a Sette.t * 'b Sette.tval cfc : ('a, 'b, 'c, 'd, 'e) t -> 'a -> 'a list list
cfc graph vertex returns a decomposition of the graph. The exploration
is done from the initial vertex vertex, and only reachable vertices are
included in the result. The result has the structure [comp1 comp2 comp3
...] where each component is defined by a list of vertices. The ordering
of component correspond to a linearization of the partial order between the
components.
val cfc_multi : 'a -> 'b -> ('a, 'b, 'c, 'd, 'e) t -> 'a Sette.t -> 'a list list
cfc dummy_vertex dummy_hedge graph setvertices returns a decomposition of
the graph, explored from the set of initial vertices
setvertices. dummy_vertex and dummy_hedge are resp. unused vertex and
hyperedge identifiers.
val cfc_filter_multi : 'a ->
'b ->
('a, 'b, 'c, 'd, 'e) t -> ('b -> bool) -> 'a Sette.t -> 'a list listval cfc_priority_multi : 'a ->
'b ->
('a, 'b, 'c, 'd, 'e) t -> ('b -> int) -> 'a Sette.t -> 'a list list
The priority function p:'b -> int filters out hyperedges b such that
p b<0, and explores first hyperedges b with the highest priority.
val scfc : ('a, 'b, 'c, 'd, 'e) t -> 'a -> 'a Ilist.t
scfc graph vertex returns a decomposition of the graph. The exploration
is done from the initial vertex vertex, and only reachable vertices are
included in the result. The result has the structure [comp1 comp2 comp3
...] where each component is in turn decomposed into components.
val scfc_multi : 'a -> 'b -> ('a, 'b, 'c, 'd, 'e) t -> 'a Sette.t -> 'a Ilist.tval scfc_filter_multi : 'a ->
'b ->
('a, 'b, 'c, 'd, 'e) t -> ('b -> bool) -> 'a Sette.t -> 'a Ilist.tval scfc_priority_multi : 'a ->
'b ->
('a, 'b, 'c, 'd, 'e) t -> ('b -> int) -> 'a Sette.t -> 'a Ilist.tval print : (Format.formatter -> 'a -> unit) ->
(Format.formatter -> 'b -> unit) ->
(Format.formatter -> 'c -> unit) ->
(Format.formatter -> 'd -> unit) ->
(Format.formatter -> 'e -> unit) ->
Format.formatter -> ('a, 'b, 'c, 'd, 'e) t -> unit'a), hedges ('b), vertex
attributes ('c), hedge attributes ('d), and the user information
('e).val print_dot : ?titlestyle:string ->
?vertexstyle:string ->
?hedgestyle:string ->
?title:string ->
(Format.formatter -> 'a -> unit) ->
(Format.formatter -> 'b -> unit) ->
(Format.formatter -> 'a -> 'c -> unit) ->
(Format.formatter -> 'b -> 'd -> unit) ->
Format.formatter -> ('a, 'b, 'c, 'd, 'e) t -> unit
BE CAUTIOUS. as the DOT files vertices and hedges are actually nodes, the user should take care to avoid name conflicts between vertex and hedge names.
BE CAUTIOUS: the output of the function will be enclosed bewteen
quotes. If ever the output contains line break, or other special
characters, it should be escaped. A possible scheme to do this is to
first output to Format.str_formatter with a standard printing function,
then to escape the resulting string and to output the result. This gives
something like:
print_attrvertex Format.str_formatter vertex attr;
Format.pp_print_string fmt (String.escaped (Format.flush_str_formatter ()));.
Concerning the escape function, you may use String.escaped, which will
produce center justified line breaks, or the provided escaped (see
below) which allows also to choose between center, left and right
justified lines.
The optional arguments allows to customize the style. The default setting corresponds to:
print_dot ~titlestyle="shape=ellipse,style=bold,style=filled,fontsize=20"
~vertexstyle="shape=box,fontsize=12" ~hedgestyle="shape=ellipse,fontsize=12"
~title="" ....
val escaped : ?linebreak:char -> string -> stringlinebreak (default
'\n'). When used for DOT output, '\l' and '\r' produces respectively
left or righjt justified lines, instead of center justified lines.module type T =sig..end
XXX_multi which does not need any more a dummy
value of type vertex (resp. hedge).module type S =sig..end
module Make: