networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
to_numpy_recarray(G, nodelist=None, dtype=None, order=None)
deprecated

to_numpy_recarray is deprecated and will be removed in NetworkX 3.0. Use nx.to_numpy_array(G, dtype=dtype, weight=None).view(np.recarray) instead.

Notes

When :None:None:`nodelist` does not contain every node in G, the adjacency matrix is built from the subgraph of G that is induced by the nodes in :None:None:`nodelist`.

Parameters

G : graph

The NetworkX graph used to construct the NumPy recarray.

nodelist : list, optional

The rows and columns are ordered according to the nodes in :None:None:`nodelist`. If :None:None:`nodelist` is None, then the ordering is produced by G.nodes().

dtype : NumPy data-type, optional

A valid NumPy named dtype used to initialize the NumPy recarray. The data type names are assumed to be keys in the graph edge attribute dictionary. The default is dtype([("weight", float)]) .

order : {'C', 'F'}, optional

Whether to store multidimensional data in C- or Fortran-contiguous (row- or column-wise) order in memory. If None, then the NumPy default is used.

Returns

M : NumPy recarray

The graph with specified edge data as a Numpy recarray

Returns the graph adjacency matrix as a NumPy recarray.

Examples

>>> G = nx.Graph()
... G.add_edge(1, 2, weight=7.0, cost=5)
... A = nx.to_numpy_recarray(G, dtype=[("weight", float), ("cost", int)])
... print(A.weight) [[0. 7.] [7. 0.]]
>>> print(A.cost)
[[0 5]
 [5 0]]
See :

Back References

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

networkx.convert_matrix.from_numpy_matrix networkx.convert_matrix.to_numpy_recarray networkx.convert_matrix.to_numpy_matrix

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 : /networkx/convert_matrix.py#696
type: <class 'function'>
Commit: