0

I have a connected graph, $G$. For a subset of the edges of that graph, $E$, I would like to know:

  • Do these edges cut the graph, resulting in two subgraphs $A$ and $B$ such that each edge in $E$ has one endpoint in each subgraph?
  • If so, how many nodes are in $A$ and $B$?
  • Also, given any vertex of the original graph, does it reside in $A$ or $B$.

I have an algorithm to answer these questions.

  1. Start by assigning an arbitrary node to $A$.
  2. Then look at the neighbours of this node:
    • If they are connected via an edge in $E$, assign the neighbour to $B$;
    • If not, assign it to $A$.
  3. For all the newly assigned nodes, repeat step 2. If any of their neighbours are already assigned, check there are no contradictions.

This continues until either all nodes are assigned, or a contradiction is found. The former implies that $E$ is indeed a cut, and returns $A$ and $B$. The latter implies that $E$ is not a cut.

The complexity of this algorithm is $O(|G|)$. For large $|G| >> |E|$, this seems like it may be much more inefficient that necessary. Is there a faster method?

  • 1
    There is no way to determine this without checking every edge in $G$. It could be any edge in $G$ outside $E$ that connects $A$ and $B$. (BTW, what do you mean by $|G|$? The number of nodes in $G$, the number of edges in $G$, something else?) – Paul Sinclair May 12 '23 at 16:53

1 Answers1

1

This is related to a very important and well-studied question in computational graph theory. First, to answer your question, if you know your original graph $G$ is connected, you can simply run a depth-first search on your graph minus the set of edges $E$. The result will be your subgraph $A$ and everything else will be $B$. (If $B$ is empty, then $E$ isn't actually a cut.) This is basically what you do. DFS runs in $O(|V| + |D|)$, where $|V|$ is the number of vertices in $G$ and $|D|$ is the number of edges in $G$. In general, you can't really get the runtime in terms of $|E|$. However...

If you reduce this problem to a min-cut problem by giving each edge a weight of $1$, you can kind of reduce your runtime in the following sense. There is a structure in the theory of minimum cuts called a Gomory-Hu Cut Equivalence Tree. It costs something like $O(|V|^2|D|^2)$ to construct, but after construction, for any $u, v \in V$, it costs at worst only $O(|V|)$ to look up the minimum cost of a $u$-$v$ cut. Which is to say, for any choice of cut $E$, pick $uv \in E$ and look up the $u$-$v$ cut in the Gomory-Hu Tree. If $|E|$ is less than that value, $E$ is not actually a cut. This strategy is best used on large graphs where you want to test many different sets of edges (and so the construction of the Gomory-Hu Tree is worth it).

Beanway
  • 71