Repository: networkx/networkx

Issue:
`nonisomorphic_trees`  create argument
the `nonisomorphic_trees` graph generator has [an argument](https://github.com/networkx/networkx/blob/2da36864c5899cbc55fc98c96635390dd96d5f88/networkx/generators/nonisomorphic_trees.py#L16) named `create` which toggles whether graphs are returned as either nx.Graph instances, or adjacency matrices in list-of-list format.

From a quick review of this function, I'm wondering if it might not be worth deprecating this `create` argument. For one thing, it is very similar to `create_using=` which is ubiquitous among the graph generation functions and has a very different meaning! Also I'm not sure that returning adjacency matrices as `list` should even be an option - if anything I'd expect users to want adjacency matrices in a form more suitable for efficient computation, i.e. numpy arrays. The latter would be possible with something like `np.to_numpy_array(G) for G in nx.nonisomorphic_trees(order)`, so there is a straightforward way to get the (arguably more desirable) behavior after a deprecation. 


Discussion:

Resolving patch:
diff --git a/networkx/conftest.py b/networkx/conftest.py
--- a/networkx/conftest.py
+++ b/networkx/conftest.py
@@ -148,6 +148,9 @@ def set_warnings():
     warnings.filterwarnings(
         "ignore", category=DeprecationWarning, message="\n\nk_corona"
     )
+    warnings.filterwarnings(
+        "ignore", category=DeprecationWarning, message=r"\n\nThe 'create=matrix'"
+    )
 
 
 @pytest.fixture(autouse=True)
diff --git a/networkx/generators/nonisomorphic_trees.py b/networkx/generators/nonisomorphic_trees.py
--- a/networkx/generators/nonisomorphic_trees.py
+++ b/networkx/generators/nonisomorphic_trees.py
@@ -25,6 +25,15 @@ def nonisomorphic_trees(order, create="graph"):
        If ``"graph"`` is selected a list of ``Graph`` instances will be returned,
        if matrix is selected a list of adjacency matrices will be returned.
 
+       .. deprecated:: 3.3
+
+          The `create` argument is deprecated and will be removed in NetworkX
+          version 3.5. In the future, `nonisomorphic_trees` will yield graph
+          instances by default. To generate adjacency matrices, call
+          ``nx.to_numpy_array`` on the output, e.g.::
+
+             [nx.to_numpy_array(G) for G in nx.nonisomorphic_trees(N)]
+
     Yields
     ------
     list
@@ -45,6 +54,20 @@ def nonisomorphic_trees(order, create="graph"):
             if create == "graph":
                 yield _layout_to_graph(layout)
             elif create == "matrix":
+                import warnings
+
+                warnings.warn(
+                    (
+                        "\n\nThe 'create=matrix' argument of nonisomorphic_trees\n"
+                        "is deprecated and will be removed in version 3.5.\n"
+                        "Use ``nx.to_numpy_array`` to convert graphs to adjacency "
+                        "matrices, e.g.::\n\n"
+                        "   [nx.to_numpy_array(G) for G in nx.nonisomorphic_trees(N)]"
+                    ),
+                    category=DeprecationWarning,
+                    stacklevel=2,
+                )
+
                 yield _layout_to_matrix(layout)
             layout = _next_rooted_tree(layout)
 


Test patch:
diff --git a/networkx/generators/tests/test_nonisomorphic_trees.py b/networkx/generators/tests/test_nonisomorphic_trees.py
--- a/networkx/generators/tests/test_nonisomorphic_trees.py
+++ b/networkx/generators/tests/test_nonisomorphic_trees.py
@@ -1,10 +1,8 @@
 """
-====================
-Generators - Non Isomorphic Trees
-====================
-
 Unit tests for WROM algorithm generator in generators/nonisomorphic_trees.py
 """
+import pytest
+
 import networkx as nx
 from networkx.utils import edges_equal
 
@@ -54,11 +52,16 @@ def f(x):
 
     def test_nonisomorphic_trees_matrix(self):
         trees_2 = [[[0, 1], [1, 0]]]
-        assert list(nx.nonisomorphic_trees(2, create="matrix")) == trees_2
+        with pytest.deprecated_call():
+            assert list(nx.nonisomorphic_trees(2, create="matrix")) == trees_2
+
         trees_3 = [[[0, 1, 1], [1, 0, 0], [1, 0, 0]]]
-        assert list(nx.nonisomorphic_trees(3, create="matrix")) == trees_3
+        with pytest.deprecated_call():
+            assert list(nx.nonisomorphic_trees(3, create="matrix")) == trees_3
+
         trees_4 = [
             [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0]],
             [[0, 1, 1, 1], [1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0]],
         ]
-        assert list(nx.nonisomorphic_trees(4, create="matrix")) == trees_4
+        with pytest.deprecated_call():
+            assert list(nx.nonisomorphic_trees(4, create="matrix")) == trees_4