简体   繁体   English

如何找到有向图中2个特定顶点之间的所有可能路径中存在的顶点?

[英]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. AB-路线尽头。

  1. Iterate over all vertices. 遍历所有顶点。
  2. Remove vertex from graph. 从图形中删除顶点。
  3. Check that path exist from A to B (ie with DFS) 检查从AB的路径是否存在(即使用DFS)
  4. If path don't exist - vertex is common for all routes. 如果路径不存在-顶点对于所有路径都是通用的。

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.

相关问题 找到有向图的顶点在时间O(| E | + | V |)中可到达的所有顶点 - Find all vertices reachable from a vertex of a directed graph in time O(|E| + |V|) 在未知大小的加权有向图上,一个人如何遍历两个顶点之间从最短到最长的所有可能的非循环路径? - On a weighted directed graph of unknown size, how can one iterate over all possible acyclic paths between two vertices from shortest to longest? 如何在有向图中找到最小顶点集,以便可以到达所有其他顶点 - How to find the minimum set of vertices in a Directed Graph such that all other vertices can be reached 检查有向无环图中两个顶点之间是否存在路径 - 查询 - Check if there exist a path between two vertices in directed acyclic graph - queries 通过有向图的所有顶点是否存在路径? - Does a path exist through all vertices of a directed graph? 在有向图中查找每个顶点的可到达顶点 - Finding reachable vertices for every vertex in a directed graph 图算法计算不同起始顶点和一个结束顶点之间的所有可能路径 - Graph Algorithm to count all possible paths between different starting vertices and one end vertex 在有向图中找到两个特定顶点之间的所有节点 - Finding all the nodes between two certain vertices in a directed graph 在有向图中为所有顶点找到两步邻居的高效算法 - Efficient algorithm to find 2-step neighbors for all vertices in a directed graph 如何在有向图和线性时间中找到两个顶点之间不同的最短路径的数量? - How to find the number of different shortest paths between two vertices, in directed graph and with linear-time?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM