Repository: networkx/networkx

Issue:
Document walk_type in directed_laplacian and friends
The current documentation of the "walk_type" argument to the many directed laplacian matrix approaches is opaque. And the logic is hidden within the actual code because it occurs in a helper function presumably so the logic is the same for all these functions. The logic should be fairly straightforward to explain. For the directed graph case it is given in `linalg.laplacianmatrix._transition_matrix` as
```python
    if walk_type is None:
        if nx.is_strongly_connected(G):
            if nx.is_aperiodic(G):
                walk_type = "random"
            else:
                walk_type = "lazy"
        else:
            walk_type = "pagerank"
```
We should put a word description of this into the `walk_type` parameter description..


Discussion:

Patch:
diff --git a/doc/developer/deprecations.rst b/doc/developer/deprecations.rst
index a2c6700ce..3b8ce95c5 100644
--- a/doc/developer/deprecations.rst
+++ b/doc/developer/deprecations.rst
@@ -46,10 +46,6 @@ Version 3.3
 * Remove pydot functionality ``drawing/nx_pydot.py``, if pydot is still not being maintained. See #5723
 * Remove the ``forest_str`` function from ``readwrite/text.py``. Replace
   existing usages with ``write_network_text``.
-* Change ``single_target_shortest_path_length`` in ``algorithms/shortest_path/unweighted.py``
-  to return a dict. See #6527
-* Change ``shortest_path`` in ``algorithms/shortest_path/generic.py``
-  to return a iterator. See #6527
 
 Version 3.4
 ~~~~~~~~~~~
@@ -69,3 +65,7 @@ Version 3.5
 * Remove ``all_triplets`` from ``algorithms/triads.py``
 * Remove ``random_triad`` from ``algorithms/triad.py``.
 * Add `not_implemented_for("multigraph”)` decorator to ``k_core``, ``k_shell``, ``k_crust`` and ``k_corona`` functions.
+* Change ``single_target_shortest_path_length`` in ``algorithms/shortest_path/unweighted.py``
+  to return a dict. See #6527
+* Change ``shortest_path`` in ``algorithms/shortest_path/generic.py``
+  to return a iterator. See #6527
diff --git a/networkx/algorithms/centrality/laplacian.py b/networkx/algorithms/centrality/laplacian.py
index e0a9a6d51..d8a58e6b3 100644
--- a/networkx/algorithms/centrality/laplacian.py
+++ b/networkx/algorithms/centrality/laplacian.py
@@ -50,8 +50,11 @@ def laplacian_centrality(
     walk_type : string or None, optional (default=None)
         Optional parameter `walk_type` used when calling
         :func:`directed_laplacian_matrix <networkx.directed_laplacian_matrix>`.
-        If None, the transition matrix is selected depending on the properties
-        of the graph. Otherwise can be `random`, `lazy`, or `pagerank`.
+        One of ``"random"``, ``"lazy"``, or ``"pagerank"``. If ``walk_type=None``
+        (the default), then a value is selected according to the properties of `G`:
+        - ``walk_type="random"`` if `G` is strongly connected and aperiodic
+        - ``walk_type="lazy"`` if `G` is strongly connected but not aperiodic
+        - ``walk_type="pagerank"`` for all other cases.
 
     alpha : real (default = 0.95)
         Optional parameter `alpha` used when calling
diff --git a/networkx/algorithms/chordal.py b/networkx/algorithms/chordal.py
index 2aa567983..079376102 100644
--- a/networkx/algorithms/chordal.py
+++ b/networkx/algorithms/chordal.py
@@ -339,6 +339,8 @@ def _find_chordality_breaker(G, s=None, treewidth_bound=sys.maxsize):
 
     It ignores any self loops.
     """
+    if len(G) == 0:
+        raise nx.NetworkXPointlessConcept("Graph has no nodes.")
     unnumbered = set(G)
     if s is None:
         s = arbitrary_element(G)
diff --git a/networkx/algorithms/dag.py b/networkx/algorithms/dag.py
index 58138c340..eb3a064e4 100644
--- a/networkx/algorithms/dag.py
+++ b/networkx/algorithms/dag.py
@@ -641,7 +641,8 @@ def is_aperiodic(G):
     """
     if not G.is_directed():
         raise nx.NetworkXError("is_aperiodic not defined for undirected graphs")
-
+    if len(G) == 0:
+        raise nx.NetworkXPointlessConcept("Graph has no nodes.")
     s = arbitrary_element(G)
     levels = {s: 0}
     this_level = [s]
diff --git a/networkx/algorithms/distance_regular.py b/networkx/algorithms/distance_regular.py
index 18c19ee00..da3754330 100644
--- a/networkx/algorithms/distance_regular.py
+++ b/networkx/algorithms/distance_regular.py
@@ -147,6 +147,8 @@ def intersection_array(G):
     global_parameters
     """
     # test for regular graph (all degrees must be equal)
+    if len(G) == 0:
+        raise nx.NetworkXPointlessConcept("Graph has no nodes.")
     degree = iter(G.degree())
     (_, k) = next(degree)
     for _, knext in degree:
diff --git a/networkx/algorithms/flow/mincost.py b/networkx/algorithms/flow/mincost.py
index cc8626c7c..7a6c33511 100644
--- a/networkx/algorithms/flow/mincost.py
+++ b/networkx/algorithms/flow/mincost.py
@@ -182,6 +182,8 @@ def min_cost_flow(G, demand="demand", capacity="capacity", weight="weight"):
     >>> G.add_edge("b", "d", weight=1, capacity=9)
     >>> G.add_edge("c", "d", weight=2, capacity=5)
     >>> flowDict = nx.min_cost_flow(G)
+    >>> flowDict
+    {'a': {'b': 4, 'c': 1}, 'd': {}, 'b': {'d': 4}, 'c': {'d': 1}}
     """
     return nx.network_simplex(G, demand=demand, capacity=capacity, weight=weight)[1]
 
@@ -227,6 +229,21 @@ def cost_of_flow(G, flowDict, weight="weight"):
     cause problems). As a workaround you can use integer numbers by
     multiplying the relevant edge attributes by a convenient
     constant factor (eg 100).
