简体   繁体   English

如何在有向图中对节点进行分组,以使组中的两个节点之间没有路径?

[英]How to group nodes in a directed graph so that no two nodes in a group have paths between them?

I have a large directed graph with cycles (a control-flow-graph from a large program).我有一个带有循环的大型有向图(来自大型程序的控制流图)。 I want to group the nodes such that each group would contain nodes independent to each other.我想对节点进行分组,以便每个组都包含彼此独立的节点。 Two nodes A and B are independent to each other if there is no path from node A to node B or node B to node A. Is there an efficient algorithm to do this?如果没有从节点 A 到节点 B 或节点 B 到节点 A 的路径,则两个节点 A 和 B 相互独立。是否有有效的算法来做到这一点?

The trivial algorithm here is to start by picking a node A, remove all nodes reachable from it, then transpose the graph, and remove all nodes that are again reachable from A. Start over again with remaining nodes (with suitable caching of reachability).这里的简单算法是首先选择一个节点 A,从它删除所有可访问的节点,然后转置图,并删除从 A 再次可访问的所有节点。从剩余节点重新开始(具有适当的可达性缓存)。

If this question is off-topic here, I would also be glad to be pointed to the right SO community.如果这个问题在这里是题外话,我也很高兴被指向正确的 SO 社区。

I found this question related, but in my case, existence of a path from A to B does not mean a B to A path exists.我发现这个问题相关,但在我的情况下,从 A 到 B 的路径的存在并不意味着 B 到 A 的路径存在。 Hence, they need not be strongly connected.因此,它们不需要强连接。 This question is also similar, but talks about having nodes without edge connection rather than path connection. 这个问题也类似,但谈论的是没有边缘连接而不是路径连接的节点。

You may end to the up with a great many "groups", with each node present in multiple groups.您可能会以大量“组”结束,每个节点都存在于多个组中。

Example, a graph with three nodes A, B and C.例如,具有三个节点 A、B 和 C 的图。

Links: B -> C and C -> B链接:B -> C 和 C -> B

The "groups" are ( A,B ) and ( A, C ) “组”是 ( A,B ) 和 ( A, C )

Is this really what you want?这真的是你想要的吗? It is hard to imagine what purpose this might serve.很难想象这会起到什么作用。

In the case of a larger graph that happens to be bipartite, you will need a group for every distinct pair where one node is in one part and the other in the other part.在碰巧是二分图的较大图的情况下,您将需要一个组用于每个不同的对,其中一个节点位于一个部分,另一个节点位于另一部分。

Since this is a control flow graph, every node is independent of every node higher in the call hierarchy, and every node in a different calling tree.由于这是一个控制流图,每个节点都独立于调用层次结构中更高的每个节点,以及不同调用树中的每个节点。

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

相关问题 查找图之间的路径最少为2的节点 - Find the nodes of a graph with minimum 2 paths between them 计数节点数-有向图中任意两个节点之间的不相交路径,以使距离&lt;= K - Count number of Node - Disjoint Paths between any two nodes in directed graph such that there distance is <=K 在加权有向图中使用 DFS 查找两个节点之间的所有路径 - Find all paths between two nodes using DFS in weighted directed graph 查找两个图节点之间的所有路径 - Find all paths between two graph nodes 柠檬图如何找到两个节点之间的所有路径 - Lemon graph how to find all paths between two nodes 在有向图中找到两个特定顶点之间的所有节点 - Finding all the nodes between two certain vertices in a directed graph 如何在Matlab或ucinet的有向图中找到两个节点之间的最强路径? - How to find strongest path between two nodes in a directed graph in matlab or ucinet? 有效地找到有向图中两个节点之间某个路径上的所有节点 - Efficiently finding all nodes on some path between two nodes in a directed graph 图算法建议:找到两个节点之间所有受影响的路径 - Graph algorithm advise: find all affected paths between two nodes Boost Graph Library中两个节点之间的所有路径 - All paths between two nodes in Boost Graph Library
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM