Graph 用负边分裂无向图

Graph 用负边分裂无向图,graph,graph-theory,connected-components,Graph,Graph Theory,Connected Components,想知道是否存在一种算法来分割给定负边的无向连通分量图 基本上,负边中提供的顶点应该是不可访问的。如果希望图形中的连接组件仅包含正边,请首先从图形中删除所有负边。然后运行DFS(深度优先搜索)以查找所有连接的组件 这是算法 Begin For each edge e in graph G, if e is negative, remove e from G. For each vertex v in G, do: If v is not labeled as v

想知道是否存在一种算法来分割给定负边的无向连通分量图


基本上,负边中提供的顶点应该是不可访问的。

如果希望图形中的连接组件仅包含正边,请首先从图形中删除所有负边。然后运行DFS(深度优先搜索)以查找所有连接的组件

这是算法

Begin 
    For each edge e in graph G, if e is negative, remove e from G.

    For each vertex v in G, do:
        If v is not labeled as visited
            Let c be a new component, and add c to set C.
            Call procedure DFS(v, c) to find one component of positive edges only.
        End If
    End For

    The set C contains all the connected components consisting of positive edges only.
End

Procedure DFS(v, c)
    Add v to c, and label v as visited.
    For each edge from v to w, do
        If vertex w is not labeled as visited then
            Call DFS(G,w)
        End If
    End For
End Procedure

我想DFS在删除负边缘时应该可以完成它-为什么需要特殊的算法?不确定我是否理解你可以详细说明吗?@AdiGuN不确定我是否理解你试图实现的目标你可以详细说明吗?我有一个正边缘和负边缘的列表。我希望构建具有正边的连接组件,以便每个连接组件都没有任何负边如果您不希望连接组件中有任何负边,那么,如前所述,在运行连接组件算法时,只使用正边。我不确定你需要详细说明什么部分。