Repository: networkx/networkx

Issue:
Deprecate `make_small_graph` and `make_small_undirected_graph` from `small` submodule?
These two functions are defined in the `generators.small` submodule, and are used internally within the module to generate many of the graphs therein. `make_small_graph` is publicly exposed in the namespace, while `make_small_undirected_graph` is not.

Looking at the implementation however, it seems that these functions insert an unnecessary layer of indirection (i.e. a `graph_description` argument that is actually a custom structured list that must be unpacked/parsed)  and complexity (see the node remapping) on top of functionality that is already provided by e.g. `nx.from_edgelist` and `nx.from_dict_of_lists`. AFAICT, `make_small_graph` doesn't add anything that can't be achieved in a more straightforward manner with `from_edgelist` and `from_dict_of_lists` - would there be appetite for it (and `make_small_undirected_graph`) and refactoring the `small` module to use more "canonical" NetworkX graph creation functions?


Discussion:
+1 on deprecation. I'm not sure if we still need `make_small_graph`, `from_dict_of_lists` is definitely more canonical NetworkX IMO.

PS: Most of the `make_small_graph` code hasn't been touched in 17 years!
Awesome, thanks taking a look @MridulS . Any deprecation would depend on #5267 going in, so I'll wait for that. I'll add a milestone to this one though so it doesn't get lost!

Resolving patch:
diff --git a/networkx/conftest.py b/networkx/conftest.py
--- a/networkx/conftest.py
+++ b/networkx/conftest.py
@@ -226,6 +226,9 @@ def set_warnings():
         "ignore", category=DeprecationWarning, message="\nfind_cores"
     )
     warnings.filterwarnings("ignore", category=FutureWarning, message="attr_matrix")
+    warnings.filterwarnings(
+        "ignore", category=DeprecationWarning, message=r"\n\nmake_small_.*"
+    )
 
 
 @pytest.fixture(autouse=True)
diff --git a/networkx/generators/small.py b/networkx/generators/small.py
--- a/networkx/generators/small.py
+++ b/networkx/generators/small.py
@@ -63,8 +63,26 @@ def make_small_undirected_graph(graph_description, create_using=None):
     """
     Return a small undirected graph described by graph_description.
 
+    .. deprecated:: 2.7
+
+       make_small_undirected_graph is deprecated and will be removed in
+       version 3.0. If "ltype" == "adjacencylist", convert the list to a dict
+       and use `from_dict_of_lists`. If "ltype" == "edgelist", use
+       `from_edgelist`.
+
     See make_small_graph.
     """
+    import warnings
+
+    msg = (
+        "\n\nmake_small_undirected_graph is deprecated and will be removed in "
+        "version 3.0.\n"
+        "If `ltype` == 'adjacencylist', convert `xlist` to a dict and use\n"
+        "`from_dict_of_lists` instead.\n"
+        "If `ltype` == 'edgelist', use `from_edgelist` instead."
+    )
+    warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
+
     G = empty_graph(0, create_using)
     if G.is_directed():
         raise NetworkXError("Directed Graph not supported")
@@ -75,6 +93,13 @@ def make_small_graph(graph_description, create_using=None):
     """
     Return the small graph described by graph_description.
 
+    .. deprecated:: 2.7
+
+       make_small_graph is deprecated and will be removed in
+       version 3.0. If "ltype" == "adjacencylist", convert the list to a dict
+       and use `from_dict_of_lists`. If "ltype" == "edgelist", use
+       `from_edgelist`.
+
     graph_description is a list of the form [ltype,name,n,xlist]
 
     Here ltype is one of "adjacencylist" or "edgelist",
@@ -105,6 +130,15 @@ def make_small_graph(graph_description, create_using=None):
 
     Use the create_using argument to choose the graph class/type.
     """
+    import warnings
+
+    msg = (
+        "\n\nmake_small_graph is deprecated and will be removed in version 3.0.\n"
+        "If `ltype` == 'adjacencylist', convert `xlist` to a dict and use\n"
+        "`from_dict_of_lists` instead.\n"
+        "If `ltype` == 'edgelist', use `from_edgelist` instead."
+    )
+    warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
 
     if graph_description[0] not in ("adjacencylist", "edgelist"):
         raise NetworkXError("ltype must be either adjacencylist or edgelist")


Test patch: