bundles / scipy 1.17.1 / scipy / sparse / csgraph / _tools / csgraph_from_dense
cython_function_or_method
scipy.sparse.csgraph._tools:csgraph_from_dense
Signature
def csgraph_from_dense ( graph , null_value = 0 , nan_null = True , infinity_null = True ) Summary
Construct a CSR-format sparse graph from a dense matrix.
Extended Summary
Parameters
graph: array_likeInput graph. Shape should be (n_nodes, n_nodes).
null_value: float or None (optional)Value that denotes non-edges in the graph. Default is zero.
infinity_null: boolIf True (default), then infinite entries (both positive and negative) are treated as null edges.
nan_null: boolIf True (default), then NaN entries are treated as non-edges
Returns
csgraph: csr_arrayCompressed sparse representation of graph,
Examples
from scipy.sparse.csgraph import csgraph_from_dense
✓graph = [ [0, 1, 2, 0], [0, 0, 0, 1], [0, 0, 0, 3], [0, 0, 0, 0] ]✓
csgraph_from_dense(graph)
✗Aliases
-
scipy.sparse.csgraph.csgraph_from_dense