首页 > 解决方案 > 如何计算无向图中节点的度数

问题描述

在无向图中找到其邻居度数之和最高的节点

我不解决这个问题可能使用威尔士鲍威尔算法

标签: graph-theory

解决方案


highest_sum = -1;
best_node = -1
Loop over nodes
  sum = 0;
  Loop over neighbours of the node
     count links connected to neighbour and add to sum
  IF sum > highest_sum
      highest_sum = sum
      best_node = this node
Print best_node

推荐阅读