+
+    Examples
+    --------
+    >>> G = nx.DiGraph()
+    >>> G.add_node("a", demand=-5)
+    >>> G.add_node("d", demand=5)
+    >>> G.add_edge("a", "b", weight=3, capacity=4)
+    >>> G.add_edge("a", "c", weight=6, capacity=10)
+    >>> G.add_edge("b", "d", weight=1, capacity=9)
+    >>> G.add_edge("c", "d", weight=2, capacity=5)
+    >>> flowDict = nx.min_cost_flow(G)
+    >>> flowDict
+    {'a': {'b': 4, 'c': 1}, 'd': {}, 'b': {'d': 4}, 'c': {'d': 1}}
+    >>> nx.cost_of_flow(G, flowDict)
+    24
     """
     return sum((flowDict[u][v] * d.get(weight, 0) for u, v, d in G.edges(data=True)))
 
diff --git a/networkx/algorithms/link_prediction.py b/networkx/algorithms/link_prediction.py
index 7335a77f5..21e89fbf1 100644
--- a/networkx/algorithms/link_prediction.py
+++ b/networkx/algorithms/link_prediction.py
@@ -37,6 +37,12 @@ def _apply_prediction(G, func, ebunch=None):
     """
     if ebunch is None:
         ebunch = nx.non_edges(G)
+    else:
+        for u, v in ebunch:
+            if u not in G:
+                raise nx.NodeNotFound(f"Node {u} not in G.")
+            if v not in G:
+                raise nx.NodeNotFound(f"Node {v} not in G.")
     return ((u, v, func(u, v)) for u, v in ebunch)
 
 
@@ -72,6 +78,14 @@ def resource_allocation_index(G, ebunch=None):
         An iterator of 3-tuples in the form (u, v, p) where (u, v) is a
         pair of nodes and p is their resource allocation index.
 
+    Raises
+    ------
+    NetworkXNotImplemented
+        If `G` is a `DiGraph`, a `Multigraph` or a `MultiDiGraph`.
+
+    NodeNotFound
+        If `ebunch` has a node that is not in `G`.
+
     Examples
     --------
     >>> G = nx.complete_graph(5)
@@ -127,6 +141,14 @@ def jaccard_coefficient(G, ebunch=None):
         An iterator of 3-tuples in the form (u, v, p) where (u, v) is a
         pair of nodes and p is their Jaccard coefficient.
 
+    Raises
+    ------
+    NetworkXNotImplemented
+        If `G` is a `DiGraph`, a `Multigraph` or a `MultiDiGraph`.
+
+    NodeNotFound
+        If `ebunch` has a node that is not in `G`.
+
     Examples
     --------
     >>> G = nx.complete_graph(5)
@@ -186,6 +208,14 @@ def adamic_adar_index(G, ebunch=None):
         An iterator of 3-tuples in the form (u, v, p) where (u, v) is a
         pair of nodes and p is their Adamic-Adar index.
 
+    Raises
+    ------
+    NetworkXNotImplemented
+        If `G` is a `DiGraph`, a `Multigraph` or a `MultiDiGraph`.
+
+    NodeNotFound
+        If `ebunch` has a node that is not in `G`.
+
     Examples
     --------
     >>> G = nx.complete_graph(5)
@@ -264,6 +294,17 @@ def common_neighbor_centrality(G, ebunch=None, alpha=0.8):
         pair of nodes and p is their Common Neighbor and Centrality based
         Parameterized Algorithm(CCPA) score.
 
+    Raises
+    ------
+    NetworkXNotImplemented
+        If `G` is a `DiGraph`, a `Multigraph` or a `MultiDiGraph`.
+
+    NetworkXAlgorithmError
+        If self loops exsists in `ebunch` or in `G` (if `ebunch` is `None`).
+
+    NodeNotFound
+        If `ebunch` has a node that is not in `G`.
+
     Examples
     --------
     >>> G = nx.complete_graph(5)
@@ -286,7 +327,7 @@ def common_neighbor_centrality(G, ebunch=None, alpha=0.8):
 
         def predict(u, v):
             if u == v:
-                raise nx.NetworkXAlgorithmError("Self links are not supported")
+                raise nx.NetworkXAlgorithmError("Self loops are not supported")
 
             return sum(1 for _ in nx.common_neighbors(G, u, v))
 
@@ -296,7 +337,7 @@ def common_neighbor_centrality(G, ebunch=None, alpha=0.8):
 
         def predict(u, v):
             if u == v:
