Repository: networkx/networkx

Issue:
`algorithms.bridges.bridges()` does a redundant copy of graph
This is the code of the `bridges` function:

```python
def bridges(G, root=None):
    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
```

The statement in the middle:

```python
    H_copy = H.copy()
```

Seem to have no effect, because `H_copy` is not used anywhere else in this module, and therefore **can be removed**.

### Current Behavior

Actually in addition to being redundant due to `H_copy` not used anywhere, presence of this statement makes extending the `networkx.Graph` class harder.

If you inherit from `networkx.Graph` and your class would have a constructor that requires some parameters to be provided, you wouldn't be able to use the `bridges()` function at all. Because this `.copy()` method has the following line:

```python
# Body of .copy() method
G = self.__class__()
```

And for inheritors of `networkx.Graph` that have custom constructors `self.__class__()` raises `TypeError` on missing arguments.

### Expected Behavior

There should be no redundant lines, and `bridges()` should work for inheritors as long as they don't override some dependent methods.

### Steps to Reproduce

Set up for example this:

```python
class Map(nx.Graph):

    def __init__(self: tp.Self, routes: tp.Iterable[str]) -> None:
        super().__init__()
```

Initialize this object like `Map(routes=("a", "b"))` and try using `bridges()` with it.

### Environment

Python version: 3.11
NetworkX version: 3.3



Discussion:
Thanks for this!  You are correct that the copy line is not needed and should be deleted.

You comment about subclassing `nx.Graph` suggests that it is important to override the `copy` method when your subclass has additional init parameters. Removing the `copy` command from `bridges` will let your example code run, but anything else that uses the `copy` method will not work. I'd suggest overriding the copy method. Another approach would be to create your subclass and have it hold the graph object as an attribute of the new class rather than be a subclass. But that depends on what else you do with your subclass. :)

Thanks! A PR that removes the `H_copy` assignment would fix this issue.  

Resolving patch:
diff --git a/networkx/algorithms/bridges.py b/networkx/algorithms/bridges.py
--- a/networkx/algorithms/bridges.py
+++ b/networkx/algorithms/bridges.py
@@ -70,7 +70,6 @@ def bridges(G, root=None):
     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():


Test patch: