Graphs.jl icon indicating copy to clipboard operation
Graphs.jl copied to clipboard

Add support for induced bipartite subgraph

Open Codsilla opened this issue 3 years ago • 3 comments

As part of a project, I had to use bipartite induced subgraphs of a graph.

Let $G=(V,E) $ be a graph and let $X,Y\subseteq V$ such that $X \cap Y = \emptyset$. The bipartite subgraph of G induced by $X$ and $Y$ is $$(X \cup Y, X \times Y \cap E) $$ In other words, it's the bipartite subgraph made of all the edges of $G$ that are between $X$ and $Y$. Such a construction is useful in, for example, the search of vertex separators.

I've made a simple implementation (30 lines or so) for it and I think it might be worth including it. Before making a pull request, I wanted to see if this is something people might find interesting to have in the package.

Codsilla avatar Jun 13 '22 14:06 Codsilla

A function which more generally returns the induced subgraph of a set of vertices could be useful. It could also be a good idea to define views on graphs where we could filter the edges and vertices (by filtering vertices, we would get the induced subgraph), see https://github.com/JuliaGraphs/Graphs.jl/issues/128#issuecomment-1129995566.

etiennedeg avatar Jun 13 '22 14:06 etiennedeg

I agree that it would be useful functionality. @Codsilla do you want to get started on a PR so we can help?

gdalle avatar Jun 19 '22 20:06 gdalle

A function which more generally returns the induced subgraph of a set of vertices could be useful.

The function induced_subgraph does just that :) Views would be nice but are not exactly in the scope of what is proposed.

I agree that it would be useful functionality. @Codsilla do you want to get started on a PR so we can help?

Just did!

Codsilla avatar Jun 20 '22 03:06 Codsilla