Bigraph.SparseSparse Boolean matrices and graph operations.
The module also provides operations on graphs. These are intended to be used when Boolean matrices are interpreted as adjacency matrices of Directed Acyclic Graphs (DAG).
The type of sparse Boolean matrices. For example, adding "(2, 1)" means that the element in row 2, column 1 is true.
val pp :
Ppx_deriving_runtime.Format.formatter ->
t ->
Ppx_deriving_runtime.unitval show : t -> Ppx_deriving_runtime.stringval to_yojson : t -> Yojson.Safe.tval of_yojson : Yojson.Safe.t -> t Ppx_deriving_yojson_runtime.error_orval make : int -> int -> tmake r c returns an empty matrix with r rows and c columns.
apply_rows iso m returns matrix m with the rows reordered according to iso. The domain of iso is assumed to be {0,...,r} with r the number of rows of m.
Same as apply_rows but on columns.
Same as apply_rows but on both rows and columns. The matrix is assumed square.
val parse_vectors : int list list -> int -> tparse_vectors l r parses list l of column vectors to a matrix with r rows and c columns, with c the length of l . Example: parse_vectors [[0;1;2];[1;2]] 4 is parsed to the following 4x2 matrix
10 11 11 00
Return the domain of a matrix, that is the set of rows having at least one true element.
Return the codomain of a matrix, that is the set of columns having at least one true element.
val iter : (int -> int -> unit) -> t -> unitSame as Map.iter.
val fold : (int -> int -> 'a -> 'a) -> t -> 'a -> 'aFold iterating over every pair (i, j) defined by the map.
Fold over rows, yielding each row index and the set of columns with true values.
Dual of Sparse.fold_r.
add i j m adds element (i,j). Both i and j must be non negative and within the bounds of m.
Add a list of elements as in Sparse.add.
val entries : t -> intReturn the number of true elements in a matrix. This is equivalent to the number of edges in a graph.
val edges : t -> (int * int) listReturn the representation of a binary matrix as a list of edges.
val mem : t -> int -> int -> boolmem m i j returns true if edge (i,j) is defined by m.
val check_dimensions : t -> r:int -> c:int -> boolcheck_dimensions m ~r ~c returns true if m has r rows and c columns.
val is_dag : t -> boolis_dag m returns true if m has no cycles. The matrix is assumed to be square.
val row : int -> trow n returns a row vector of n true elements.
val col : int -> tcol n returns a column vector of n true elements.
val diag : int -> tdiag n returns a square matrix of size n with all true elements on the diagonal.
tens a b returns the tensor product of matrices a and b. The tensor product is defined according to the following schema:
+-----------+-----------+ | | | | a | | | | | +-----------+-----------+ | | | | | b | | | | +-----------+-----------+
append a b appends matrix b to the right of matrix a. The two matrices are assumed to have the same number of rows. This operation is described by the diagram below:
+-----------+-----------+ | | | | a | b | | | | +-----------+-----------+
stack a b stacks matrix a on top of matrix b. The two matrices are assumed to have the same number of columns. This operation is described by the following diagram:
+-----------+ | | | a | | | +-----------+ | | | b | | | +-----------+
glue a b c d computes the matrix defined below:
+-----------+-----------+ | | | | a | b | | | | +-----------+-----------+ | | | | c | d | | | | +-----------+-----------+
mul a b multiplies (row by column multiplication) matrix a by matrix b. The number of columns of a is assumed to be equal to the number of rows of b.
siblings m i returns the set of siblings of i. Two nodes are siblings if they share a parent.
Dual of Sparse.siblings.
levels m returns the level decomposition of m. Each level is obtained by iteratively removing the leaves in the graph until no nodes are left. Argument m is assumed square.
row_eq m js computes a set of rows such that the union of their children sets is equal to js.
Dual of Sparse.row_eq.