-                raise nx.NetworkXAlgorithmError("Self links are not supported")
+                raise nx.NetworkXAlgorithmError("Self loops are not supported")
             path_len = spl[u].get(v, inf)
 
             return alpha * sum(1 for _ in nx.common_neighbors(G, u, v)) + (
@@ -338,6 +379,14 @@ def preferential_attachment(G, ebunch=None):
         An iterator of 3-tuples in the form (u, v, p) where (u, v) is a
         pair of nodes and p is their preferential attachment score.
 
+    Raises
+    ------
+    NetworkXNotImplemented
+        If `G` is a `DiGraph`, a `Multigraph` or a `MultiDiGraph`.
+
+    NodeNotFound
+        If `ebunch` has a node that is not in `G`.
+
     Examples
     --------
     >>> G = nx.complete_graph(5)
@@ -402,6 +451,17 @@ def cn_soundarajan_hopcroft(G, ebunch=None, community="community"):
         An iterator of 3-tuples in the form (u, v, p) where (u, v) is a
         pair of nodes and p is their score.
 
+    Raises
+    ------
+    NetworkXNotImplemented
+        If `G` is a `DiGraph`, a `Multigraph` or a `MultiDiGraph`.
+
+    NetworkXAlgorithmError
+        If no community information is available for a node in `ebunch` or in `G` (if `ebunch` is `None`).
+
+    NodeNotFound
+        If `ebunch` has a node that is not in `G`.
+
     Examples
     --------
     >>> G = nx.path_graph(3)
@@ -477,6 +537,17 @@ def ra_index_soundarajan_hopcroft(G, ebunch=None, community="community"):
         An iterator of 3-tuples in the form (u, v, p) where (u, v) is a
         pair of nodes and p is their score.
 
+    Raises
+    ------
+    NetworkXNotImplemented
+        If `G` is a `DiGraph`, a `Multigraph` or a `MultiDiGraph`.
+
+    NetworkXAlgorithmError
+        If no community information is available for a node in `ebunch` or in `G` (if `ebunch` is `None`).
+
+    NodeNotFound
+        If `ebunch` has a node that is not in `G`.
+
     Examples
     --------
     >>> G = nx.Graph()
@@ -553,6 +624,18 @@ def within_inter_cluster(G, ebunch=None, delta=0.001, community="community"):
         An iterator of 3-tuples in the form (u, v, p) where (u, v) is a
         pair of nodes and p is their WIC measure.
 
+    Raises
+    ------
+    NetworkXNotImplemented
+        If `G` is a `DiGraph`, a `Multigraph` or a `MultiDiGraph`.
+
+    NetworkXAlgorithmError
+        - If `delta` is less than or equal to zero.
+        - If no community information is available for a node in `ebunch` or in `G` (if `ebunch` is `None`).
+
+    NodeNotFound
+        If `ebunch` has a node that is not in `G`.
+
     Examples
     --------
     >>> G = nx.Graph()
@@ -601,4 +684,6 @@ def _community(G, u, community):
     try:
         return node_u[community]
     except KeyError as err:
-        raise nx.NetworkXAlgorithmError("No community information") from err
+        raise nx.NetworkXAlgorithmError(
+            f"No community information available for Node {u}"
+        ) from err
diff --git a/networkx/algorithms/regular.py b/networkx/algorithms/regular.py
index d33323427..52b5ed6ee 100644
--- a/networkx/algorithms/regular.py
+++ b/networkx/algorithms/regular.py
@@ -29,6 +29,8 @@ def is_regular(G):
     True
 
     """
+    if len(G) == 0:
+        raise nx.NetworkXPointlessConcept("Graph has no nodes.")
     n1 = nx.utils.arbitrary_element(G)
     if not G.is_directed():
         d1 = G.degree(n1)
diff --git a/networkx/algorithms/similarity.py b/networkx/algorithms/similarity.py
index 92b0cf9a3..0ad6de6e6 100644
--- a/networkx/algorithms/similarity.py
+++ b/networkx/algorithms/similarity.py
@@ -1275,6 +1275,14 @@ def simrank_similarity(
         If neither ``source`` nor ``target`` is ``None``, this returns
         the similarity value for the given pair of nodes.
 
+    Raises
+    -------
+    ExceededMaxIterations
+        If the algorithm does not converge within ``max_iterations``.
+
+    NodeNotFound
+        If either ``source`` or ``target`` is not in `G`.
+
     Examples
     --------
     >>> G = nx.cycle_graph(2)
@@ -1311,8 +1319,21 @@ def simrank_similarity(
     import numpy as np
 
     nodelist = list(G)
-    s_indx = None if source is None else nodelist.index(source)
-    t_indx = None if target is None else nodelist.index(target)
+    if source is not None:
+        if source not in nodelist:
+            raise nx.NodeNotFound(f"Source node {source} not in G")
+        else:
+            s_indx = nodelist.index(source)
+    else:
+        s_indx = None
+
+    if target is not None:
+        if target not in nodelist:
+            raise nx.NodeNotFound(f"Target node {target} not in G")
+        else:
+            t_indx = nodelist.index(target)
+    else:
+        t_indx = None
 
     x = _simrank_similarity_numpy(
         G, s_indx, t_indx, importance_factor, max_iterations, tolerance
@@ -1535,6 +1556,18 @@ def panther_similarity(
         the self-similarity (i.e., ``v``) will not be included in
         the returned dictionary.
 
+    Raises
+    -------
+    NetworkXUnfeasible
+        If `source` is an isolated node.
+
+    NodeNotFound
+        If `source` is not in `G`.
+
+    Notes
+    -------
+        The isolated nodes in `G` are ignored.
+
     Examples
     --------
     >>> G = nx.star_graph(10)
@@ -1550,6 +1583,18 @@ def panther_similarity(
     """
     import numpy as np
 
+    if source not in G:
+        raise nx.NodeNotFound(f"Source node {source} not in G")
+
+    isolates = set(nx.isolates(G))
+
+    if source in isolates:
+        raise nx.NetworkXUnfeasible(
+            f"Panther similarity is not defined for the isolated source node {source}."
+        )
+
+    G = G.subgraph([node for node in G.nodes if node not in isolates]).copy()
+
     num_nodes = G.number_of_nodes()
     if num_nodes < k:
         warnings.warn(
diff --git a/networkx/linalg/laplacianmatrix.py b/networkx/linalg/laplacianmatrix.py
index 137638281..17bfd6d36 100644
--- a/networkx/linalg/laplacianmatrix.py
+++ b/networkx/linalg/laplacianmatrix.py
@@ -219,8 +219,11 @@ def directed_laplacian_matrix(
        If None, then each edge has weight 1.
 
     walk_type : string or None, optional (default=None)
-       If None, `P` is selected depending on the properties of the
-       graph. Otherwise is one of 'random', 'lazy', or 'pagerank'
+       One of ``"random"``, ``"lazy"``, or ``"pagerank"``. If ``walk_type=None``
+       (the default), then a value is selected according to the properties of `G`:
+       - ``walk_type="random"`` if `G` is strongly connected and aperiodic
+       - ``walk_type="lazy"`` if `G` is strongly connected but not aperiodic
+       - ``walk_type="pagerank"`` for all other cases.
 
     alpha : real
        (1 - alpha) is the teleportation probability used with pagerank
@@ -307,8 +310,11 @@ def directed_combinatorial_laplacian_matrix(
        If None, then each edge has weight 1.
 
     walk_type : string or None, optional (default=None)
-       If None, `P` is selected depending on the properties of the
-       graph. Otherwise is one of 'random', 'lazy', or 'pagerank'
+        One of ``"random"``, ``"lazy"``, or ``"pagerank"``. If ``walk_type=None``
+        (the default), then a value is selected according to the properties of `G`:
+        - ``walk_type="random"`` if `G` is strongly connected and aperiodic
+        - ``walk_type="lazy"`` if `G` is strongly connected but not aperiodic
+        - ``walk_type="pagerank"`` for all other cases.
 
     alpha : real
        (1 - alpha) is the teleportation probability used with pagerank
@@ -372,8 +378,11 @@ def _transition_matrix(G, nodelist=None, weight="weight", walk_type=None, alpha=
        If None, then each edge has weight 1.
 
     walk_type : string or None, optional (default=None)
-       If None, `P` is selected depending on the properties of the
-       graph. Otherwise is one of 'random', 'lazy', or 'pagerank'
+       One of ``"random"``, ``"lazy"``, or ``"pagerank"``. If ``walk_type=None``
+       (the default), then a value is selected according to the properties of `G`:
+        - ``walk_type="random"`` if `G` is strongly connected and aperiodic
+        - ``walk_type="lazy"`` if `G` is strongly connected but not aperiodic
+        - ``walk_type="pagerank"`` for all other cases.
 
     alpha : real
        (1 - alpha) is the teleportation probability used with pagerank


Test patch:
diff --git a/networkx/algorithms/components/tests/test_strongly_connected.py b/networkx/algorithms/components/tests/test_strongly_connected.py
index f1c773026..6d4ea8552 100644
--- a/networkx/algorithms/components/tests/test_strongly_connected.py
+++ b/networkx/algorithms/components/tests/test_strongly_connected.py
@@ -186,9 +186,6 @@ class TestStronglyConnected:
             with pytest.deprecated_call():
                 next(nx.strongly_connected_components_recursive(G))
         pytest.raises(NetworkXNotImplemented, nx.is_strongly_connected, G)
-        pytest.raises(
-            nx.NetworkXPointlessConcept, nx.is_strongly_connected, nx.DiGraph()
-        )
         pytest.raises(NetworkXNotImplemented, nx.condensation, G)
 
     strong_cc_methods = (
diff --git a/networkx/algorithms/components/tests/test_weakly_connected.py b/networkx/algorithms/components/tests/test_weakly_connected.py
index e31326366..f01447893 100644
--- a/networkx/algorithms/components/tests/test_weakly_connected.py
+++ b/networkx/algorithms/components/tests/test_weakly_connected.py
@@ -88,3 +88,9 @@ class TestWeaklyConnected:
             assert len(seen & component) == 0
             seen.update(component)
             component.clear()
+
+
+def test_is_weakly_connected_empty_graph_raises():
+    G = nx.DiGraph()
+    with pytest.raises(nx.NetworkXPointlessConcept, match="Connectivity is undefined"):
+        nx.is_weakly_connected(G)
diff --git a/networkx/algorithms/shortest_paths/generic.py b/networkx/algorithms/shortest_paths/generic.py
index 2d3f75c04..1ed47aa71 100644
--- a/networkx/algorithms/shortest_paths/generic.py
+++ b/networkx/algorithms/shortest_paths/generic.py
@@ -135,8 +135,17 @@ def shortest_path(G, source=None, target=None, weight=None, method="dijkstra"):
     method = "unweighted" if weight is None else method
     if source is None:
         if target is None:
-            msg = "shortest_path for all_pairs will return an iterator in v3.3"
-            warnings.warn(msg, DeprecationWarning)
+            warnings.warn(
+                (
+                    "\n\nshortest_path will return an iterator that yields\n"
+                    "(node, path) pairs instead of a dictionary when source\n"
+                    "and target are unspecified beginning in version 3.5\n\n"
+                    "To keep the current behavior, use:\n\n"
+                    "\tdict(nx.shortest_path(G))"
+                ),
+                FutureWarning,
+                stacklevel=3,
+            )
 
             # Find paths between all pairs.
             if method == "unweighted":
diff --git a/networkx/algorithms/shortest_paths/unweighted.py b/networkx/algorithms/shortest_paths/unweighted.py
index 78df41bc3..bc329c552 100644
--- a/networkx/algorithms/shortest_paths/unweighted.py
+++ b/networkx/algorithms/shortest_paths/unweighted.py
@@ -135,8 +135,14 @@ def single_target_shortest_path_length(G, target, cutoff=None):
     if target not in G:
         raise nx.NodeNotFound(f"Target {target} is not in G")
 
-    msg = "single_target_shortest_path_length will return a dict starting in v3.3"
-    warnings.warn(msg, DeprecationWarning)
+    warnings.warn(
+        (
+            "\n\nsingle_target_shortest_path_length will return a dict instead of"
+            "\nan iterator in version 3.5"
+        ),
+        FutureWarning,
+        stacklevel=3,
+    )
 
     if cutoff is None:
         cutoff = float("inf")
diff --git a/networkx/algorithms/tests/test_dag.py b/networkx/algorithms/tests/test_dag.py
index 540c0c55e..d26c9fd3b 100644
--- a/networkx/algorithms/tests/test_dag.py
+++ b/networkx/algorithms/tests/test_dag.py
@@ -618,11 +618,17 @@ def test_is_aperiodic_selfloop():
     assert nx.is_aperiodic(G)
 
 
-def test_is_aperiodic_raise():
+def test_is_aperiodic_undirected_raises():
     G = nx.Graph()
     pytest.raises(nx.NetworkXError, nx.is_aperiodic, G)
 
 
+def test_is_aperiodic_empty_graph():
+    G = nx.empty_graph(create_using=nx.DiGraph)
+    with pytest.raises(nx.NetworkXPointlessConcept, match="Graph has no nodes."):
+        nx.is_aperiodic(G)
+
+
 def test_is_aperiodic_bipartite():
     # Bipartite graph
     G = nx.DiGraph(nx.davis_southern_women_graph())
diff --git a/networkx/algorithms/tests/test_distance_regular.py b/networkx/algorithms/tests/test_distance_regular.py
index d336b1882..6cbeb2a6d 100644
--- a/networkx/algorithms/tests/test_distance_regular.py
+++ b/networkx/algorithms/tests/test_distance_regular.py
@@ -1,3 +1,5 @@
+import pytest
+
 import networkx as nx
 from networkx import is_strongly_regular
 
@@ -41,6 +43,13 @@ class TestDistanceRegular:
         assert c == [1, 2, 5]
 
 
+@pytest.mark.parametrize("f", (nx.is_distance_regular, nx.is_strongly_regular))
+def test_empty_graph_raises(f):
+    G = nx.Graph()
+    with pytest.raises(nx.NetworkXPointlessConcept, match="Graph has no nodes"):
+        f(G)
+
+
 class TestStronglyRegular:
     """Unit tests for the :func:`~networkx.is_strongly_regular`
     function.
diff --git a/networkx/algorithms/tests/test_euler.py b/networkx/algorithms/tests/test_euler.py
index 08eaf7fcc..b5871f09b 100644
--- a/networkx/algorithms/tests/test_euler.py
+++ b/networkx/algorithms/tests/test_euler.py
@@ -5,6 +5,13 @@ import pytest
 import networkx as nx
 
 
+@pytest.mark.parametrize("f", (nx.is_eulerian, nx.is_semieulerian))
+def test_empty_graph_raises(f):
+    G = nx.Graph()
+    with pytest.raises(nx.NetworkXPointlessConcept, match="Connectivity is undefined"):
+        f(G)
+
+
 class TestIsEulerian:
     def test_is_eulerian(self):
         assert nx.is_eulerian(nx.complete_graph(5))
diff --git a/networkx/algorithms/tests/test_link_prediction.py b/networkx/algorithms/tests/test_link_prediction.py
index 7fc04d206..b4643b342 100644
--- a/networkx/algorithms/tests/test_link_prediction.py
+++ b/networkx/algorithms/tests/test_link_prediction.py
@@ -34,23 +34,17 @@ class TestResourceAllocationIndex:
         G = nx.star_graph(4)
         self.test(G, [(1, 2)], [(1, 2, 0.25)])
 
-    def test_notimplemented(self):
-        assert pytest.raises(
-            nx.NetworkXNotImplemented, self.func, nx.DiGraph([(0, 1), (1, 2)]), [(0, 2)]
-        )
-        assert pytest.raises(
-            nx.NetworkXNotImplemented,
-            self.func,
-            nx.MultiGraph([(0, 1), (1, 2)]),
-            [(0, 2)],
-        )
+    @pytest.mark.parametrize("graph_type", (nx.DiGraph, nx.MultiGraph, nx.MultiDiGraph))
+    def test_notimplemented(self, graph_type):
         assert pytest.raises(
-            nx.NetworkXNotImplemented,
-            self.func,
-            nx.MultiDiGraph([(0, 1), (1, 2)]),
-            [(0, 2)],
+            nx.NetworkXNotImplemented, self.func, graph_type([(0, 1), (1, 2)]), [(0, 2)]
         )
 
+    def test_node_not_found(self):
+        G = nx.Graph()
+        G.add_edges_from([(0, 1), (0, 2), (2, 3)])
+        assert pytest.raises(nx.NodeNotFound, self.func, G, [(0, 4)])
+
     def test_no_common_neighbor(self):
         G = nx.Graph()
         G.add_nodes_from([0, 1])
@@ -80,23 +74,17 @@ class TestJaccardCoefficient:
         G = nx.path_graph(4)
         self.test(G, [(0, 2)], [(0, 2, 0.5)])
 
-    def test_notimplemented(self):
-        assert pytest.raises(
-            nx.NetworkXNotImplemented, self.func, nx.DiGraph([(0, 1), (1, 2)]), [(0, 2)]
-        )
-        assert pytest.raises(
-            nx.NetworkXNotImplemented,
-            self.func,
-            nx.MultiGraph([(0, 1), (1, 2)]),
-            [(0, 2)],
-        )
+    @pytest.mark.parametrize("graph_type", (nx.DiGraph, nx.MultiGraph, nx.MultiDiGraph))
+    def test_notimplemented(self, graph_type):
         assert pytest.raises(
-            nx.NetworkXNotImplemented,
-            self.func,
-            nx.MultiDiGraph([(0, 1), (1, 2)]),
-            [(0, 2)],
+            nx.NetworkXNotImplemented, self.func, graph_type([(0, 1), (1, 2)]), [(0, 2)]
         )
 
+    def test_node_not_found(self):
+        G = nx.Graph()
+        G.add_edges_from([(0, 1), (0, 2), (2, 3)])
+        assert pytest.raises(nx.NodeNotFound, self.func, G, [(0, 4)])
+
     def test_no_common_neighbor(self):
         G = nx.Graph()
         G.add_edges_from([(0, 1), (2, 3)])
@@ -131,23 +119,17 @@ class TestAdamicAdarIndex:
         G = nx.star_graph(4)
         self.test(G, [(1, 2)], [(1, 2, 1 / math.log(4))])
 
-    def test_notimplemented(self):
-        assert pytest.raises(
-            nx.NetworkXNotImplemented, self.func, nx.DiGraph([(0, 1), (1, 2)]), [(0, 2)]
-        )
-        assert pytest.raises(
-            nx.NetworkXNotImplemented,
-            self.func,
-            nx.MultiGraph([(0, 1), (1, 2)]),
-            [(0, 2)],
-        )
+    @pytest.mark.parametrize("graph_type", (nx.DiGraph, nx.MultiGraph, nx.MultiDiGraph))
+    def test_notimplemented(self, graph_type):
         assert pytest.raises(
-            nx.NetworkXNotImplemented,
-            self.func,
-            nx.MultiDiGraph([(0, 1), (1, 2)]),
-            [(0, 2)],
+            nx.NetworkXNotImplemented, self.func, graph_type([(0, 1), (1, 2)]), [(0, 2)]
         )
 
+    def test_node_not_found(self):
+        G = nx.Graph()
+        G.add_edges_from([(0, 1), (0, 2), (2, 3)])
+        assert pytest.raises(nx.NodeNotFound, self.func, G, [(0, 4)])
+
     def test_no_common_neighbor(self):
         G = nx.Graph()
         G.add_nodes_from([0, 1])
@@ -190,6 +172,11 @@ class TestCommonNeighborCentrality:
             nx.NetworkXNotImplemented, self.func, graph_type([(0, 1), (1, 2)]), [(0, 2)]
         )
 
+    def test_node_not_found(self):
+        G = nx.Graph()
+        G.add_edges_from([(0, 1), (0, 2), (2, 3)])
+        assert pytest.raises(nx.NodeNotFound, self.func, G, [(0, 4)])
+
     def test_no_common_neighbor(self):
         G = nx.Graph()
         G.add_nodes_from([0, 1])
@@ -223,23 +210,17 @@ class TestPreferentialAttachment:
         G = nx.star_graph(4)
         self.test(G, [(0, 2)], [(0, 2, 4)])
 
-    def test_notimplemented(self):
-        assert pytest.raises(
-            nx.NetworkXNotImplemented, self.func, nx.DiGraph([(0, 1), (1, 2)]), [(0, 2)]
-        )
-        assert pytest.raises(
-            nx.NetworkXNotImplemented,
-            self.func,
-            nx.MultiGraph([(0, 1), (1, 2)]),
-            [(0, 2)],
-        )
+    @pytest.mark.parametrize("graph_type", (nx.DiGraph, nx.MultiGraph, nx.MultiDiGraph))
+    def test_notimplemented(self, graph_type):
         assert pytest.raises(
-            nx.NetworkXNotImplemented,
-            self.func,
-            nx.MultiDiGraph([(0, 1), (1, 2)]),
-            [(0, 2)],
+            nx.NetworkXNotImplemented, self.func, graph_type([(0, 1), (1, 2)]), [(0, 2)]
         )
 
+    def test_node_not_found(self):
+        G = nx.Graph()
+        G.add_edges_from([(0, 1), (0, 2), (2, 3)])
+        assert pytest.raises(nx.NodeNotFound, self.func, G, [(0, 4)])
+
     def test_zero_degrees(self):
         G = nx.Graph()
         G.add_nodes_from([0, 1])
@@ -282,17 +263,21 @@ class TestCNSoundarajanHopcroft:
         G.nodes[4]["community"] = 0
         self.test(G, [(1, 2)], [(1, 2, 2)])
 
-    def test_notimplemented(self):
-        G = nx.DiGraph([(0, 1), (1, 2)])
-        G.add_nodes_from([0, 1, 2], community=0)
-        assert pytest.raises(nx.NetworkXNotImplemented, self.func, G, [(0, 2)])
-        G = nx.MultiGraph([(0, 1), (1, 2)])
-        G.add_nodes_from([0, 1, 2], community=0)
-        assert pytest.raises(nx.NetworkXNotImplemented, self.func, G, [(0, 2)])
-        G = nx.MultiDiGraph([(0, 1), (1, 2)])
+    @pytest.mark.parametrize("graph_type", (nx.DiGraph, nx.MultiGraph, nx.MultiDiGraph))
+    def test_notimplemented(self, graph_type):
+        G = graph_type([(0, 1), (1, 2)])
         G.add_nodes_from([0, 1, 2], community=0)
         assert pytest.raises(nx.NetworkXNotImplemented, self.func, G, [(0, 2)])
 
+    def test_node_not_found(self):
+        G = nx.Graph()
+        G.add_edges_from([(0, 1), (0, 2), (2, 3)])
+        G.nodes[0]["community"] = 0
+        G.nodes[1]["community"] = 1
+        G.nodes[2]["community"] = 0
+        G.nodes[3]["community"] = 0
+        assert pytest.raises(nx.NodeNotFound, self.func, G, [(0, 4)])
+
     def test_no_common_neighbor(self):
         G = nx.Graph()
         G.add_nodes_from([0, 1])
@@ -387,17 +372,21 @@ class TestRAIndexSoundarajanHopcroft:
         G.nodes[4]["community"] = 0
         self.test(G, [(1, 2)], [(1, 2, 0.25)])
 
-    def test_notimplemented(self):
-        G = nx.DiGraph([(0, 1), (1, 2)])
-        G.add_nodes_from([0, 1, 2], community=0)
-        assert pytest.raises(nx.NetworkXNotImplemented, self.func, G, [(0, 2)])
-        G = nx.MultiGraph([(0, 1), (1, 2)])
-        G.add_nodes_from([0, 1, 2], community=0)
-        assert pytest.raises(nx.NetworkXNotImplemented, self.func, G, [(0, 2)])
-        G = nx.MultiDiGraph([(0, 1), (1, 2)])
+    @pytest.mark.parametrize("graph_type", (nx.DiGraph, nx.MultiGraph, nx.MultiDiGraph))
+    def test_notimplemented(self, graph_type):
+        G = graph_type([(0, 1), (1, 2)])
         G.add_nodes_from([0, 1, 2], community=0)
         assert pytest.raises(nx.NetworkXNotImplemented, self.func, G, [(0, 2)])
 
+    def test_node_not_found(self):
+        G = nx.Graph()
+        G.add_edges_from([(0, 1), (0, 2), (2, 3)])
+        G.nodes[0]["community"] = 0
+        G.nodes[1]["community"] = 1
+        G.nodes[2]["community"] = 0
+        G.nodes[3]["community"] = 0
+        assert pytest.raises(nx.NodeNotFound, self.func, G, [(0, 4)])
+
     def test_no_common_neighbor(self):
         G = nx.Graph()
         G.add_nodes_from([0, 1])
@@ -495,17 +484,21 @@ class TestWithinInterCluster:
         G.nodes[4]["community"] = 0
         self.test(G, [(1, 2)], [(1, 2, 1 / self.delta)])
 
-    def test_notimplemented(self):
-        G = nx.DiGraph([(0, 1), (1, 2)])
-        G.add_nodes_from([0, 1, 2], community=0)
-        assert pytest.raises(nx.NetworkXNotImplemented, self.func, G, [(0, 2)])
-        G = nx.MultiGraph([(0, 1), (1, 2)])
-        G.add_nodes_from([0, 1, 2], community=0)
-        assert pytest.raises(nx.NetworkXNotImplemented, self.func, G, [(0, 2)])
-        G = nx.MultiDiGraph([(0, 1), (1, 2)])
+    @pytest.mark.parametrize("graph_type", (nx.DiGraph, nx.MultiGraph, nx.MultiDiGraph))
+    def test_notimplemented(self, graph_type):
+        G = graph_type([(0, 1), (1, 2)])
         G.add_nodes_from([0, 1, 2], community=0)
         assert pytest.raises(nx.NetworkXNotImplemented, self.func, G, [(0, 2)])
 
+    def test_node_not_found(self):
+        G = nx.Graph()
+        G.add_edges_from([(0, 1), (0, 2), (2, 3)])
+        G.nodes[0]["community"] = 0
+        G.nodes[1]["community"] = 1
+        G.nodes[2]["community"] = 0
+        G.nodes[3]["community"] = 0
+        assert pytest.raises(nx.NodeNotFound, self.func, G, [(0, 4)])
+
     def test_no_common_neighbor(self):
         G = nx.Graph()
         G.add_nodes_from([0, 1])
diff --git a/networkx/algorithms/tests/test_regular.py b/networkx/algorithms/tests/test_regular.py
index 0c8e4e465..a8b4c3a30 100644
--- a/networkx/algorithms/tests/test_regular.py
+++ b/networkx/algorithms/tests/test_regular.py
@@ -68,6 +68,12 @@ class TestIsRegular:
         assert reg.is_regular(g)
 
 
+def test_is_regular_empty_graph_raises():
+    G = nx.Graph()
+    with pytest.raises(nx.NetworkXPointlessConcept, match="Graph has no nodes"):
+        nx.is_regular(G)
+
+
 class TestIsKRegular:
     def test_is_k_regular1(self):
         g = gen.cycle_graph(4)
diff --git a/networkx/algorithms/tests/test_similarity.py b/networkx/algorithms/tests/test_similarity.py
index b7fcf90fa..420c709c1 100644
--- a/networkx/algorithms/tests/test_similarity.py
+++ b/networkx/algorithms/tests/test_similarity.py
@@ -699,6 +699,16 @@ class TestSimilarity:
         G = nx.cycle_graph(5)
         pytest.raises(nx.ExceededMaxIterations, alg, G, max_iterations=10)
 
+    def test_simrank_source_not_found(self):
+        G = nx.cycle_graph(5)
+        with pytest.raises(nx.NodeNotFound, match="Source node 10 not in G"):
+            nx.simrank_similarity(G, source=10)
+
+    def test_simrank_target_not_found(self):
+        G = nx.cycle_graph(5)
+        with pytest.raises(nx.NodeNotFound, match="Target node 10 not in G"):
+            nx.simrank_similarity(G, target=10)
+
     def test_simrank_between_versions(self):
         G = nx.cycle_graph(5)
         # _python tolerance 1e-4
@@ -819,6 +829,21 @@ class TestSimilarity:
         sim = nx.panther_similarity(G, "v1", path_length=2, weight="w")
         assert sim == expected
 
+    def test_panther_similarity_source_not_found(self):
+        G = nx.Graph()
+        G.add_edges_from([(0, 1), (0, 2), (0, 3), (1, 2), (2, 4)])
+        with pytest.raises(nx.NodeNotFound, match="Source node 10 not in G"):
+            nx.panther_similarity(G, source=10)
+
+    def test_panther_similarity_isolated(self):
+        G = nx.Graph()
+        G.add_nodes_from(range(5))
+        with pytest.raises(
+            nx.NetworkXUnfeasible,
+            match="Panther similarity is not defined for the isolated source node 1.",
+        ):
+            nx.panther_similarity(G, source=1)
+
     def test_generate_random_paths_unweighted(self):
         np.random.seed(42)
 
diff --git a/networkx/algorithms/tree/tests/test_recognition.py b/networkx/algorithms/tree/tests/test_recognition.py
index a9c6c5aad..105f5a89e 100644
--- a/networkx/algorithms/tree/tests/test_recognition.py
+++ b/networkx/algorithms/tree/tests/test_recognition.py
@@ -119,6 +119,12 @@ def test_emptybranch():
     assert not nx.is_arborescence(G)
 
 
+def test_is_branching_empty_graph_raises():
+    G = nx.DiGraph()
+    with pytest.raises(nx.NetworkXPointlessConcept, match="G has no nodes."):
+        nx.is_branching(G)
+
+
 def test_path():
     G = nx.DiGraph()
     nx.add_path(G, range(5))
@@ -160,3 +166,9 @@ def test_notarborescence2():
     G.add_edge(6, 4)
     assert not nx.is_branching(G)
     assert not nx.is_arborescence(G)
+
+
+def test_is_arborescense_empty_graph_raises():
+    G = nx.DiGraph()
+    with pytest.raises(nx.NetworkXPointlessConcept, match="G has no nodes."):
+        nx.is_arborescence(G)
diff --git a/networkx/conftest.py b/networkx/conftest.py
index ef3551f41..41f4789c3 100644
--- a/networkx/conftest.py
+++ b/networkx/conftest.py
@@ -94,13 +94,13 @@ def set_warnings():
     )
     warnings.filterwarnings(
         "ignore",
-        category=DeprecationWarning,
-        message="single_target_shortest_path_length will",
+        category=FutureWarning,
+        message="\n\nsingle_target_shortest_path_length",
     )
     warnings.filterwarnings(
         "ignore",
-        category=DeprecationWarning,
-        message="shortest_path for all_pairs",
+        category=FutureWarning,
+        message="\n\nshortest_path",
     )
     warnings.filterwarnings(
         "ignore", category=DeprecationWarning, message="\nforest_str is deprecated"