# For a tree, how to obtain two induced subgraph by breaking an edge in LightGraphs?

**URL:** <https://discourse.julialang.org/t/for-a-tree-how-to-obtain-two-induced-subgraph-by-breaking-an-edge-in-lightgraphs/56676>\
**Category:** Graphs\
**Tags:** lightgraphs\
**Created:** [March 7, 2021, 2:12pm UTC](https://discourse.julialang.org/t/for-a-tree-how-to-obtain-two-induced-subgraph-by-breaking-an-edge-in-lightgraphs/56676 "2021-03-07T14:12:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Post date:** [March 7, 2021, 2:12pm UTC](https://discourse.julialang.org/t/for-a-tree-how-to-obtain-two-induced-subgraph-by-breaking-an-edge-in-lightgraphs/56676/1 "2021-03-07T14:12:24Z")

</div>

For example, if I have a tree

```julia
                  1 - 2 - 3 - 4
                      | |
                      5 6 - 7 - 8

```

If breaking the ege (3,6), I want to obtain two induced subgraphs

```julia
                  1 - 2 - 3 - 4
                      |   
                      5 

```

and

```julia
                  6 - 7 - 8

```

At present, I implemented a very cumbersome approach, which is

1. Enumerate the neighbors of vertex 6 (excluding 3 of course) and the neighbors of those neighbors and so on (recursively). Recording the vertices in a list, then serve the list to `LightGraphs.induced_subgraph(g, the_list)`.
2. Do the same thing for vertex 3.

I wonder if there is a better approach?
