3

I have a bipartite graph. I'll refer to red-nodes and black-nodes of the respective disjoint sets.

I would like to know how to find a connected induced subgraph that maximizes the number of red-nodes while ensuring that all black nodes in the subgraph have new valences less than or equal to 2. Where "induced" means that if two nodes are connected in the original graph and both exist in the subgraph then the edge between them is automatically included. Eventually I'd like to introduce non-negative edge-weights.

Can this be reduced to a standard graph algorithm? Hopefully one with known complexity and simple implementation.

It's clearly possible to grow a subgraph greedily. But is this best?

Alec Jacobson
  • 6,032
  • 5
  • 51
  • 88
  • By "remaining black nodes" it sounds like you mean black nodes that are *not* in the subgraph... But if so, then the solution is trivial: if the entire graph is connected then it is the unique optimal solution; if it's not connected, there is no solution. – j_random_hacker Jun 14 '17 at 23:26
  • Oh no, sorry that was unclear. I meant the ones _in_ the subgraph. I will edit. – Alec Jacobson Jun 15 '17 at 00:11
  • Is the subgraph required to be an induced subgraph? (Meaning: If we want to choose two vertices b and r to include, and there is an edge (b, r) in the original graph, are we forced to include this edge in the subgraph too?) – j_random_hacker Jun 15 '17 at 11:23
  • Yes. I'll edit. – Alec Jacobson Jun 15 '17 at 13:35

2 Answers2

1

I'm sure that this problem belongs to NP-complete class, so there is no easy way to solve it. I would suggest you using constraint satisfaction approach. There are quite a few ways to formulate your problem, for example mixed-integer programming, MaxSAT or even pseudo-boolean constraints.

For the first try, I would recommend MiniZinc solver. For example, consider this example of defining and solving graph problems in MiniZinc.

CaptainTrunky
  • 1,562
  • 2
  • 15
  • 23
1

Unfortunately this is NP-hard, so there are probably no polynomial-time algorithms to solve it. Here is a reduction from the NP-hard problem Independent Set, where we are given a graph G = (V, E) (with n = |V| and m = |E|) and an integer k, and the task is to determine whether it is possible to find a set of k or more vertices such that no two vertices in the set are linked by an edge:

  • For every vertex v_i in G, create a red vertex r_i in H.
  • For every edge (v_i, v_j) in G, create the following in H:
    • a black vertex b_ij,
    • n+1 red vertices t_ijk (1 <= k <= n+1),
    • n black vertices u_ijk (1 <= k <= n),
    • n edges (t_ijk, u_ijk) (1 <= k <= n)
    • n edges (t_ijk, u_ij{k-1}) (2 <= k <= n+1)
    • the three edges (r_i, b_ij), (r_j, b_ij), and (t_ij1, b_ij).
  • For every pair of vertices v_i, v_j, create the following:
    • a black vertex c_ij,
    • the two edges (r_i, c_ij) and (r_j, c_ij).
  • Set the threshold to m(n+1)+k.

Call the set of all r_i R, the set of all b_ij B, the set of all c_ij C, the set of all t_ij T, and the set of all u_ij U.

The general idea here is that we force each black vertex b_ij to choose at most 1 of the 2 red vertices r_i and r_j that correspond to the endpoints of the edge (i, j) in G. We do this by giving each of these b_ij vertices 3 outgoing edges, of which one (the one to t_ij1) is a "must-have" -- that is, any solution in which a t_ij1 vertex is not selected can be improved by selecting it, as well as the n other red vertices it connects to (via a "wiggling path" that alternates between vertices in t_ijk and vertices in u_ijk), getting rid of either r_i or r_j to restore the property that no black vertex has 3 or more neighbours in the solution if necessary, and then finally restoring connectedness by choosing vertices from C as necessary. (The c_ij vertices are "connectors": they exist only to ensure that whatever subset of R we include can be made into a single connected component.)

Suppose first that there is an IS of size k in G. We will show that there is a connected induced subgraph X with at least m(n+1)+k red nodes in H, in which every black vertex has at most 2 neighbours in X.

First, include in X the k vertices from R that correspond to the vertices in the IS (such a set must exist by assumption). Because these vertices form an IS, no vertex in B is adjacent to more than 1 of them, so for each vertex b_ij, we may safely add it, and the "wiggling path" of 2n+1 vertices beginning at t_ij1, into X as well. Each of these wiggling paths contains n+1 red vertices, and there are m such paths (one for each edge in G), so there are now m(n+1)+k red vertices in X. Finally, to ensure that X is connected, add to it every vertex c_ij such that r_i and r_j are both in X already: notice that this does not change the total number of red vertices in X.

Now suppose that there is a connected induced subgraph X with at least m(n+1)+k red nodes in H, in which every black vertex has at most 2 neighbours in X. We will show that there is an IS in G of size k.

The only red vertices in H are those in R and those in T. There are only n vertices in R, so if X does not contain all m wiggly paths, it must have at most (m-1)(n+1)+n = m(n+1)-1 red vertices, contradicting the assumption that it has at least m(n+1)+k red vertices. Thus X must contain all m wiggly paths. This leaves k other red vertices in X, which must be from R. No two of these vertices can be adjacent to the same vertex in B, since that B-vertex would then be adjacent to 3 vertices: thus, these k vertices correspond to an IS in G.

Since a YES-instance of IS implies a YES-instance to the constructed instance of your problem and vice versa, the solution to the constructed instance of your problem corresponds exactly to the solution to the IS instance; and since the construction is clearly polynomial-time, this establishes that your problem is NP-hard.

j_random_hacker
  • 50,331
  • 10
  • 105
  • 169