code: def bridges(G, root=None):
      """Generate all bridges in a graph.
  
      A *bridge* in a graph is an edge whose removal causes the number of
      connected components of the graph to increase.  Equivalently, a bridge is an
      edge that does not belong to any cycle. Bridges are also known as cut-edges,
      isthmuses, or cut arcs.
  
      Parameters
      ----------
      G : undirected graph
  
      root : node (optional)
         A node in the graph `G`. If specified, only the bridges in the
         connected component containing this node will be returned.
  
      Yields
      ------
      e : edge
         An edge in the graph whose removal disconnects the graph (or
         causes the number of connected components to increase).
  
      Raises
      ------
      NodeNotFound
         If `root` is not in the graph `G`.
  
      NetworkXNotImplemented
          If `G` is a directed graph.
  
      Examples
      --------
      The barbell graph with parameter zero has a single bridge:
  
      >>> G = nx.barbell_graph(10, 0)
      >>> list(nx.bridges(G))
      [(9, 10)]
  
      Notes
      -----
      This is an implementation of the algorithm described in [1]_.  An edge is a
      bridge if and only if it is not contained in any chain. Chains are found
      using the :func:`networkx.chain_decomposition` function.
  
      The algorithm described in [1]_ requires a simple graph. If the provided
      graph is a multigraph, we convert it to a simple graph and verify that any
      bridges discovered by the chain decomposition algorithm are not multi-edges.
  
      Ignoring polylogarithmic factors, the worst-case time complexity is the
      same as the :func:`networkx.chain_decomposition` function,
      $O(m + n)$, where $n$ is the number of nodes in the graph and $m$ is
      the number of edges.
  
      References
      ----------
      .. [1] https://en.wikipedia.org/wiki/Bridge_%28graph_theory%29#Bridge-Finding_with_Chain_Decompositions
      """
      multigraph = G.is_multigraph()
      H = nx.Graph(G) if multigraph else G
      chains = nx.chain_decomposition(H, root=root)
      chain_edges = set(chain.from_iterable(chains))
      H_copy = H.copy()
      if root is not None:
          H = H.subgraph(nx.node_connected_component(H, root)).copy()
      for u, v in H.edges():
          if (u, v) not in chain_edges and (v, u) not in chain_edges:
              if multigraph and len(G[u][v]) > 1:
                  continue
              yield u, v
  
imports: from itertools import chain
  import networkx
  from networkx.utils import not_implemented_for
label_desc: Use image node_id 1 for calling a global function with example usage: bridges(G, root) without return types