package mopsa
Install
Dune Dependency
Authors
Maintainers
Sources
md5=fdee20e988343751de440b4f6b67c0f4
sha512=f5cbf1328785d3f5ce40155dada2d95e5de5cce4f084ea30cfb04d1ab10cc9403a26cfb3fa55d0f9da72244482130fdb89c286a9aed0d640bba46b7c00e09500
doc/containers/Containers/GraphSig/module-type-S/index.html
Module type GraphSig.S
Source
Types
Type of graphs. Custom arbitrary data of type 'node_data
and 'edge_data
can be stored, respectively, in nodes and edges.
type node_id = P.NodeId.t
type edge_id = P.EdgeId.t
type port = P.Port.t
Export back types from the functor parameter.
module NodeSet : SetExtSig.S with type elt = node_id
module EdgeSet : SetExtSig.S with type elt = edge_id
Sets constructed from ordered type parameters.
module NodeMap : MapExtSig.S with type key = node_id
module EdgeMap : MapExtSig.S with type key = edge_id
Maps constructed from ordered type parameters.
Construction
val create : unit -> ('n, 'e) graph
Creates an empty graph.
val add_node :
('n, 'e) graph ->
node_id ->
?inc:(port * ('n, 'e) edge) list ->
?out:(port * ('n, 'e) edge) list ->
?entry:port ->
?exit:port ->
'n ->
('n, 'e) node
Adds a node to the graph. Optionally connects the node to incoming or outgoing edges. Optionally sets as an entry or exit node on a port (defaults to None, i.e., not entry nor exit). The node identifier must be unique among the node in the graph; raises Invalid_argument
otherwise.
val add_edge :
('n, 'e) graph ->
edge_id ->
?src:(port * ('n, 'e) node) list ->
?dst:(port * ('n, 'e) node) list ->
'e ->
('n, 'e) edge
Adds an edge to the graph. Optionally connects the edge to source or destination nodes. The edge identifier must be unique among the edges in the graph; raises Invalid_argument
otherwise.
Removes a node if it exists in the graph; otherwise, do nothing. All connections to incoming and outgoing edges are removed.
Removes an edge if it exists in the graph; otherwise, do nothing. All connections to source and destination nodes are removed.
Sets whether a node is an entry node on some port, or not (None). A given node can be entry for a single port at a time; previous entry ports are removed.
Sets whether a node is an exit node on some port, or not (None). A given node can be exit on a single port at a time; previous exit ports are removed.
Adds an incoming edge to the node, on the given port. A node can be connected to the same edge several times, on different or equal ports. Use the _unique
version to ensure that a node is connected to an given edge on a given port only once.
Adds an outgoing edge to the node, on the given port.
Adds incoming edges to the node, on the given ports.
Adds outgoing edges to the node, on the given ports.
Adds a source node to the edge, on the given port.
Adds a destination node to the edge, on the given port.
Adds source nodes to the edge, on the given ports.
Adds destination nodes to the edge, on the given ports.
Adds an incoming edge to the node, on the given port, but only if not already present on this port. Does not prevent the node to be connected to the edge on other ports.
Adds an outgoing edge to the node, on the given port, but only if not already present on this port.
Adds incoming edges to the node, on the given ports, but only if not already present on this port.
Adds outgoing edges to the node, on the given ports, but only if not already present on this port.
Adds a source node to the edge, on the given port, but only if not already present on this port.
Adds a destination node to the edge, on the given port, but only if not already present on this port.
Adds source nodes to the edge, on the given ports, but only if not already present on this port.
Adds destination nodes to the edge, on the given ports, but only if not already present on this port.
Removes all the connections to the node incoming from the edge on the given port. No edge nor node is deleted.
Removes all the connections from the node outgoing into the edge on the given port. No edge nor node is deleted.
Removes all the connections to the node incoming into from the edge, on all ports. No edge nor node is deleted.
Removes all the connections from the node incoming into the edge, on all ports. No edge nor node is deleted.
val node_remove_all_in : ('n, 'e) node -> unit
Removes all the connections incoming into the node, for all edges and ports. No edge nor node is deleted.
val node_remove_all_out : ('n, 'e) node -> unit
Removes all the connections outgoing from the node, for all edges and ports. No edge nor node is deleted.
Removes all the connections to the edge from the node on the given port. No edge nor node is deleted.
Removes all the connections from the edge to the node on the given port. No edge nor node is deleted.
Removes all the connections to the edge from the node, on all ports. No edge nor node is deleted.
Removes all the connections from the edge to the node on all ports. No edge nor node is deleted.
val edge_remove_all_src : ('n, 'e) edge -> unit
Removes all the connections at the source of the edge, for all nodes and ports. No edge nor node is deleted.
val edge_remove_all_dst : ('n, 'e) edge -> unit
Removes all the connections at the destination of the edge, for all nodes and ports. No edge nor node is deleted
Sets the incoming edges to the node, on the given ports.
Sets the outgoing edges to the node, on the given ports.
Sets the source nodes to the edge, on the given ports.
Sets destination nodes to the edge, on the given ports.
Sets the incoming edges to the node, on the given ports.
Sets the outgoing edges to the node, on the given ports.
Sets the source nodes to the edge, on the given ports.
Sets destination nodes to the edge, on the given ports.
Exploration
The set of nodes in the graph as a map from identifiers to nodes.
The set of edges in the graph as a map from identifiers to edges.
Whether the graph contains a node with this identifier.
Whether the graph contains an edge with this identifier.
The node corresponding to the identifier in the graph. Raises Not_found
if has_node
is false.
The edge corresponding to the identifier in the graph. Raises Not_found
if has_edge
is false.
val edge_data : ('n, 'e) edge -> 'e
Gets custom data associated to the edge.
val edge_set_data : ('n, 'e) edge -> 'e -> unit
Sets custom data associated to the edge.
List of edge source nodes on the given port.
List of edge destination nodes on the given port.
val edge_src_size : ('n, 'e) edge -> int
Number of edge source nodes.
val edge_dst_size : ('n, 'e) edge -> int
Number of edge destination nodes.
Number of edge destination nodes on the given port.
val node_data : ('n, 'e) node -> 'n
Gets custom data associated to the node.
val node_set_data : ('n, 'e) node -> 'n -> unit
Sets custom data associated to the node.
List of edges incoming into the node on the given port.
List of edges outgoing from the node on the given port.
val node_in_size : ('n, 'e) node -> int
Number of edges incoming into the node.
val node_out_size : ('n, 'e) node -> int
Number of edges outgoing from the node.
Number of edges incoming into the node on the given port.
Number of edges outgoing from the node on the given port.
If the node is an entry node, returns its port, otherwise None.
If the node is an exit node, returns its port, otherwise None.
Whether the given edge is outgoing from the node.
Whether the given edge is outgoing from the node on the given port.
Whether the given edge is incoming into the node.
Whether the given edge is incoming into the node on the given port.
Whether the edge has the node as source on the given port.
Whether the edge has the node as destination.
Whether the edge has the node as destination on the given port.
Successors nodes of a given node. Each returned element (port1,edge,port2,node)
gives the port port1
connecting the argument node to an edge edge
, the edge edge
, the port port2
connecting the edge edge
to the successor node node
, and finally the successor node node
.
Predecessor nodes of a given node. Each returned element (node,port1,edge,port2)
gives the predecessor node node
, the port port1
connecting it to an edge edge
, the edge edge
, and finally the port port2
connecting the edge edge
to the argument node.
Successor nodes of a given node connected through an edge on the specified ports. node_out_nodes_port node port1 port2
returns a list of (edge,node')
elements, where port1
connects the argument node
to an edge edge
and port2
connects the edge edge
to a successor node node'
.
Predecessor nodes of a given node connected through an edge on the specified ports. node_in_nodes_port node port1 port2
returns a list of (node',edge)
elements, where port1
connects the predecessor node'
to an edge edge
and port2
connects the edge edge
to a the argument node node
.
Whether the first node has an outgoing edge into the second node.
Whether the first node has an incoming edge from the second node.
Whether the first node has an outgoing edge on the first port, going into the second node on the second port.
Whether the first node has an incoming edge on the first port, coming from the second node on the second port.
Maps and folds
Creates a copy of the graph, applying a function to each node data and each edge data.
val transpose : ('n, 'e) graph -> unit
Reverses the direction of all edges. Also switches entry and exit nodes.
Iterates a function on all nodes. The order in which the function is called is not specified.
Iterates a function on all edges. The order in which the function is called is not specified.
Constructs a map from node identifiers, applying the given function. The order in which the function is called is not specified.
Constructs a map from edge identifiers, applying the given function. The order in which the function is called is not specified.
Accumulates a function on all nodes. The order in which the function is called is not specified.
Accumulates a function on all edges. The order in which the function is called is not specified.
Iterates a function on all nodes. The function is called in increasing identifier order.
Iterates a function on all edges. The function is called in increasing identifier order.
Constructs a map from node identifiers, applying the given function. The function is called in increasing identifier order.
Constructs a map from edge identifiers, applying the given function. The function is called in increasing identifier order.
Accumulates a function on all nodes. The function is called in increasing identifier order.
Accumulates a function on all edges. The function is called in increasing identifier order.
Simplification
val remove_orphan : ('n, 'e) graph -> unit
Removes orphan nodes and edges. Orphan nodes have no incoming nor outgoing edges, and orphan edges have no source nor destination nodes.
Topological ordering
val weak_topological_order : ('n, 'e) graph -> ('n, 'e) node nested_list list
Computes a weak topological ordering suitable to perform fixpoint iterations with widening. Implements Bourdoncle's algorithm 1
. 1
Francois Bourdoncle. Efficient Chaotic Iteration Strategies With Widenings. In Proc. FMPA'93, 128-141, 1993. Springer.
val widening_points : ('n, 'e) node nested_list list -> ('n, 'e) node list
Returns an adminisible list of widening points. Given a weak topological ordering, we compute the head of every component.
Printing
Print in plain text.
type ('n, 'e) printer = {
print_node : Stdlib.Format.formatter -> ('n, 'e) node -> unit;
print_edge : Stdlib.Format.formatter -> ('n, 'e) edge -> unit;
print_src : Stdlib.Format.formatter -> ('n, 'e) node -> port -> ('n, 'e) edge -> unit;
print_dst : Stdlib.Format.formatter -> ('n, 'e) edge -> port -> ('n, 'e) node -> unit;
print_entry : Stdlib.Format.formatter -> ('n, 'e) node -> port -> unit;
print_exit : Stdlib.Format.formatter -> ('n, 'e) node -> port -> unit;
}
Print in dot graph format.
type ('n, 'e) dot_printer = {
dot_pp_node : Stdlib.Format.formatter -> ('n, 'e) node -> unit;
dot_pp_edge : Stdlib.Format.formatter -> ('n, 'e) edge -> unit;
dot_pp_port : Stdlib.Format.formatter -> port -> unit;
dot_filter_node : ('n, 'e) node -> bool;
dot_filter_edge : ('n, 'e) edge -> bool;
dot_filter_port : port -> bool;
}
val print_dot :
('n, 'e) dot_printer ->
string ->
Stdlib.Format.formatter ->
('n, 'e) graph ->
unit
print_dot channel graph name printer
. outputs the graph in the specified channel in dot format. In addition name
gives the dot graph name. The node, edge and port printer functions are user-specified.