scipy.sparse.csgraph.
csgraph_masked_from_dense#
- scipy.sparse.csgraph.csgraph_masked_from_dense(graph, null_value=0, nan_null=True, infinity_null=True, copy=True)#
Konstruiert eine maskierte Array-Graphenrepräsentation aus einer dichten Matrix.
Hinzugefügt in Version 0.11.0.
- Parameter:
- grapharray_like
Eingabegraph. Die Form sollte (n_nodes, n_nodes) sein.
- null_valuefloat oder None (optional)
Wert, der Nicht-Kanten im Graphen bezeichnet. Standard ist Null.
- infinity_nullbool
Wenn True (Standard), werden unendliche Einträge (sowohl positive als auch negative) als Nullkanten behandelt.
- nan_nullbool
Wenn True (Standard), werden NaN-Einträge als Nicht-Kanten behandelt
- Rückgabe:
- csgraphMaskedArray
maskierte Array-Repräsentation des Graphen
Beispiele
>>> from scipy.sparse.csgraph import csgraph_masked_from_dense
>>> graph = [ ... [0, 1, 2, 0], ... [0, 0, 0, 1], ... [0, 0, 0, 3], ... [0, 0, 0, 0] ... ]
>>> csgraph_masked_from_dense(graph) masked_array( data=[[--, 1, 2, --], [--, --, --, 1], [--, --, --, 3], [--, --, --, --]], mask=[[ True, False, False, True], [ True, True, True, False], [ True, True, True, False], [ True, True, True, True]], fill_value=0)