module documentation

Implementation of Python-level sparse matrix operations.

Function _convert_mode_argument Undocumented
Function _graph_from_sparse_matrix Construct graph from sparse matrix, unweighted.
Function _graph_from_weighted_sparse_matrix Construct graph from sparse matrix, weighted
Function _maybe_halve_diagonal Halves all items in the diagonal of the given SciPy sparse matrix in coo mode if and only if the given condition is True.
Constant _SUPPORTED_MODES Undocumented
def _convert_mode_argument(mode): (source)

Undocumented

def _graph_from_sparse_matrix(klass, matrix, mode='directed', loops='once'): (source)

Construct graph from sparse matrix, unweighted.

@param loops: specifies how the diagonal of the matrix should be handled:

  • C{"ignore"} - ignore loop edges in the diagonal
  • C{"once"} - treat the diagonal entries as loop edge counts
  • C{"twice"} - treat the diagonal entries as I{twice} the number of loop edges
def _graph_from_weighted_sparse_matrix(klass, matrix, mode=ADJ_DIRECTED, attr='weight', loops='once'): (source)

Construct graph from sparse matrix, weighted

NOTE: Of course, you cannot emcompass a fully general weighted multigraph with a single adjacency matrix, so we don't try to do it here either.

@param loops: specifies how to handle loop edges. When C{False} or
C{"ignore"}, the diagonal of the adjacency matrix will be ignored. When C{True} or C{"once"}, the diagonal is assumed to contain the weight of the corresponding loop edge. When C{"twice"}, the diagonal is assumed to contain I{twice} the weight of the corresponding loop edge.
def _maybe_halve_diagonal(m, condition): (source)

Halves all items in the diagonal of the given SciPy sparse matrix in coo mode if and only if the given condition is True.

Returns the row, column and data arrays.

_SUPPORTED_MODES: tuple[str, ...] = (source)

Undocumented

Value
('directed', 'undirected', 'max', 'min', 'plus', 'lower', 'upper')