scipy 1.8.0 Pypi GitHub Homepage
Other Docs
ParametersReturnsBackRef
csgraph_to_masked(csgraph)
versionadded

Parameters

csgraph : csr_matrix, csc_matrix, or lil_matrix

Sparse representation of a graph.

Returns

graph : MaskedArray

The masked dense representation of the sparse graph.

Convert a sparse graph representation to a masked array representation

Examples

>>> from scipy.sparse import csr_matrix
... from scipy.sparse.csgraph import csgraph_to_masked
>>> graph = csr_matrix( [
... [0, 1, 2, 0],
... [0, 0, 0, 1],
... [0, 0, 0, 3],
... [0, 0, 0, 0]
... ])
... graph <4x4 sparse matrix of type '<class 'numpy.int64'>' with 4 stored elements in Compressed Sparse Row format>
>>> csgraph_to_masked(graph)
masked_array(
  data=[[ --, 1.0, 2.0,  --],
        [ --,  --,  --, 1.0],
        [ --,  --,  --, 3.0],
        [ --,  --,  --,  --]],
  mask=[[ True, False, False,  True],
        [ True,  True,  True, False],
        [ True,  True,  True, False],
        [ True,  True,  True,  True]],
  fill_value=1e+20)
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.sparse.csgraph._tools.csgraph_to_masked

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : None#None
type: <class 'builtin_function_or_method'>
Commit: