package owl-base
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=7e7725e9a1a967b2af54d7f091a0aea76c54e9abeb4220947921864ef6ffe7d0
md5=247e4b6e6190df68830095441e71e69a
doc/owl-base/Owl_graph/index.html
Module Owl_graph
Graph module supports basic operations on DAG.
Type definition
Obtaining properties
val id : 'a node -> int``id x`` returns the id of node ``x``.
val name : 'a node -> string``name x`` returns the name string of node ``x``.
val indegree : 'a node -> int``indegree x`` returns the in-degree of node ``x``.
val outdegree : 'a node -> int``outdegree x`` returns the out-degree of node ``x``.
val attr : 'a node -> 'a``attr x`` returns the ``attr`` field of node ``x``.
val set_attr : 'a node -> 'a -> unit``set_attr x`` sets the ``attr`` field of node ``x``.
Manipulation functions
``node ~id ~name ~prev ~next attr`` creates a node with given id and name string. The created node is also connected to parents in ``prev`` and children in ``next``. The ``attr`` will be saved in ``attr`` field.
``connect parents children`` connects a set of parents to a set of children. The created links are the Cartesian product of parents and children.
val remove_node : 'a node -> unit``remove_node x`` removes node ``x`` from the graph by disconnecting itself from all its parent nodes and child nodes.
``remove_edge src dst`` removes a link ``src -> dst`` from the graph. Note that it does not remove dst -> src if there exists one.
``copy ~dir x`` makes a copy of ``x`` and all its ancestors (if ``dir = Ancestor``) or all its descendants (if ``dir = Descendant``).
Note that this function only makes a copy of the graph structure, ``attr`` fileds of the nodes in the new graph share the same memory with those in the original graph.
Iterators
Iterate the ancestors of a given node.
Iterate the descendants of a given node.
Filter the ancestors of a given node.
Iterate the descendants of a given node.
Fold the ancestors of a given node.
Fold the descendants of a given node.
Iterate all the in-edges of a given node.
Iterate all the out-edges of a given node.
Fold all the in-edges of a given node.
Fold all the out-edges of a given node.
Helper functions
val pp_node : Format.formatter -> 'a node -> unitPretty print a given node.
val to_string : bool -> 'a node array -> stringConvert a given node to its string representaion.