[英]How to find vertices exist in all possible route between 2 specific vertex in a directed graph?
How to find the common vertices in all possible routes between 2 specific vertices in a directed graph? 如何在有向图的2个特定顶点之间的所有可能路径中找到公共顶点? At least one route exist is a prerequisite. 至少存在一条路由是前提条件。
O(|V||E|)
solution. O(|V||E|)
解。 A and B - end of routes. A和B-路线尽头。
The only way a vertex will be in all possible paths is if it's a 'bottleneck' - all paths go through it because it's the only way to go. 顶点在所有可能路径中的唯一方式是,如果它是“瓶颈”,则所有路径都将通过,因为这是唯一的方式。
You can determine which vertices are in this set by removing each from the graph and testing if there still exists a path through the graph. 您可以通过从图中删除每个顶点并测试是否仍然存在穿过图中的路径来确定该集合中的哪些顶点。 By removing the node, you're looking to see if this removes all viable paths from the source to the destination. 通过删除该节点,您正在查看是否会删除从源到目标的所有可行路径。
您可以对Bellman-Ford进行变形,以检查是否在所有可能性中都使用了顶点。
采取所有可能路线的交叉点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.