AttributeError: module 'networkx' has no attribute 'from_numpy_matrix' (or 'read_gpickle', 'Graph' object has no attribute 'node', 'nodes_iter', any name): which networkx removed it and what to use
networkx 3.0 (2023-01-08) removed from_numpy_matrix and to_numpy_matrix (use from_numpy_array, to_numpy_array), read_gpickle and write_gpickle (use pickle), from_scipy_sparse_matrix (from_scipy_sparse_array) and nx.info (print(G)). 2.4 (2019-10-17) removed G.node (use G.nodes) and connected_component_subgraphs. 2.0 removed nodes_iter, edges_iter and G.edge. If the error comes from a library you did not write, upgrade the library or pin networkx below the release that removed the name. Paste the error below for the release-by-release answer.
Examples:
Runs in your browser on the data in this page (networkx_names.json); nothing you paste is sent anywhere.
Which release removed it, and what replaces it?
288 names that one networkx release has and a later one does not (100 of them in 3.0). "Instead" is networkx's own deprecation text from the last release that had the name (175 of 288), except where marked "our note" (from networkx's migration guides and release notes, for names removed without a warning, as most of the 1.x API was in 2.0).
| Name | Removed in | Instead |
|---|---|---|
networkx.block | 2.0 | |
networkx.draw_graphviz | 2.0 | |
networkx.edges_iter | 2.0 | G.edges() or nx.edges(G) (2.0 removed every *_iter method). (our note) |
networkx.external | 2.0 | |
networkx.kclique | 2.0 | From networkx.algorithms.community import kclique (still there in 3.7). |
networkx.mst | 2.0 | From networkx.algorithms.tree import mst (still there in 3.7). |
networkx.nodes_iter | 2.0 | G.nodes() or nx.nodes(G) (2.0 removed every *_iter method). (our note) |
networkx.threshold | 2.0 | |
networkx.topological_sort_recursive | 2.0 | |
networkx.algorithms.block | 2.0 | |
networkx.algorithms.kclique | 2.0 | From networkx.algorithms.community import kclique (still there in 3.7). |
networkx.algorithms.mst | 2.0 | |
networkx.algorithms.topological_sort_recursive | 2.0 | |
networkx.algorithms.centrality.communicability_alg | 2.0 | |
networkx.algorithms.dag.topological_sort_recursive | 2.0 | |
networkx.classes.edges_iter | 2.0 | G.edges() or nx.edges(G) (2.0 removed every *_iter method). (our note) |
networkx.classes.nodes_iter | 2.0 | G.nodes() or nx.nodes(G) (2.0 removed every *_iter method). (our note) |
networkx.classes.function.edges_iter | 2.0 | G.edges() or nx.edges(G) (2.0 removed every *_iter method). (our note) |
networkx.classes.function.nodes_iter | 2.0 | G.nodes() or nx.nodes(G) (2.0 removed every *_iter method). (our note) |
networkx.drawing.draw_graphviz | 2.0 | |
networkx.drawing.nx_pydot.networkx_from_pydot | 2.0 | networkx_from_pydot is replaced by from_pydot |
networkx.drawing.nx_pydot.pydot_from_networkx | 2.0 | pydot_from_networkx is replaced by to_pydot |
networkx.drawing.nx_pylab.draw_graphviz | 2.0 | |
networkx.generators.threshold | 2.0 | |
networkx.utils.create_degree_sequence | 2.0 | create_degree_sequence() is deprecated |
G.adjacency_iter (DiGraph) | 2.0 | G.adjacency() (2.0 release notes). (our note) |
G.adjacency_list (DiGraph) | 2.0 | G.adjacency() (2.0 release notes), or [list(nbrs) for n, nbrs in G.adjacency()]. (our note) |
G.adjlist_dict_factory (DiGraph) | 2.0 | adjlist_inner_dict_factory (and adjlist_outer_dict_factory) on the class. (our note) |
G.degree_iter (DiGraph) | 2.0 | G.degree() (2.0 removed every *_iter method). (our note) |
G.edge (DiGraph) | 2.0 | G.adj (G.adj[u][v] is the edge data dict, as G.edge[u][v] was in 1.x), or G.edges[u, v]. (our note) |
G.edges_iter (DiGraph) | 2.0 | G.edges() (2.0 removed every *_iter method). (our note) |
G.in_degree_iter (DiGraph) | 2.0 | G.in_degree(). (our note) |
G.in_edges_iter (DiGraph) | 2.0 | G.in_edges(). (our note) |
G.neighbors_iter (DiGraph) | 2.0 | G.neighbors(n), which returns an iterator from 2.0. (our note) |
G.nodes_iter (DiGraph) | 2.0 | G.nodes() (2.0 removed every *_iter method; the method without _iter returns a view or iterator). (our note) |
G.out_degree_iter (DiGraph) | 2.0 | G.out_degree(). (our note) |
G.out_edges_iter (DiGraph) | 2.0 | G.out_edges(). (our note) |
G.predecessors_iter (DiGraph) | 2.0 | G.predecessors(n). (our note) |
G.successors_iter (DiGraph) | 2.0 | G.successors(n). (our note) |
G.adjacency_iter (Graph) | 2.0 | G.adjacency() (2.0 release notes). (our note) |
G.adjacency_list (Graph) | 2.0 | G.adjacency() (2.0 release notes), or [list(nbrs) for n, nbrs in G.adjacency()]. (our note) |
G.adjlist_dict_factory (Graph) | 2.0 | adjlist_inner_dict_factory (and adjlist_outer_dict_factory) on the class. (our note) |
G.degree_iter (Graph) | 2.0 | G.degree() (2.0 removed every *_iter method). (our note) |
G.edge (Graph) | 2.0 | G.adj (G.adj[u][v] is the edge data dict, as G.edge[u][v] was in 1.x), or G.edges[u, v]. (our note) |
G.edges_iter (Graph) | 2.0 | G.edges() (2.0 removed every *_iter method). (our note) |
G.neighbors_iter (Graph) | 2.0 | G.neighbors(n), which returns an iterator from 2.0. (our note) |
G.nodes_iter (Graph) | 2.0 | G.nodes() (2.0 removed every *_iter method; the method without _iter returns a view or iterator). (our note) |
G.adjacency_iter (MultiDiGraph) | 2.0 | G.adjacency() (2.0 release notes). (our note) |
G.adjacency_list (MultiDiGraph) | 2.0 | G.adjacency() (2.0 release notes), or [list(nbrs) for n, nbrs in G.adjacency()]. (our note) |
G.adjlist_dict_factory (MultiDiGraph) | 2.0 | adjlist_inner_dict_factory (and adjlist_outer_dict_factory) on the class. (our note) |
G.degree_iter (MultiDiGraph) | 2.0 | G.degree() (2.0 removed every *_iter method). (our note) |
G.edge (MultiDiGraph) | 2.0 | G.adj (G.adj[u][v] is the edge data dict, as G.edge[u][v] was in 1.x), or G.edges[u, v]. (our note) |
G.edges_iter (MultiDiGraph) | 2.0 | G.edges() (2.0 removed every *_iter method). (our note) |
G.in_degree_iter (MultiDiGraph) | 2.0 | G.in_degree(). (our note) |
G.in_edges_iter (MultiDiGraph) | 2.0 | G.in_edges(). (our note) |
G.neighbors_iter (MultiDiGraph) | 2.0 | G.neighbors(n), which returns an iterator from 2.0. (our note) |
G.nodes_iter (MultiDiGraph) | 2.0 | G.nodes() (2.0 removed every *_iter method; the method without _iter returns a view or iterator). (our note) |
G.out_degree_iter (MultiDiGraph) | 2.0 | G.out_degree(). (our note) |
G.out_edges_iter (MultiDiGraph) | 2.0 | G.out_edges(). (our note) |
G.predecessors_iter (MultiDiGraph) | 2.0 | G.predecessors(n). (our note) |
G.successors_iter (MultiDiGraph) | 2.0 | G.successors(n). (our note) |
G.adjacency_iter (MultiGraph) | 2.0 | G.adjacency() (2.0 release notes). (our note) |
G.adjacency_list (MultiGraph) | 2.0 | G.adjacency() (2.0 release notes), or [list(nbrs) for n, nbrs in G.adjacency()]. (our note) |
G.adjlist_dict_factory (MultiGraph) | 2.0 | adjlist_inner_dict_factory (and adjlist_outer_dict_factory) on the class. (our note) |
G.degree_iter (MultiGraph) | 2.0 | G.degree() (2.0 removed every *_iter method). (our note) |
G.edge (MultiGraph) | 2.0 | G.adj (G.adj[u][v] is the edge data dict, as G.edge[u][v] was in 1.x), or G.edges[u, v]. (our note) |
G.edges_iter (MultiGraph) | 2.0 | G.edges() (2.0 removed every *_iter method). (our note) |
G.neighbors_iter (MultiGraph) | 2.0 | G.neighbors(n), which returns an iterator from 2.0. (our note) |
G.nodes_iter (MultiGraph) | 2.0 | G.nodes() (2.0 removed every *_iter method; the method without _iter returns a view or iterator). (our note) |
networkx.bellman_ford | 2.1 | Function bellman_ford() is deprecated and will be removedin 2.1, use bellman_ford_predecessor_and_distance() instead. |
networkx.from_pandas_dataframe | 2.1 | from_pandas_dataframe is deprecated and will be removedin 2.1, use from_pandas_edgelist instead. |
networkx.to_pandas_dataframe | 2.1 | to_pandas_dataframe is deprecated and will be removedin 2.1, use to_pandas_adjacency instead. |
networkx.algorithms.bellman_ford | 2.1 | Function bellman_ford() is deprecated and will be removedin 2.1, use bellman_ford_predecessor_and_distance() instead. |
networkx.algorithms.community.asyn_lpa | 2.1 | |
networkx.algorithms.dag.nodes_or_number | 2.1 | From networkx.utils import nodes_or_number (still there in 3.7). |
networkx.algorithms.dag.open_file | 2.1 | From networkx.utils import open_file (still there in 3.7). |
networkx.algorithms.shortest_paths.bellman_ford | 2.1 | Function bellman_ford() is deprecated and will be removedin 2.1, use bellman_ford_predecessor_and_distance() instead. |
networkx.convert_matrix.from_pandas_dataframe | 2.1 | from_pandas_dataframe is deprecated and will be removedin 2.1, use from_pandas_edgelist instead. |
networkx.convert_matrix.to_pandas_dataframe | 2.1 | to_pandas_dataframe is deprecated and will be removedin 2.1, use to_pandas_adjacency instead. |
networkx.generators.tree | 2.1 | |
G.root_graph (DiGraph) | 2.2 | |
G.root_graph (Graph) | 2.2 | |
G.root_graph (MultiDiGraph) | 2.2 | |
G.root_graph (MultiGraph) | 2.2 | |
networkx.attracting_component_subgraphs | 2.4 | attracting_component_subgraphs is deprecated and will be removedin 2.2. Use (G.subgraph(c).copy() for c in attracting_components(G)) |
networkx.biconnected_component_subgraphs | 2.4 | connected_component_subgraphs is deprecated and will be removedin 2.2. Use (G.subgraph(c).copy() for c in biconnected_components(G)) |
networkx.connected_component_subgraphs | 2.4 | connected_component_subgraphs is deprecated and will be removedin 2.2. Use (G.subgraph(c).copy() for c in connected_components(G)) |
networkx.strongly_connected_component_subgraphs | 2.4 | strongly_connected_component_subgraphs is deprecated and will be removed in 2.2use (G.subgraph(c).copy() for c in strongly_connected_components(G)) |
networkx.weakly_connected_component_subgraphs | 2.4 | weakly_connected_component_subgraphs is deprecated and will be removed in 2.2use (G.subgraph(c).copy() for c in weakly_connected_components(G)) |
networkx.algorithms.attracting_component_subgraphs | 2.4 | attracting_component_subgraphs is deprecated and will be removedin 2.2. Use (G.subgraph(c).copy() for c in attracting_components(G)) |
networkx.algorithms.biconnected_component_subgraphs | 2.4 | connected_component_subgraphs is deprecated and will be removedin 2.2. Use (G.subgraph(c).copy() for c in biconnected_components(G)) |
networkx.algorithms.connected_component_subgraphs | 2.4 | connected_component_subgraphs is deprecated and will be removedin 2.2. Use (G.subgraph(c).copy() for c in connected_components(G)) |
networkx.algorithms.strongly_connected_component_subgraphs | 2.4 | strongly_connected_component_subgraphs is deprecated and will be removed in 2.2use (G.subgraph(c).copy() for c in strongly_connected_components(G)) |
networkx.algorithms.weakly_connected_component_subgraphs | 2.4 | weakly_connected_component_subgraphs is deprecated and will be removed in 2.2use (G.subgraph(c).copy() for c in weakly_connected_components(G)) |
networkx.algorithms.community.community_generators | 2.4 | |
networkx.algorithms.components.attracting_component_subgraphs | 2.4 | attracting_component_subgraphs is deprecated and will be removedin 2.2. Use (G.subgraph(c).copy() for c in attracting_components(G)) |
networkx.algorithms.components.biconnected_component_subgraphs | 2.4 | connected_component_subgraphs is deprecated and will be removedin 2.2. Use (G.subgraph(c).copy() for c in biconnected_components(G)) |
networkx.algorithms.components.connected_component_subgraphs | 2.4 | connected_component_subgraphs is deprecated and will be removedin 2.2. Use (G.subgraph(c).copy() for c in connected_components(G)) |
networkx.algorithms.components.strongly_connected_component_subgraphs | 2.4 | strongly_connected_component_subgraphs is deprecated and will be removed in 2.2use (G.subgraph(c).copy() for c in strongly_connected_components(G)) |
networkx.algorithms.components.weakly_connected_component_subgraphs | 2.4 | weakly_connected_component_subgraphs is deprecated and will be removed in 2.2use (G.subgraph(c).copy() for c in weakly_connected_components(G)) |
G.add_cycle (DiGraph) | 2.4 | add_cycle is deprecated. Use nx.add_cycle instead. |
G.add_path (DiGraph) | 2.4 | add_path is deprecated. Use nx.add_path instead. |
G.add_star (DiGraph) | 2.4 | add_star is deprecated. Use nx.add_star instead. |
G.fresh_copy (DiGraph) | 2.4 | G.fresh_copy is deprecated. Use G.__class__ instead |
G.node (DiGraph) | 2.4 | G.nodes: G.nodes[n] for a node's attribute dict, G.nodes(data=True) for (node, data) pairs, `for n in G:` to loop over nodes. (networkx 2.0 kept G.node as a pointer to G.nodes; 2.4 removed it.) (our note) |
G.nodes_with_selfloops (DiGraph) | 2.4 | nodes_with_selfloops is deprecated.Use nx.nodes_with_selfloops instead. |
G.number_of_selfloops (DiGraph) | 2.4 | number_of_selfloops is deprecated.Use nx.number_of_selfloops instead. |
G.selfloop_edges (DiGraph) | 2.4 | selfloop_edges is deprecated. Use nx.selfloop_edges instead. |
G.add_cycle (Graph) | 2.4 | add_cycle is deprecated. Use nx.add_cycle instead. |
G.add_path (Graph) | 2.4 | add_path is deprecated. Use nx.add_path instead. |
G.add_star (Graph) | 2.4 | add_star is deprecated. Use nx.add_star instead. |
G.fresh_copy (Graph) | 2.4 | G.fresh_copy is deprecated. Use G.__class__ instead |
G.node (Graph) | 2.4 | G.nodes: G.nodes[n] for a node's attribute dict, G.nodes(data=True) for (node, data) pairs, `for n in G:` to loop over nodes. (networkx 2.0 kept G.node as a pointer to G.nodes; 2.4 removed it.) (our note) |
G.nodes_with_selfloops (Graph) | 2.4 | nodes_with_selfloops is deprecated.Use nx.nodes_with_selfloops instead. |
G.number_of_selfloops (Graph) | 2.4 | number_of_selfloops is deprecated.Use nx.number_of_selfloops instead. |
G.selfloop_edges (Graph) | 2.4 | selfloop_edges is deprecated. Use nx.selfloop_edges instead. |
G.add_cycle (MultiDiGraph) | 2.4 | add_cycle is deprecated. Use nx.add_cycle instead. |
G.add_path (MultiDiGraph) | 2.4 | add_path is deprecated. Use nx.add_path instead. |
G.add_star (MultiDiGraph) | 2.4 | add_star is deprecated. Use nx.add_star instead. |
G.fresh_copy (MultiDiGraph) | 2.4 | G.fresh_copy is deprecated. Use G.__class__ instead |
G.node (MultiDiGraph) | 2.4 | G.nodes: G.nodes[n] for a node's attribute dict, G.nodes(data=True) for (node, data) pairs, `for n in G:` to loop over nodes. (networkx 2.0 kept G.node as a pointer to G.nodes; 2.4 removed it.) (our note) |
G.nodes_with_selfloops (MultiDiGraph) | 2.4 | nodes_with_selfloops is deprecated.Use nx.nodes_with_selfloops instead. |
G.number_of_selfloops (MultiDiGraph) | 2.4 | number_of_selfloops is deprecated.Use nx.number_of_selfloops instead. |
G.selfloop_edges (MultiDiGraph) | 2.4 | selfloop_edges is deprecated. Use nx.selfloop_edges instead. |
G.add_cycle (MultiGraph) | 2.4 | add_cycle is deprecated. Use nx.add_cycle instead. |
G.add_path (MultiGraph) | 2.4 | add_path is deprecated. Use nx.add_path instead. |
G.add_star (MultiGraph) | 2.4 | add_star is deprecated. Use nx.add_star instead. |
G.fresh_copy (MultiGraph) | 2.4 | G.fresh_copy is deprecated. Use G.__class__ instead |
G.node (MultiGraph) | 2.4 | G.nodes: G.nodes[n] for a node's attribute dict, G.nodes(data=True) for (node, data) pairs, `for n in G:` to loop over nodes. (networkx 2.0 kept G.node as a pointer to G.nodes; 2.4 removed it.) (our note) |
G.nodes_with_selfloops (MultiGraph) | 2.4 | nodes_with_selfloops is deprecated.Use nx.nodes_with_selfloops instead. |
G.number_of_selfloops (MultiGraph) | 2.4 | number_of_selfloops is deprecated.Use nx.number_of_selfloops instead. |
G.selfloop_edges (MultiGraph) | 2.4 | selfloop_edges is deprecated. Use nx.selfloop_edges instead. |
networkx.nx_yaml | 2.6.2 | pyyaml directly: yaml.dump(G, f) and yaml.load(f, Loader=yaml.Loader) (networkx 3.0 migration guide). (our note) |
networkx.read_yaml | 2.6.2 | pyyaml directly: yaml.dump(G, f) and yaml.load(f, Loader=yaml.Loader) (networkx 3.0 migration guide). (our note) |
networkx.release | 2.6.2 | |
networkx.version | 2.6.2 | |
networkx.write_yaml | 2.6.2 | pyyaml directly: yaml.dump(G, f) and yaml.load(f, Loader=yaml.Loader) (networkx 3.0 migration guide). (our note) |
networkx.algorithms.approximation.independent_set | 2.6.2 | |
networkx.readwrite.read_yaml | 2.6.2 | pyyaml directly: yaml.dump(G, f) and yaml.load(f, Loader=yaml.Loader) (networkx 3.0 migration guide). (our note) |
networkx.readwrite.write_yaml | 2.6.2 | pyyaml directly: yaml.dump(G, f) and yaml.load(f, Loader=yaml.Loader) (networkx 3.0 migration guide). (our note) |
networkx.drawing.layout.random_state | 2.7 | |
networkx.adj_matrix | 3.0 | adj_matrix is deprecated and will be removed in version 3.0. Use `adjacency_matrix` instead |
networkx.authority_matrix | 3.0 | authority_matrix is deprecated as of version 2.6 and will be removed in version 3.0. The authority matrix can be computed by:: >>> M = nx.to_numpy_array(G, nodelist=nodelist) >>> M.T @ M |
networkx.betweenness_centrality_source | 3.0 | betweenness_centrality_source --> betweenness_centrality_subset |
networkx.edge_betweenness | 3.0 | edge_betweeness is replaced by edge_betweenness_centrality |
networkx.extrema_bounding | 3.0 | extrema_bounding is deprecated and will be removed in networkx 3.0 |
networkx.find_cores | 3.0 | find_cores is deprecated as of version 2.7 and will be removed in version 3.0. The find_cores function is renamed core_number |
networkx.from_numpy_matrix | 3.0 | from_numpy_matrix is deprecated and will be removed in NetworkX 3.0. Use from_numpy_array instead, e.g. from_numpy_array(A, **kwargs) |
networkx.from_scipy_sparse_matrix | 3.0 | The scipy.sparse array containers will be used instead of matrices in Networkx 3.0. Use `from_scipy_sparse_array` instead. |
networkx.gpickle | 3.0 | The pickle module: with open(path, 'wb') as f: pickle.dump(G, f, pickle.HIGHEST_PROTOCOL), and pickle.load(f) to read (networkx 3.0 migration guide). (our note) |
networkx.hits_numpy | 3.0 | networkx.hits_numpy is deprecated and will be removedin NetworkX 3.0, use networkx.hits instead. |
networkx.hits_scipy | 3.0 | networkx.hits_scipy is deprecated and will be removedin NetworkX 3.0, use networkx.hits instead. |
networkx.hub_matrix | 3.0 | hub_matrix is deprecated as of version 2.6 and will be removed in version 3.0. The hub matrix can be computed by:: >>> M = nx.to_numpy_array(G, nodelist=nodelist) >>> M @ M.T |
networkx.info | 3.0 | info is deprecated and will be removed in version 3.0. Instead (our note): print(G): str(G) is a one-line summary in 3.7 ('Graph with 3 nodes and 2 edges'); G.number_of_nodes(), G.number_of_edges() for the numbers. |
networkx.jit | 3.0 | |
networkx.jit_data | 3.0 | jit_data is deprecated and will be removed in NetworkX 3.0. |
networkx.jit_graph | 3.0 | jit_graph is deprecated and will be removed in NetworkX 3.0. |
networkx.k_nearest_neighbors | 3.0 | k_nearest_neighbors function is deprecated and will be removed in v3.0. Use `average_degree_connectivity` instead. |
networkx.make_small_graph | 3.0 | make_small_graph is deprecated and will be removed in version 3.0. If `ltype` == 'adjacencylist', convert `xlist` to a dict and use `from_dict_of_lists` instead. If `ltype` == 'edgelist', use `from_edgelist` instead. |
networkx.numeric_mixing_matrix | 3.0 | numeric_mixing_matrix is deprecated and will be removed in v3.0. Use `attribute_mixing_matrix` instead. |
networkx.nx_shp | 3.0 | |
networkx.ordered | 3.0 | Consistently ordered variant of :class:`~networkx.Graph`. .. deprecated:: 2.6 OrderedGraph is deprecated and will be removed in version 3.0. Use `Graph` instead, which guarantees order is preserved for Python >= 3.7 |
networkx.OrderedDiGraph | 3.0 | OrderedDiGraph is deprecated and will be removed in version 3.0. Use `DiGraph` instead, which guarantees order is preserved for Python >= 3.7 |
networkx.OrderedGraph | 3.0 | OrderedGraph is deprecated and will be removed in version 3.0. Use `Graph` instead, which guarantees order is preserved for Python >= 3.7 |
networkx.OrderedMultiDiGraph | 3.0 | OrderedMultiDiGraph is deprecated and will be removed in version 3.0. Use `MultiDiGraph` instead, which guarantees order is preserved for Python >= 3.7 |
networkx.OrderedMultiGraph | 3.0 | OrderedMultiGraph is deprecated and will be removed in version 3.0. Use `MultiGraph` instead, which guarantees order is preserved for Python >= 3.7 |
networkx.pagerank_numpy | 3.0 | networkx.pagerank_numpy is deprecated and will be removed in NetworkX 3.0, use networkx.pagerank instead. |
networkx.pagerank_scipy | 3.0 | networkx.pagerank_scipy is deprecated and will be removed in NetworkX 3.0, use networkx.pagerank instead. |
networkx.project | 3.0 | networkx.project is deprecated and will be removedin NetworkX 3.0, use networkx.projected_graph instead. |
networkx.read_gpickle | 3.0 | read_gpickle is deprecated and will be removed in 3.0.Use pickle.load(path) |
networkx.read_shp | 3.0 | read_shp is deprecated and will be removed in 3.0.See https://networkx.org/documentation/latest/auto_examples/index.html#geospatial. |
networkx.simrank_similarity_numpy | 3.0 | networkx.simrank_similarity_numpy is deprecated and will be removedin NetworkX 3.0, use networkx.simrank_similarity instead. |
networkx.testing | 3.0 | |
networkx.to_numpy_matrix | 3.0 | to_numpy_matrix is deprecated and will be removed in NetworkX 3.0. Use to_numpy_array instead, e.g. np.asmatrix(to_numpy_array(G, **kwargs)) |
networkx.to_numpy_recarray | 3.0 | to_numpy_recarray is deprecated and will be removed in version 3.0. Use to_numpy_array instead:: nx.to_numpy_array(G, dtype=dtype, weight=None).view(np.recarray) |
networkx.to_scipy_sparse_matrix | 3.0 | The scipy.sparse array containers will be used instead of matrices in Networkx 3.0. Use `to_scipy_sparse_array` instead. |
networkx.write_gpickle | 3.0 | write_gpickle is deprecated and will be removed in 3.0.Use pickle.dump(G, path, protocol) |
networkx.write_shp | 3.0 | write_shp is deprecated and will be removed in 3.0.See https://networkx.org/documentation/latest/auto_examples/index.html#geospatial. |
networkx.algorithms.authority_matrix | 3.0 | authority_matrix is deprecated as of version 2.6 and will be removed in version 3.0. The authority matrix can be computed by:: >>> M = nx.to_numpy_array(G, nodelist=nodelist) >>> M.T @ M |
networkx.algorithms.betweenness_centrality_source | 3.0 | betweenness_centrality_source --> betweenness_centrality_subset |
networkx.algorithms.edge_betweenness | 3.0 | edge_betweeness is replaced by edge_betweenness_centrality |
networkx.algorithms.extrema_bounding | 3.0 | extrema_bounding is deprecated and will be removed in networkx 3.0 |
networkx.algorithms.find_cores | 3.0 | find_cores is deprecated as of version 2.7 and will be removed in version 3.0. The find_cores function is renamed core_number |
networkx.algorithms.hits_numpy | 3.0 | networkx.hits_numpy is deprecated and will be removedin NetworkX 3.0, use networkx.hits instead. |
networkx.algorithms.hits_scipy | 3.0 | networkx.hits_scipy is deprecated and will be removedin NetworkX 3.0, use networkx.hits instead. |
networkx.algorithms.hub_matrix | 3.0 | hub_matrix is deprecated as of version 2.6 and will be removed in version 3.0. The hub matrix can be computed by:: >>> M = nx.to_numpy_array(G, nodelist=nodelist) >>> M @ M.T |
networkx.algorithms.k_nearest_neighbors | 3.0 | k_nearest_neighbors function is deprecated and will be removed in v3.0. Use `average_degree_connectivity` instead. |
networkx.algorithms.numeric_mixing_matrix | 3.0 | numeric_mixing_matrix is deprecated and will be removed in v3.0. Use `attribute_mixing_matrix` instead. |
networkx.algorithms.pagerank_numpy | 3.0 | networkx.pagerank_numpy is deprecated and will be removed in NetworkX 3.0, use networkx.pagerank instead. |
networkx.algorithms.pagerank_scipy | 3.0 | networkx.pagerank_scipy is deprecated and will be removed in NetworkX 3.0, use networkx.pagerank instead. |
networkx.algorithms.project | 3.0 | networkx.project is deprecated and will be removedin NetworkX 3.0, use networkx.projected_graph instead. |
networkx.algorithms.simrank_similarity_numpy | 3.0 | networkx.simrank_similarity_numpy is deprecated and will be removedin NetworkX 3.0, use networkx.simrank_similarity instead. |
networkx.algorithms.bipartite.project | 3.0 | networkx.project is deprecated and will be removedin NetworkX 3.0, use networkx.projected_graph instead. |
networkx.algorithms.centrality.betweenness_centrality_source | 3.0 | betweenness_centrality_source --> betweenness_centrality_subset |
networkx.algorithms.centrality.edge_betweenness | 3.0 | edge_betweeness is replaced by edge_betweenness_centrality |
networkx.classes.info | 3.0 | info is deprecated and will be removed in version 3.0. Instead (our note): print(G): str(G) is a one-line summary in 3.7 ('Graph with 3 nodes and 2 edges'); G.number_of_nodes(), G.number_of_edges() for the numbers. |
networkx.classes.ordered | 3.0 | Consistently ordered variant of :class:`~networkx.Graph`. .. deprecated:: 2.6 OrderedGraph is deprecated and will be removed in version 3.0. Use `Graph` instead, which guarantees order is preserved for Python >= 3.7 |
networkx.classes.OrderedDiGraph | 3.0 | OrderedDiGraph is deprecated and will be removed in version 3.0. Use `DiGraph` instead, which guarantees order is preserved for Python >= 3.7 |
networkx.classes.OrderedGraph | 3.0 | OrderedGraph is deprecated and will be removed in version 3.0. Use `Graph` instead, which guarantees order is preserved for Python >= 3.7 |
networkx.classes.OrderedMultiDiGraph | 3.0 | OrderedMultiDiGraph is deprecated and will be removed in version 3.0. Use `MultiDiGraph` instead, which guarantees order is preserved for Python >= 3.7 |
networkx.classes.OrderedMultiGraph | 3.0 | OrderedMultiGraph is deprecated and will be removed in version 3.0. Use `MultiGraph` instead, which guarantees order is preserved for Python >= 3.7 |
networkx.classes.function.info | 3.0 | info is deprecated and will be removed in version 3.0. Instead (our note): print(G): str(G) is a one-line summary in 3.7 ('Graph with 3 nodes and 2 edges'); G.number_of_nodes(), G.number_of_edges() for the numbers. |
networkx.convert_matrix.from_numpy_matrix | 3.0 | from_numpy_matrix is deprecated and will be removed in NetworkX 3.0. Use from_numpy_array instead, e.g. from_numpy_array(A, **kwargs) |
networkx.convert_matrix.from_scipy_sparse_matrix | 3.0 | The scipy.sparse array containers will be used instead of matrices in Networkx 3.0. Use `from_scipy_sparse_array` instead. |
networkx.convert_matrix.to_numpy_matrix | 3.0 | to_numpy_matrix is deprecated and will be removed in NetworkX 3.0. Use to_numpy_array instead, e.g. np.asmatrix(to_numpy_array(G, **kwargs)) |
networkx.convert_matrix.to_numpy_recarray | 3.0 | to_numpy_recarray is deprecated and will be removed in version 3.0. Use to_numpy_array instead:: nx.to_numpy_array(G, dtype=dtype, weight=None).view(np.recarray) |
networkx.convert_matrix.to_scipy_sparse_matrix | 3.0 | The scipy.sparse array containers will be used instead of matrices in Networkx 3.0. Use `to_scipy_sparse_array` instead. |
networkx.drawing.nx_agraph.display_pygraphviz | 3.0 | display_pygraphviz is deprecated and will be removed in NetworkX 3.0. To view a graph G using pygraphviz, use nx.nx_agraph.view_pygraphviz(G). To view a graph from file, consider an image processing libary like `Pillow`, e.g. PIL.Image.open(path.name).show() |
networkx.generators.make_small_graph | 3.0 | make_small_graph is deprecated and will be removed in version 3.0. If `ltype` == 'adjacencylist', convert `xlist` to a dict and use `from_dict_of_lists` instead. If `ltype` == 'edgelist', use `from_edgelist` instead. |
networkx.linalg.adj_matrix | 3.0 | adj_matrix is deprecated and will be removed in version 3.0. Use `adjacency_matrix` instead |
networkx.readwrite.gpickle | 3.0 | The pickle module: with open(path, 'wb') as f: pickle.dump(G, f, pickle.HIGHEST_PROTOCOL), and pickle.load(f) to read (networkx 3.0 migration guide). (our note) |
networkx.readwrite.jit | 3.0 | |
networkx.readwrite.jit_data | 3.0 | jit_data is deprecated and will be removed in NetworkX 3.0. |
networkx.readwrite.jit_graph | 3.0 | jit_graph is deprecated and will be removed in NetworkX 3.0. |
networkx.readwrite.nx_shp | 3.0 | |
networkx.readwrite.nx_yaml | 3.0 | pyyaml directly: yaml.dump(G, f) and yaml.load(f, Loader=yaml.Loader) (networkx 3.0 migration guide). (our note) |
networkx.readwrite.read_gpickle | 3.0 | read_gpickle is deprecated and will be removed in 3.0.Use pickle.load(path) |
networkx.readwrite.read_shp | 3.0 | read_shp is deprecated and will be removed in 3.0.See https://networkx.org/documentation/latest/auto_examples/index.html#geospatial. |
networkx.readwrite.write_gpickle | 3.0 | write_gpickle is deprecated and will be removed in 3.0.Use pickle.dump(G, path, protocol) |
networkx.readwrite.write_shp | 3.0 | write_shp is deprecated and will be removed in 3.0.See https://networkx.org/documentation/latest/auto_examples/index.html#geospatial. |
networkx.readwrite.json_graph.jit | 3.0 | |
networkx.readwrite.json_graph.jit_data | 3.0 | jit_data is deprecated and will be removed in NetworkX 3.0. |
networkx.readwrite.json_graph.jit_graph | 3.0 | jit_graph is deprecated and will be removed in NetworkX 3.0. |
networkx.utils.consume | 3.0 | consume is deprecated and will be removed in version 3.0. Use collections.deque(iterator, maxlen=0) instead. |
networkx.utils.contextmanagers | 3.0 | |
networkx.utils.default_opener | 3.0 | default_opener is deprecated and will be removed in version 3.0. |
networkx.utils.dict_to_numpy_array1 | 3.0 | dict_to_numpy_array1 is deprecated and will be removed in networkx 3.0. Use dict_to_numpy_array instead. |
networkx.utils.dict_to_numpy_array2 | 3.0 | dict_to_numpy_array2 is deprecated and will be removed in networkx 3.0. Use dict_to_numpy_array instead. |
networkx.utils.empty_generator | 3.0 | empty_generator is deprecated and will be removed in v3.0. |
networkx.utils.generate_unique_node | 3.0 | generate_unique_node is deprecated and will be removed in 3.0. Use uuid.uuid4 instead. |
networkx.utils.is_iterator | 3.0 | is_iterator is deprecated and will be removed in version 3.0. Use isinstance(obj, collections.abc.Iterator) instead. |
networkx.utils.is_list_of_ints | 3.0 | is_list_of_ints is deprecated and will be removed in 3.0.See also: networkx.utils.make_list_of_ints. |
networkx.utils.is_string_like | 3.0 | is_string_like is deprecated and will be removed in 3.0.Use isinstance(obj, str) instead. |
networkx.utils.iterable | 3.0 | iterable is deprecated and will be removed in 3.0.Use isinstance(obj, (collections.abc.Iterable, collections.abc.Sized)) instead. |
networkx.utils.make_str | 3.0 | make_str is deprecated and will be removed in 3.0. Use str instead. |
networkx.utils.preserve_random_state | 3.0 | preserve_random_state is deprecated and will be removed in 3.0. |
networkx.utils.random_state | 3.0 | `random_state` is a deprecated alias for `np_random_state` and will be removed in version 3.0. Use `np_random_state` instead. |
networkx.utils.reversed | 3.0 | context manager reversed is deprecated and to be removed in 3.0.Use G.reverse(copy=False) if G.is_directed() else G instead. |
networkx.utils.to_tuple | 3.0 | to_tuple is deprecated and will be removed in NetworkX 3.0. |
networkx.utils.decorators.preserve_random_state | 3.0 | preserve_random_state is deprecated and will be removed in 3.0. |
networkx.utils.decorators.random_state | 3.0 | `random_state` is a deprecated alias for `np_random_state` and will be removed in version 3.0. Use `np_random_state` instead. |
networkx.backends | 3.2 | From networkx.utils import backends (still there in 3.7). |
networkx.cliques_containing_node | 3.2 | cliques_containing_node is deprecated and will be removed. Use the result of find_cliques directly to compute maximal cliques containing each node: {n: [c for c in nx.find_cliques(G) if n in c] for n in G} |
networkx.graph_clique_number | 3.2 | graph_clique_number is deprecated and will be removed. Use: max(len(c) for c in nx.find_cliques(G)) instead. |
networkx.graph_number_of_cliques | 3.2 | graph_number_of_cliques is deprecated and will be removed. Use: sum(1 for _ in nx.find_cliques(G)) instead. |
networkx.algorithms.cliques_containing_node | 3.2 | cliques_containing_node is deprecated and will be removed. Use the result of find_cliques directly to compute maximal cliques containing each node: {n: [c for c in nx.find_cliques(G) if n in c] for n in G} |
networkx.algorithms.graph_clique_number | 3.2 | graph_clique_number is deprecated and will be removed. Use: max(len(c) for c in nx.find_cliques(G)) instead. |
networkx.algorithms.graph_number_of_cliques | 3.2 | graph_number_of_cliques is deprecated and will be removed. Use: sum(1 for _ in nx.find_cliques(G)) instead. |
networkx.classes.backends | 3.2 | |
networkx.classes.function.reverse_view | 3.2 | From networkx import reverse_view (still there in 3.7). |
networkx.classes.function.subgraph_view | 3.2 | From networkx import subgraph_view (still there in 3.7). |
networkx.forest_str | 3.4 | forest_str is deprecated as of version 3.1 and will be removed in version 3.3. Use generate_network_text or write_network_text instead. |
networkx.join | 3.4 | The function `join` is deprecated and is renamed `join_trees`. The join function itself will be removed in v3.4 |
networkx.random_tree | 3.4 | random_tree is deprecated and will be removed in NX v3.4 Use random_labeled_tree instead. |
networkx.strongly_connected_components_recursive | 3.4 | strongly_connected_components_recursive is deprecated and will be removed in the future. Use strongly_connected_components instead. |
networkx.algorithms.join | 3.4 | The function `join` is deprecated and is renamed `join_trees`. The join function itself will be removed in v3.4 |
networkx.algorithms.strongly_connected_components_recursive | 3.4 | strongly_connected_components_recursive is deprecated and will be removed in the future. Use strongly_connected_components instead. |
networkx.algorithms.components.strongly_connected_components_recursive | 3.4 | strongly_connected_components_recursive is deprecated and will be removed in the future. Use strongly_connected_components instead. |
networkx.algorithms.tree.Edmonds | 3.4 | Edmonds has been deprecated |
networkx.algorithms.tree.join | 3.4 | The function `join` is deprecated and is renamed `join_trees`. The join function itself will be removed in v3.4 |
networkx.generators.random_tree | 3.4 | random_tree is deprecated and will be removed in NX v3.4 Use random_labeled_tree instead. |
networkx.readwrite.forest_str | 3.4 | forest_str is deprecated as of version 3.1 and will be removed in version 3.3. Use generate_network_text or write_network_text instead. |
networkx.utils.deprecate_positional_args | 3.4.1 | |
networkx.utils.decorators.deprecate_positional_args | 3.4.1 | |
networkx.all_triplets | 3.5 | all_triplets is deprecated and will be removed in v3.5. Use `itertools.combinations(G, 3)` instead. |
networkx.d_separated | 3.5 | d_separated is deprecated and will be removed in NetworkX v3.5.Please use `is_d_separator(G, x, y, z)`. |
networkx.minimal_d_separator | 3.5 | This function is deprecated and will be removed in NetworkX v3.5.Please use `is_d_separator(G, x, y)`. |
networkx.random_triad | 3.5 | random_triad is deprecated and will be removed in NetworkX v3.5. Use random.sample instead, e.g.:: G.subgraph(random.sample(list(G), 3)) |
networkx.total_spanning_tree_weight | 3.5 | total_spanning_tree_weight is deprecated and will be removed in v3.5. Use `nx.number_of_spanning_trees(G)` instead. |
networkx.algorithms.all_triplets | 3.5 | all_triplets is deprecated and will be removed in v3.5. Use `itertools.combinations(G, 3)` instead. |
networkx.algorithms.d_separated | 3.5 | d_separated is deprecated and will be removed in NetworkX v3.5.Please use `is_d_separator(G, x, y, z)`. |
networkx.algorithms.minimal_d_separator | 3.5 | This function is deprecated and will be removed in NetworkX v3.5.Please use `is_d_separator(G, x, y)`. |
networkx.algorithms.random_triad | 3.5 | random_triad is deprecated and will be removed in NetworkX v3.5. Use random.sample instead, e.g.:: G.subgraph(random.sample(list(G), 3)) |
networkx.drawing.nx_pylab.circular_layout | 3.5 | From networkx import circular_layout (still there in 3.7). |
networkx.drawing.nx_pylab.forceatlas2_layout | 3.5 | From networkx import forceatlas2_layout (still there in 3.7). |
networkx.drawing.nx_pylab.kamada_kawai_layout | 3.5 | From networkx import kamada_kawai_layout (still there in 3.7). |
networkx.drawing.nx_pylab.planar_layout | 3.5 | From networkx import planar_layout (still there in 3.7). |
networkx.drawing.nx_pylab.random_layout | 3.5 | From networkx import random_layout (still there in 3.7). |
networkx.drawing.nx_pylab.shell_layout | 3.5 | From networkx import shell_layout (still there in 3.7). |
networkx.drawing.nx_pylab.spectral_layout | 3.5 | From networkx import spectral_layout (still there in 3.7). |
networkx.drawing.nx_pylab.spring_layout | 3.5 | From networkx import spring_layout (still there in 3.7). |
networkx.linalg.total_spanning_tree_weight | 3.5 | total_spanning_tree_weight is deprecated and will be removed in v3.5. Use `nx.number_of_spanning_trees(G)` instead. |
networkx.compute_v_structures | 3.6 | `compute_v_structures` actually yields colliders. It will be removed in version 3.6. Use `nx.dag.v_structures` or `nx.dag.colliders` instead. |
networkx.algorithms.compute_v_structures | 3.6 | `compute_v_structures` actually yields colliders. It will be removed in version 3.6. Use `nx.dag.v_structures` or `nx.dag.colliders` instead. |
networkx.algorithms.dag.compute_v_structures | 3.6 | `compute_v_structures` actually yields colliders. It will be removed in version 3.6. Use `nx.dag.v_structures` or `nx.dag.colliders` instead. |
networkx.algorithms.community.kernighan_lin | 3.6.1 | |
networkx.random_lobster | 3.7 | `random_lobster` is deprecated, use `random_lobster_graph` instead. |
networkx.generators.random_lobster | 3.7 | `random_lobster` is deprecated, use `random_lobster_graph` instead. |
How was this measured?
Each of 33 networkx releases (every release from 1.11 to 3.7, patch releases included) was installed from PyPI in its own environment, the public names of 31 networkx modules and of the Graph, DiGraph, MultiGraph and MultiDiGraph classes were listed with dir(), and getattr was run for the union of all names in every release. A small graph of each class was also built and checked with hasattr, because networkx 1.x set G.node and G.edge on the object, not the class. Releases: 1.11, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.5.1, 2.6.2, 2.6.3, 2.7, 2.7.1, 2.8, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.8.5, 2.8.6, 2.8.7, 2.8.8, 3.0, 3.1 (Python 3.8); 3.2, 3.2.1 (Python 3.9); 3.3, 3.4, 3.4.1, 3.4.2 (Python 3.10); 3.5, 3.6, 3.6.1 (Python 3.11); 3.7 (Python 3.12). 1.11 and 2.0 to 2.5.1 were installed with decorator 4.4.2, and 1.11 to 2.2 with setuptools below 70 (they import pkg_resources).
The table keeps class members, names in any module's __all__ (networkx re-exports them at the top) and names networkx itself deprecated; helpers a module merely imported are left out, but the lookup still answers for them. The text is read from the installed source of the last release that had the name: the warnings.warn(..., DeprecationWarning) in its body, with a local msg = ... resolved.
Questions
How do I fix "module 'networkx' has no attribute 'from_numpy_matrix'"?
networkx 3.0 (2023-01-08) removed from_numpy_matrix and to_numpy_matrix; 2.6 to 2.8 warn when they are called. Use nx.from_numpy_array(A) and nx.to_numpy_array(G), which take the same arguments; wrap with np.asmatrix(...) if you really need a matrix. The same release removed from_scipy_sparse_matrix and to_scipy_sparse_matrix: use from_scipy_sparse_array and to_scipy_sparse_array.
How do I fix "module 'networkx' has no attribute 'read_gpickle'"?
networkx 3.0 removed read_gpickle, write_gpickle and the networkx.readwrite.gpickle module. Use pickle directly: with open('g.gpickle', 'wb') as f: pickle.dump(G, f, pickle.HIGHEST_PROTOCOL); and with open('g.gpickle', 'rb') as f: G = pickle.load(f). A file written by write_gpickle in 2.8.8 loads this way in 3.7 (tried).
How do I fix "'Graph' object has no attribute 'node'"?
networkx 2.4 (2019-10-17) removed G.node; 2.0 to 2.3 kept it as a pointer to G.nodes. Use G.nodes[n] for a node's attribute dict, G.nodes(data=True) for (node, data) pairs, and for n in G: to loop. The same release removed G.add_path, G.add_cycle, G.add_star and G.selfloop_edges (use nx.add_path(G, ...), nx.selfloop_edges(G)).
How do I fix "module 'networkx' has no attribute 'connected_component_subgraphs'"?
networkx 2.4 removed connected_component_subgraphs (and the strongly, weakly and biconnected versions); 2.1 to 2.3 warned. Use (G.subgraph(c).copy() for c in nx.connected_components(G)), or max(nx.connected_components(G), key=len) for the largest component's nodes.
How do I fix "'Graph' object has no attribute 'nodes_iter'" (or edges_iter, degree_iter)?
networkx 2.0 (2017-09-20) removed every *_iter method. Call the method without _iter: G.nodes(), G.edges(), G.degree(), G.neighbors(n); they return views or iterators. G.edge also went in 2.0: use G.adj (G.adj[u][v] is the edge data dict).
How do I fix "module 'networkx' has no attribute 'info'"?
networkx 3.0 removed nx.info. print(G) gives the same one-line summary ('Graph with 3 nodes and 2 edges'); use G.number_of_nodes() and G.number_of_edges() for the numbers.
Sources
- The networkx packages on PyPI, installed and run, and their source as installed; the release dates are PyPI's.
- networkx's migration guide from 1.x to 2.0, from 2.x to 3.0 and release notes (for the notes).
The same data as JSON: networkx_names.json, licensed CC BY 4.0.
Related: "module 'numpy' has no attribute 'float_'" · "cannot import name 'triu' from 'scipy.linalg'" · "module 'matplotlib.cm' has no attribute 'get_cmap'".