prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Create bridges.py
  Contains three simple functions for detection and retrieval of bridges or local bridges in a undirected network.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `networkx/algorithms/bridges.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 # bridges.py - bridge-finding algorithms
  3 #
  4 # Copyright 2004-2016 NetworkX developers.
  5 #
  6 # This file is part of NetworkX.
  7 #
  8 # NetworkX is distributed under a BSD license; see LICENSE.txt for more
  9 # information.
  10 """Bridge-finding algorithms."""
  11 from itertools import chain
  12 
  13 import networkx as nx
  14 from networkx.utils import not_implemented_for
  15 
  16 __all__ = ['bridges', 'has_bridges']
  17 
  18 
  19 @not_implemented_for('multigraph')
  20 @not_implemented_for('directed')
  21 def bridges(G, root=None):
  22     """Generate all bridges in a graph.
  23 
  24     A *bridge* in a graph is an edge whose removal causes the number of
  25     connected components of the graph to increase.
  26 
  27     Parameters
  28     ----------
  29     G : undirected graph
  30 
  31     root : node (optional)
  32        A node in the graph `G`. If specified, only the bridges in the
  33        connected component containing this node will be returned.
  34 
  35     Yields
  36     ------
  37     e : edge
  38        An edge in the graph whose removal disconnects the graph (or
  39        causes the number of connected components to increase).
  40 
  41     Raises
  42     ------
  43     NodeNotFound
  44        If `root` is not in the graph `G`.
  45 
  46     Examples
  47     --------
  48     The barbell graph with parameter zero has a single bridge::
  49 
  50         >>> G = nx.barbell_graph(10, 0)
  51         >>> list(nx.bridges(G))
  52         [(9, 10)]
  53 
  54     Notes
  55     -----
  56     This implementation uses the :func:`networkx.chain_decomposition`
  57     function, so it shares its worst-case time complexity, :math:`O(m +
  58     n)`, ignoring polylogarithmic factors, where *n* is the number of
  59     nodes in the graph and *m* is the number of edges.
  60 
  61     """
  62     chains = nx.chain_decomposition(G, root=root)
  63     chain_edges = set(chain.from_iterable(chains))
  64     for u, v in G.edges():
  65         if (u, v) not in chain_edges and (v, u) not in chain_edges:
  66             yield u, v
  67 
  68 
  69 @not_implemented_for('multigraph')
  70 @not_implemented_for('directed')
  71 def has_bridges(G, root=None):
  72     """Decide whether a graph has any bridges.
  73 
  74     A *bridge* in a graph is an edge whose removal causes the number of
  75     connected components of the graph to increase.
  76 
  77     Parameters
  78     ----------
  79     G : undirected graph
  80 
  81     root : node (optional)
  82        A node in the graph `G`. If specified, only the bridges in the
  83        connected component containing this node will be considered.
  84 
  85     Returns
  86     -------
  87     bool
  88        Whether the graph (or the connected component containing `root`)
  89        has any bridges.
  90 
  91     Raises
  92     ------
  93     NodeNotFound
  94        If `root` is not in the graph `G`.
  95 
  96     Examples
  97     --------
  98     The barbell graph with parameter zero has a single bridge::
  99 
  100         >>> G = nx.barbell_graph(10, 0)
  101         >>> nx.has_bridges(G)
  102         True
  103 
  104     On the other hand, the cycle graph has no bridges::
  105 
  106         >>> G = nx.cycle_graph(5)
  107         >>> nx.has_bridges(G)
  108         False
  109 
  110     Notes
  111     -----
  112     This implementation uses the :func:`networkx.bridges` function, so
  113     it shares its worst-case time complexity, :math:`O(m + n)`, ignoring
  114     polylogarithmic factors, where *n* is the number of nodes in the
  115     graph and *m* is the number of edges.
  116 
  117     """
  118     try:
  119         next(bridges(G))
  120     except StopIteration:
  121         return False
  122     else:
  123         return True
  124
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/networkx/algorithms/bridges.py b/networkx/algorithms/bridges.py
  --- a/networkx/algorithms/bridges.py
  +++ b/networkx/algorithms/bridges.py
  @@ -1,7 +1,7 @@
   # -*- coding: utf-8 -*-
   # bridges.py - bridge-finding algorithms
   #
  -# Copyright 2004-2016 NetworkX developers.
  +# Copyright 2004-2017 NetworkX developers.
   #
   # This file is part of NetworkX.
   #
  @@ -13,7 +13,7 @@
   import networkx as nx
   from networkx.utils import not_implemented_for
   
  -__all__ = ['bridges', 'has_bridges']
  +__all__ = ['bridges', 'has_bridges', 'local_bridges']
   
   
   @not_implemented_for('multigraph')
  @@ -121,3 +121,61 @@
           return False
       else:
           return True
  +
  +
  +@not_implemented_for('multigraph')
  +@not_implemented_for('directed')
  +def local_bridges(G, with_span=True, weight=None):
  +    """Iterate over local bridges of `G` optionally computing the span
  +
  +    A *local bridge* is an edge whose endpoints have no common neighbors.
  +    That is, the edge is not part of a triangle in the graph.
  +
  +    The *span* of a *local bridge* is the shortest path length between
  +    the endpoints if the local bridge is removed.
  +
  +    Parameters
  +    ----------
  +    G : undirected graph
  +
  +    with_span : bool
  +        If True, yield a 3-tuple `(u, v, span)`
  +
  +    weight : function, string or None (default: None)
  +        If function, used to compute edge weights for the span.
  +        If string, the edge data attribute used in calculating span.
  +        If None, all edges have weight 1.
  +
  +    Yields
  +    ------
  +    e : edge
  +        The local bridges as an edge 2-tuple of nodes `(u, v)` or
  +        as a 3-tuple `(u, v, span)` when `with_span is True`.
  +
  +    Examples
  +    --------
  +    A cycle graph has every edge a local bridge with span N-1.
  +
  +       >>> G = nx.cycle_graph(9)
  +       >>> (0, 8, 8) in set(nx.local_bridges(G))
  +       True
  +    """
  +    if with_span is not True:
  +        for u, v in G.edges:
  +            if not (set(G[u]) & set(G[v])):
  +                yield u, v
  +    else:
  +        wt = nx.weighted._weight_function(G, weight)
  +        for u, v in G.edges:
  +            if not (set(G[u]) & set(G[v])):
  +                enodes = {u, v}
  +                def hide_edge(n, nbr, d):
  +                    if n not in enodes or nbr not in enodes:
  +                        return wt(n, nbr, d)
  +                    return None
  +
  +                try:
  +                    span = nx.shortest_path_length(G, u, v, weight=hide_edge)
  +                    yield u, v, span
  +                except nx.NetworkXNoPath:
  +                    yield u, v, float('inf')
  
verification_info: {"golden_diff": "diff --git a/networkx/algorithms/bridges.py b/networkx/algorithms/bridges.py\n--- a/networkx/algorithms/bridges.py\n+++ b/networkx/algorithms/bridges.py\n@@ -1,7 +1,7 @@\n # -*- coding: utf-8 -*-\n # bridges.py - bridge-finding algorithms\n #\n-# Copyright 2004-2016 NetworkX developers.\n+# Copyright 2004-2017 NetworkX developers.\n #\n # This file is part of NetworkX.\n #\n@@ -13,7 +13,7 @@\n import networkx as nx\n from networkx.utils import not_implemented_for\n \n-__all__ = ['bridges', 'has_bridges']\n+__all__ = ['bridges', 'has_bridges', 'local_bridges']\n \n \n @not_implemented_for('multigraph')\n@@ -121,3 +121,61 @@\n         return False\n     else:\n         return True\n+\n+\n+@not_implemented_for('multigraph')\n+@not_implemented_for('directed')\n+def local_bridges(G, with_span=True, weight=None):\n+    \"\"\"Iterate over local bridges of `G` optionally computing the span\n+\n+    A *local bridge* is an edge whose endpoints have no common neighbors.\n+    That is, the edge is not part of a triangle in the graph.\n+\n+    The *span* of a *local bridge* is the shortest path length between\n+    the endpoints if the local bridge is removed.\n+\n+    Parameters\n+    ----------\n+    G : undirected graph\n+\n+    with_span : bool\n+        If True, yield a 3-tuple `(u, v, span)`\n+\n+    weight : function, string or None (default: None)\n+        If function, used to compute edge weights for the span.\n+        If string, the edge data attribute used in calculating span.\n+        If None, all edges have weight 1.\n+\n+    Yields\n+    ------\n+    e : edge\n+        The local bridges as an edge 2-tuple of nodes `(u, v)` or\n+        as a 3-tuple `(u, v, span)` when `with_span is True`.\n+\n+    Examples\n+    --------\n+    A cycle graph has every edge a local bridge with span N-1.\n+\n+       >>> G = nx.cycle_graph(9)\n+       >>> (0, 8, 8) in set(nx.local_bridges(G))\n+       True\n+    \"\"\"\n+    if with_span is not True:\n+        for u, v in G.edges:\n+            if not (set(G[u]) & set(G[v])):\n+                yield u, v\n+    else:\n+        wt = nx.weighted._weight_function(G, weight)\n+        for u, v in G.edges:\n+            if not (set(G[u]) & set(G[v])):\n+                enodes = {u, v}\n+                def hide_edge(n, nbr, d):\n+                    if n not in enodes or nbr not in enodes:\n+                        return wt(n, nbr, d)\n+                    return None\n+\n+                try:\n+                    span = nx.shortest_path_length(G, u, v, weight=hide_edge)\n+                    yield u, v, span\n+                except nx.NetworkXNoPath:\n+                    yield u, v, float('inf')\n", "issue": "Create bridges.py\nContains three simple functions for detection and retrieval of bridges or local bridges in a undirected network.\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# bridges.py - bridge-finding algorithms\n#\n# Copyright 2004-2016 NetworkX developers.\n#\n# This file is part of NetworkX.\n#\n# NetworkX is distributed under a BSD license; see LICENSE.txt for more\n# information.\n\"\"\"Bridge-finding algorithms.\"\"\"\nfrom itertools import chain\n\nimport networkx as nx\nfrom networkx.utils import not_implemented_for\n\n__all__ = ['bridges', 'has_bridges']\n\n\n@not_implemented_for('multigraph')\n@not_implemented_for('directed')\ndef bridges(G, root=None):\n    \"\"\"Generate all bridges in a graph.\n\n    A *bridge* in a graph is an edge whose removal causes the number of\n    connected components of the graph to increase.\n\n    Parameters\n    ----------\n    G : undirected graph\n\n    root : node (optional)\n       A node in the graph `G`. If specified, only the bridges in the\n       connected component containing this node will be returned.\n\n    Yields\n    ------\n    e : edge\n       An edge in the graph whose removal disconnects the graph (or\n       causes the number of connected components to increase).\n\n    Raises\n    ------\n    NodeNotFound\n       If `root` is not in the graph `G`.\n\n    Examples\n    --------\n    The barbell graph with parameter zero has a single bridge::\n\n        >>> G = nx.barbell_graph(10, 0)\n        >>> list(nx.bridges(G))\n        [(9, 10)]\n\n    Notes\n    -----\n    This implementation uses the :func:`networkx.chain_decomposition`\n    function, so it shares its worst-case time complexity, :math:`O(m +\n    n)`, ignoring polylogarithmic factors, where *n* is the number of\n    nodes in the graph and *m* is the number of edges.\n\n    \"\"\"\n    chains = nx.chain_decomposition(G, root=root)\n    chain_edges = set(chain.from_iterable(chains))\n    for u, v in G.edges():\n        if (u, v) not in chain_edges and (v, u) not in chain_edges:\n            yield u, v\n\n\n@not_implemented_for('multigraph')\n@not_implemented_for('directed')\ndef has_bridges(G, root=None):\n    \"\"\"Decide whether a graph has any bridges.\n\n    A *bridge* in a graph is an edge whose removal causes the number of\n    connected components of the graph to increase.\n\n    Parameters\n    ----------\n    G : undirected graph\n\n    root : node (optional)\n       A node in the graph `G`. If specified, only the bridges in the\n       connected component containing this node will be considered.\n\n    Returns\n    -------\n    bool\n       Whether the graph (or the connected component containing `root`)\n       has any bridges.\n\n    Raises\n    ------\n    NodeNotFound\n       If `root` is not in the graph `G`.\n\n    Examples\n    --------\n    The barbell graph with parameter zero has a single bridge::\n\n        >>> G = nx.barbell_graph(10, 0)\n        >>> nx.has_bridges(G)\n        True\n\n    On the other hand, the cycle graph has no bridges::\n\n        >>> G = nx.cycle_graph(5)\n        >>> nx.has_bridges(G)\n        False\n\n    Notes\n    -----\n    This implementation uses the :func:`networkx.bridges` function, so\n    it shares its worst-case time complexity, :math:`O(m + n)`, ignoring\n    polylogarithmic factors, where *n* is the number of nodes in the\n    graph and *m* is the number of edges.\n\n    \"\"\"\n    try:\n        next(bridges(G))\n    except StopIteration:\n        return False\n    else:\n        return True\n", "path": "networkx/algorithms/bridges.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n# bridges.py - bridge-finding algorithms\n#\n# Copyright 2004-2017 NetworkX developers.\n#\n# This file is part of NetworkX.\n#\n# NetworkX is distributed under a BSD license; see LICENSE.txt for more\n# information.\n\"\"\"Bridge-finding algorithms.\"\"\"\nfrom itertools import chain\n\nimport networkx as nx\nfrom networkx.utils import not_implemented_for\n\n__all__ = ['bridges', 'has_bridges', 'local_bridges']\n\n\n@not_implemented_for('multigraph')\n@not_implemented_for('directed')\ndef bridges(G, root=None):\n    \"\"\"Generate all bridges in a graph.\n\n    A *bridge* in a graph is an edge whose removal causes the number of\n    connected components of the graph to increase.\n\n    Parameters\n    ----------\n    G : undirected graph\n\n    root : node (optional)\n       A node in the graph `G`. If specified, only the bridges in the\n       connected component containing this node will be returned.\n\n    Yields\n    ------\n    e : edge\n       An edge in the graph whose removal disconnects the graph (or\n       causes the number of connected components to increase).\n\n    Raises\n    ------\n    NodeNotFound\n       If `root` is not in the graph `G`.\n\n    Examples\n    --------\n    The barbell graph with parameter zero has a single bridge::\n\n        >>> G = nx.barbell_graph(10, 0)\n        >>> list(nx.bridges(G))\n        [(9, 10)]\n\n    Notes\n    -----\n    This implementation uses the :func:`networkx.chain_decomposition`\n    function, so it shares its worst-case time complexity, :math:`O(m +\n    n)`, ignoring polylogarithmic factors, where *n* is the number of\n    nodes in the graph and *m* is the number of edges.\n\n    \"\"\"\n    chains = nx.chain_decomposition(G, root=root)\n    chain_edges = set(chain.from_iterable(chains))\n    for u, v in G.edges():\n        if (u, v) not in chain_edges and (v, u) not in chain_edges:\n            yield u, v\n\n\n@not_implemented_for('multigraph')\n@not_implemented_for('directed')\ndef has_bridges(G, root=None):\n    \"\"\"Decide whether a graph has any bridges.\n\n    A *bridge* in a graph is an edge whose removal causes the number of\n    connected components of the graph to increase.\n\n    Parameters\n    ----------\n    G : undirected graph\n\n    root : node (optional)\n       A node in the graph `G`. If specified, only the bridges in the\n       connected component containing this node will be considered.\n\n    Returns\n    -------\n    bool\n       Whether the graph (or the connected component containing `root`)\n       has any bridges.\n\n    Raises\n    ------\n    NodeNotFound\n       If `root` is not in the graph `G`.\n\n    Examples\n    --------\n    The barbell graph with parameter zero has a single bridge::\n\n        >>> G = nx.barbell_graph(10, 0)\n        >>> nx.has_bridges(G)\n        True\n\n    On the other hand, the cycle graph has no bridges::\n\n        >>> G = nx.cycle_graph(5)\n        >>> nx.has_bridges(G)\n        False\n\n    Notes\n    -----\n    This implementation uses the :func:`networkx.bridges` function, so\n    it shares its worst-case time complexity, :math:`O(m + n)`, ignoring\n    polylogarithmic factors, where *n* is the number of nodes in the\n    graph and *m* is the number of edges.\n\n    \"\"\"\n    try:\n        next(bridges(G))\n    except StopIteration:\n        return False\n    else:\n        return True\n\n\n@not_implemented_for('multigraph')\n@not_implemented_for('directed')\ndef local_bridges(G, with_span=True, weight=None):\n    \"\"\"Iterate over local bridges of `G` optionally computing the span\n\n    A *local bridge* is an edge whose endpoints have no common neighbors.\n    That is, the edge is not part of a triangle in the graph.\n\n    The *span* of a *local bridge* is the shortest path length between\n    the endpoints if the local bridge is removed.\n\n    Parameters\n    ----------\n    G : undirected graph\n\n    with_span : bool\n        If True, yield a 3-tuple `(u, v, span)`\n\n    weight : function, string or None (default: None)\n        If function, used to compute edge weights for the span.\n        If string, the edge data attribute used in calculating span.\n        If None, all edges have weight 1.\n\n    Yields\n    ------\n    e : edge\n        The local bridges as an edge 2-tuple of nodes `(u, v)` or\n        as a 3-tuple `(u, v, span)` when `with_span is True`.\n\n    Examples\n    --------\n    A cycle graph has every edge a local bridge with span N-1.\n\n       >>> G = nx.cycle_graph(9)\n       >>> (0, 8, 8) in set(nx.local_bridges(G))\n       True\n    \"\"\"\n    if with_span is not True:\n        for u, v in G.edges:\n            if not (set(G[u]) & set(G[v])):\n                yield u, v\n    else:\n        wt = nx.weighted._weight_function(G, weight)\n        for u, v in G.edges:\n            if not (set(G[u]) & set(G[v])):\n                enodes = {u, v}\n                def hide_edge(n, nbr, d):\n                    if n not in enodes or nbr not in enodes:\n                        return wt(n, nbr, d)\n                    return None\n\n                try:\n                    span = nx.shortest_path_length(G, u, v, weight=hide_edge)\n                    yield u, v, span\n                except nx.NetworkXNoPath:\n                    yield u, v, float('inf')\n", "path": "networkx/algorithms/bridges.py"}]}