summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/reference/functions.rst1
-rw-r--r--examples/algorithms/plot_parallel_betweenness.py2
-rw-r--r--networkx/algorithms/connectivity/tests/test_kcutsets.py1
-rw-r--r--networkx/classes/function.py46
-rw-r--r--networkx/classes/graph.py3
-rw-r--r--networkx/classes/tests/test_function.py32
-rw-r--r--networkx/convert_matrix.py2
7 files changed, 4 insertions, 83 deletions
diff --git a/doc/reference/functions.rst b/doc/reference/functions.rst
index 04ad1e57..a859bc87 100644
--- a/doc/reference/functions.rst
+++ b/doc/reference/functions.rst
@@ -12,7 +12,6 @@ Graph
degree
degree_histogram
density
- info
create_empty_copy
is_directed
to_directed
diff --git a/examples/algorithms/plot_parallel_betweenness.py b/examples/algorithms/plot_parallel_betweenness.py
index d9333f45..e6d238dd 100644
--- a/examples/algorithms/plot_parallel_betweenness.py
+++ b/examples/algorithms/plot_parallel_betweenness.py
@@ -65,7 +65,7 @@ G_ws = nx.connected_watts_strogatz_graph(1000, 4, 0.1)
for G in [G_ba, G_er, G_ws]:
print("")
print("Computing betweenness centrality for:")
- print(nx.info(G))
+ print(G)
print("\tParallel version")
start = time.time()
bt = betweenness_centrality_parallel(G)
diff --git a/networkx/algorithms/connectivity/tests/test_kcutsets.py b/networkx/algorithms/connectivity/tests/test_kcutsets.py
index 91426f17..3d48c4ce 100644
--- a/networkx/algorithms/connectivity/tests/test_kcutsets.py
+++ b/networkx/algorithms/connectivity/tests/test_kcutsets.py
@@ -241,7 +241,6 @@ def test_non_repeated_cuts():
solution = [{32, 33}, {2, 33}, {0, 3}, {0, 1}, {29, 33}]
cuts = list(nx.all_node_cuts(G))
if len(solution) != len(cuts):
- print(nx.info(G))
print(f"Solution: {solution}")
print(f"Result: {cuts}")
assert len(solution) == len(cuts)
diff --git a/networkx/classes/function.py b/networkx/classes/function.py
index 7707ec4c..27e5bc6f 100644
--- a/networkx/classes/function.py
+++ b/networkx/classes/function.py
@@ -18,7 +18,6 @@ __all__ = [
"number_of_edges",
"density",
"is_directed",
- "info",
"freeze",
"is_frozen",
"subgraph",
@@ -552,51 +551,6 @@ def create_empty_copy(G, with_data=True):
return H
-def info(G, n=None):
- """Return a summary of information for the graph G or a single node n.
-
- The summary includes the number of nodes and edges, or neighbours for a single
- node.
-
- Parameters
- ----------
- G : Networkx graph
- A graph
- n : node (any hashable)
- A node in the graph G
-
- Returns
- -------
- info : str
- A string containing the short summary
-
- Raises
- ------
- NetworkXError
- If n is not in the graph G
-
- .. deprecated:: 2.7
- ``info`` is deprecated and will be removed in NetworkX 3.0.
- """
- import warnings
-
- warnings.warn(
- ("info is deprecated and will be removed in version 3.0.\n"),
- DeprecationWarning,
- stacklevel=2,
- )
- if n is None:
- return str(G)
- if n not in G:
- raise nx.NetworkXError(f"node {n} not in graph")
- info = "" # append this all to a string
- info += f"Node {n} has the following properties:\n"
- info += f"Degree: {G.degree(n)}\n"
- info += "Neighbors: "
- info += " ".join(str(nbr) for nbr in G.neighbors(n))
- return info
-
-
def set_node_attributes(G, values, name=None):
"""Sets node attributes from a given value or dictionary of values.
diff --git a/networkx/classes/graph.py b/networkx/classes/graph.py
index 5bc77b75..88e98f75 100644
--- a/networkx/classes/graph.py
+++ b/networkx/classes/graph.py
@@ -378,7 +378,8 @@ class Graph:
Returns
-------
info : string
- Graph information as provided by `nx.info`
+ Graph information including the graph name (if any), graph type, and the
+ number of nodes and edges.
Examples
--------
diff --git a/networkx/classes/tests/test_function.py b/networkx/classes/tests/test_function.py
index 051d655c..a9c60ba0 100644
--- a/networkx/classes/tests/test_function.py
+++ b/networkx/classes/tests/test_function.py
@@ -260,38 +260,6 @@ class TestFunction:
assert G.frozen == nx.is_frozen(self.G)
assert G.frozen
- def test_info(self):
- G = nx.path_graph(5)
- G.name = "path_graph(5)"
- info = nx.info(G)
- expected_graph_info = "Graph named 'path_graph(5)' with 5 nodes and 4 edges"
- assert info == expected_graph_info
-
- info = nx.info(G, n=1)
- assert type(info) == str
- expected_node_info = "\n".join(
- ["Node 1 has the following properties:", "Degree: 2", "Neighbors: 0 2"]
- )
- assert info == expected_node_info
-
- # must raise an error for a non-existent node
- pytest.raises(nx.NetworkXError, nx.info, G, 1248)
-
- def test_info_digraph(self):
- G = nx.DiGraph(name="path_graph(5)")
- nx.add_path(G, [0, 1, 2, 3, 4])
- info = nx.info(G)
- expected_graph_info = "DiGraph named 'path_graph(5)' with 5 nodes and 4 edges"
- assert info == expected_graph_info
-
- info = nx.info(G, n=1)
- expected_node_info = "\n".join(
- ["Node 1 has the following properties:", "Degree: 2", "Neighbors: 2"]
- )
- assert info == expected_node_info
-
- pytest.raises(nx.NetworkXError, nx.info, G, n=-1)
-
def test_neighbors_complete_graph(self):
graph = nx.complete_graph(100)
pop = random.sample(list(graph), 1)
diff --git a/networkx/convert_matrix.py b/networkx/convert_matrix.py
index 56443806..eef2bece 100644
--- a/networkx/convert_matrix.py
+++ b/networkx/convert_matrix.py
@@ -194,7 +194,7 @@ def from_pandas_adjacency(df, create_using=None):
1 2 1
>>> G = nx.from_pandas_adjacency(df)
>>> G.name = "Graph from pandas adjacency matrix"
- >>> print(nx.info(G))
+ >>> print(G)
Graph named 'Graph from pandas adjacency matrix' with 2 nodes and 3 edges
"""