gpt4 book ai didi

algorithm - 无向图可以有自循环吗?

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:12:28 25 4
gpt4 key购买 nike

我的意思是有向图可以有自环,所以我不明白为什么无向图不能有自环(CLRS 说这是禁止的,但没有给出正当理由)。

Example: 

G_directed = (V,E) is a directed graph

Say this graph has the vertex set V = {1,2,3,4,5,6}

With edges E = {(1,2),(2,2),(2,4),(2,5),(4,1),(4,5),(5,4),(6,3)}
-----------------------------------------------------------------
Say we now decide to turn G_directed into an undirected graph:

G_undirected = (Vu,Eu) is an undirected graph

Vu = {1,2,3,4,5,6}

With edges E = {(1,2),(2,2),(2,4),(2,5),(4,1),(4,5),(6,3)}

示例中的 (2,2) 是自循环。我真的没有看到这对图形遍历有任何问题。

最佳答案

有几类无向图。在不允许循环(自引用)的地方,它们被称为 simple graphs .但确实没有理由考虑在同一对节点之间具有循环甚至多条边的无向图:这些被称为 multigraphs :

A loop is an edge (directed or undirected) that connects a vertex to itself; it may be permitted or not, according to the application.

A multigraph, as opposed to a simple graph, is an undirected graph in which multiple edges (and sometimes loops) are allowed.

关于algorithm - 无向图可以有自循环吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46624329/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com