简体   繁体   English

完全断开二分图

[英]Completely disconnecting a bipartite graph

I have a disconnected bipartite undirected graph. 我有一个断开的二分无向图。 I want to completely disconnect the graph. 我想完全断开图表。 Only operation that I can perform is to remove a node. 只有我可以执行的操作是删除节点。 Removing a node will automatically delete its edges. 删除节点将自动删除其边缘。 Task is to minimize the number of nodes to be removed. 任务是最小化要删除的节点数。 Each node in the graph has atmost 4 edges. 图中的每个节点最多有4个边。

By completely disconnecting a graph, I mean that no two nodes should be connected through a link. 通过完全断开图形,我的意思是不应该通过链接连接两个节点。 Basically an empty edge set. 基本上是一个空边集。

I think, you cannot prove your algorithm is optimal because, in fact, it is not optimal. 我认为,你无法证明你的算法是最优的,因为事实上它并不是最优的。

To completely disconnect your graph minimizing the number of nodes to be removed, you have to remove all the nodes belonging to the minimal vertex cover of your graph. 要完全断开图形,最大限度地减少要删除的节点数,必须删除属于图形最小顶点覆盖的所有节点。 Searching the minimal vertex cover is usually NP-complete, but for bipartite graphs there is a polynomial-time solution. 搜索最小顶点覆盖通常是NP完全的,但对于二分图,存在多项式时间解。

Find maximum matching in the graph (probably with Hopcroft–Karp algorithm ). 在图中找到最大匹配(可能使用Hopcroft-Karp算法 )。 Then use König's theorem to get the minimal vertex cover: 然后使用König定理得到最小的顶点覆盖:

Consider a bipartite graph where the vertices are partitioned into left (L) and right (R) sets. 考虑一个二分图,其中顶点被划分为左(L)和右(R)集。 Suppose there is a maximum matching which partitions the edges into those used in the matching (E_m) and those not (E_0). 假设存在最大匹配,将边缘划分为匹配(E_m)中使用的边缘和不匹配(E_0)的边缘。 Let T consist of all unmatched vertices from L, as well as all vertices reachable from those by going left-to-right along edges from E_0 and right-to-left along edges from E_m. 令T由来自L的所有不匹配顶点以及通过沿着E_0的边缘从左到右沿着从E_m的边缘向右到左的所有顶点组成。 This essentially means that for each unmatched vertex in L, we add into T all vertices that occur in a path alternating between edges from E_0 and E_m. 这实质上意味着对于L中的每个不匹配的顶点,我们将在E_0和E_m的边之间交替的路径中出现的所有顶点添加到T中。

Then (L \\ T) OR (R AND T) is a minimum vertex cover. 然后(L \\ T)OR(R AND T)是最小顶点覆盖。

Here's a counter-example to your suggested algorithm. 这是您建议的算法的反例。

在此输入图像描述

The best solution is to remove both nodes A and B, even though they are different colors. 最好的解决方案是删除节点A和B,即使它们是不同的颜色。

I have thought of an algorithm for it but am not able to prove if its optimal. 我已经想到了它的算法,但我无法证明它是否是最优的。

My algorithm: On each disconnected subgraph, I run a BFS and color it accordingly. 我的算法:在每个断开连接的子图上,我运行一个BFS并相应地对其进行着色。 Then I identify the number of nodes colored with each color and take the minimum of the two and store. 然后我确定用每种颜色着色的节点数量,并取两者中的最小值并存储。 I repeat the procedure for each subgraph and add up to get the required minimum. 我重复每个子图的程序,然后加起来得到所需的最小值。 Help me prove the algorithm if it's correct. 如果它是正确的,请帮助我证明算法。

EDIT: The above algorithm is not optimal. 编辑:上述算法不是最优的。 The accepted answer has been verified to be correct. 已接受的答案已经过验证是正确的。

Since all the edges are from one set to another, find these two sets using say BFS and coloring using 2 colours. 由于所有边缘都是从一个集合到另一个集合,因此使用BFS和使用2种颜色着色来找到这两个集合。 Then remove the nodes in smaller set. 然后删除较小集中的节点。

Since there are no edges among themselves the rest of the nodes are disconnected as well. 由于它们之间没有边缘,所以其余节点也是断开的。

[As a pre-processing step you can leave out nodes with 0 edges first.] [作为预处理步骤,您可以先省略0边的节点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM