令G =(v,e)有向图。令V为G中的顶点,找到参与非简单的定向路径的顶点的数量

发布于 2025-02-12 22:18:09 字数 274 浏览 0 评论 0原文

令G =(v,e)有向图。

让V为G中的顶点,找到参与非简单的定向路径的顶点的数量到

我的尝试:

  1. 查找牢固连接的组件,v_1,v_1,v_2 ...,v_i(使用DFS搜索产生) 。

  2. 在v_1,v_2 ...,v_i。

    上执行拓扑排序
  3. 假设v in v_j中的v。 在V_1上执行DFS到V_J,并在紧密连接中计数所有顶点 大小大于1的组件。

我的解决方案正确吗?

Let G=(V, E) directed graph.

Let v be a vertex in G, find the number of vertices that take part in non-simple directed paths to v.

My attempt:

  1. Find strongly connected components , V_1,V_2...,V_i (using DFS search produces).

  2. Perform topological sorting on the V_1,V_2...,V_i.

  3. Suppose v in V_j.
    Perform DFS on V_1 to V_j and count all vertex in the strongly connected
    components whose size is bigger than 1.

Is my solution correct?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

来日方长 2025-02-19 22:18:09

第一步:检查您的图表是否周期。它没有,然后没有非简单路径。

第二:检查您的图表是否计数。如果有1个组件,则参与非简单有向路径的顶点数量等于图中的顶点数量,因为每个顶点都可以在一个周期中转到一个顶点,绕周期绕过一个周期,并继续继续目的地。

第三:检查包含v的循环的组件。它没有,那么没有非简单路径。否则,参与非简单有向路径的顶点数量等于组件中的顶点数量。

First step: check your graph for cycles. It there are none, then there are no non-simple paths..

Second: check your graph for component count. If there is 1 component then the number of vertices that take part in non-simple directed paths is equal to the number of vertices in the graph, because every vertex can go to a vertex in a cycle, go around the cycle, and continue to the destination.

Third: Check the component that contains v for cycles. It there are none, then there are no non-simple paths. Otherwise the number of vertices that take part in non-simple directed paths is equal to the number of vertices in the component.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文