algorithm - 仅在给定邻接矩阵的情况下在线性时间内检查图形属性

标签 algorithm graph adjacency-matrix

我遇到了一个关于图表的问题。 让我们定义一个耙图。

A n-vertex graph is a rake when it meets certain conditions:

  1. there is a vertex of degree 1 in the graph
  2. this vertex is connected to a vertex of degree 2
  3. this second vertex is connected to another vertex of degree n-2 other vertices may or may not be connected to each other.

我得到了一个包含 n 个顶点的图的邻接矩阵。我的任务是检查给定矩阵表示的图形是否为“rake”。问题是必须在线性时间内完成。

我什么都试过了。当你有邻接表时这很容易做到,但我如何使用给定的矩阵让它花费 O(n) 时间?

最佳答案

好吧,我似乎找到了答案!确实有一个线性时间算法可以解决这个问题,因为我提出的这个问题在科学界被称为检查一个图是否是蝎子图!

在这里您可以找到我一直在寻找的算法。 http://www.cs.cornell.edu/courses/cs681/2007fa/Handouts/scorpion.pdf

感谢您的帮助!

关于algorithm - 仅在给定邻接矩阵的情况下在线性时间内检查图形属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20154189/

相关文章:

matlab - 使用 matlab 从给定的二进制矩阵创建邻域图

C++/Opencv 了解正在使用的数据类型

java - 使用 A* 在图中寻找路径

c++ - 如何避免在 BFS 中进一步搜索顶点的邻居?我正在使用 Boost 图形库

php - 如何使用 MySQL 数据生成动态图表?

c# - 为加权图生成邻接矩阵

图形表示 : adjacency list vs matrix

algorithm - (with example) 为什么 KMP 字符串匹配 O(n)。不应该是 O(n*m) 吗?

ruby-on-rails - 如何根据点数相应地查找和更新关卡?

python - 在球面上均匀分布n个点