当前位置: 首页 > 知识库问答 >
问题:

图中的连接点

颜德馨
2023-03-14

我正在研究一个算法,用来在图中找到所有的连接点,这里给出了。

这是计算艺术点数的函数:

// A recursive function that find articulation points using DFS traversal
// u --> The vertex to be visited next
// visited[] --> keeps tract of visited vertices
// disc[] --> Stores discovery times of visited vertices
// parent[] --> Stores parent vertices in DFS tree
// ap[] --> Store articulation points
void Graph::APUtil(int u, bool visited[], int disc[],
                                      int low[], int parent[], bool ap[])
{
    // A static variable is used for simplicity, we can avoid use of static
    // variable by passing a pointer.
    static int time = 0;

    // Count of children in DFS Tree
    int children = 0;

    // Mark the current node as visited
    visited[u] = true;

    // Initialize discovery time and low value
    disc[u] = low[u] = ++time;

    // Go through all vertices aadjacent to this
    list<int>::iterator i;
    for (i = adj[u].begin(); i != adj[u].end(); ++i)
    {
        int v = *i;  // v is current adjacent of u

        // If v is not visited yet, then make it a child of u
        // in DFS tree and recur for it
        if (!visited[v])
        {
            children++;
            parent[v] = u;
            APUtil(v, visited, disc, low, parent, ap);

            // Check if the subtree rooted with v has a connection to
            // one of the ancestors of u
            low[u]  = min(low[u], low[v]);

            // u is an articulation point in following cases

            // (1) u is root of DFS tree and has two or more chilren.
            if (parent[u] == NIL && children > 1)
               ap[u] = true;

            // (2) If u is not root and low value of one of its child is more
            // than discovery value of u.
            if (parent[u] != NIL && low[v] >= disc[u])
               ap[u] = true;
        }

        // Update low value of u for parent function calls.
        else if (v != parent[u])
            low[u]  = min(low[u], disc[v]);
    }
}

现在我很难理解这段代码的某些行。

if (parent[u] != NIL && low[v] >= disc[u])
               ap[u] = true;

上面的陈述是否意味着,由于顶点“v”是顶点“u”的直接子点,如果有某个顶点是可以从“v”或“v”本身到达的,并且是在“u”之后发现的,那就意味着存在一个后边。

else if (v != parent[u])
     low[u]  = min(low[u], disc[v]);

我的解释对吗?如果我错了请给我正确的解释。

共有1个答案

易飞文
2023-03-14

首先让我们集中讨论关节点的含义,它意味着当你移除它时,图会分裂。

三点连在一起的简单图:A-B-C

很明显B是连接点。当我们从a点进行深度优先搜索时,我们得到了disc[a]

LOW[B]<=DISC[C],因为没有路径(不包括来自其父路径)可供点C到达前一个访问点,因此点B是一个连接。

从parent[u]!=NIL,我们可以看到第一个是一个例外,因为它之前没有前一点。

 类似资料:
  • 我正在进行一个项目,我们以线性方式进行测量并旋转样本以生成3D曲面图。 数据来自极坐标格式,我们有4个数据集: 我可以通过用sin和cos生成x和y向量并根据该矩阵绘制结果来将其转换为笛卡尔点。 因此,一个示例“准备绘制”矩阵集如下所示: Matlab正在连接我想要的向量。但是,它没有将90度旋转连接到135度旋转。我如何让它做到这一点? 生成类似于上述示例的图形的基本代码如下:

  • 问题内容: 我有以下SQL: 在Oracle SQL Developer 4.0.0.13(连接到DB2数据库)中,我在以下斜体下面显示了 一条弯曲的 行:“ from pluspbillline ”和“ left external join workorder ”。 警告说:“ pluspbillline已与连接图的其余部分断开连接”。这是什么意思? 问题答案: 我不确定是什么原因导致Oracl

  • 我正在寻找一个算法,找到顶点的最小子集,这样从图中移除这个子集(以及连接这些顶点的边),所有其他顶点都变得不连通(即,图将没有任何边)。 null 我有图论的基础知识,所以请原谅任何不正确的地方。

  • 问题内容: 目前,我们正在使用带有8gb RAM的4个cpu窗口框,并在同一框上安装了MySQL5.x。我们正在为应用程序使用Weblogic应用程序服务器。我们的应用程序目标是200个并发用户(显然不是同一模块/屏幕)。那么,我们应该在连接池中配置的最佳连接数是多少(最小和最大数)(我们正在使用weblogic AS的连接池机制)? 问题答案: 这个问题有一个非常简单的答案: 连接池中的连接数应

  • 我正在使用hikaricp(这可能也适用于任何其他数据库连接池)。我有一个DBPool类,在其中我实例化了一个HikariDataSource(使用HikariConfig对象)。对于这个DBPool,我使用lazyholder习惯用法来限制每个VM一个池实例。但是,一旦获得对池的引用,就可以检索连接对象(无需任何进一步的锁/同步/信号量检查),因为我认为连接池会处理我的连接对象限制。每次通过数据

  • 我尝试使用combinedchart,但结果是这样的: