python - 在图形结构中传播评级

标签 python algorithm graph neural-network graph-algorithm

我有以下问题:

Consider a weighted direct graph. 
Each node has a rating and the weighted edges represents 
      the "influence" of a node on its neighbors.
When a node rating change, the neighbors will see their own rating modified (positively or negatively)

如何在一个节点上传播一个新的评级?
我认为这应该是一个标准算法,但是哪一个?

这是一个一般性问题,但实际上我使用的是 Python ;)

谢谢

[编辑]
评级是一个介于 0 到 1 之间的简单浮点值:[0.0,1.0]
肯定存在收敛问题:我只想将传播限制为几次迭代...

最佳答案

有一个简单的标准方法如下:

let G=(V,E) be the graph
let w:E->R be a weight function such that w(e) = weight of edge e
let A be an array such that A[v] = rating(v)
let n be the required number of iterations

for i from 1 to n (inclusive) do:
    for each vertex v in V:
          A'[v] = calculateNewRating(v,A,w) #use the array A for the old values and w
    A <- A' #assign A with the new values which are stored in A'
return A

但是,在某些情况下,您可能会根据图形的特征​​以及如何重新计算每个节点的评分,使用更好的算法。例如:

  1. 假设 E 中的每个 (u,v) rating'(v) = sum(rating(u) * w(u,v)),您会得到 Page Rank 的变体,如果图是强连通的(Perron-Forbenius theorem),它保证收敛到主特征向量,因此计算最终值很简单。
  2. 假设 rating'(v) = max{ rating(u) |对于 E} 中的每个 (u,v),那么它也可以保证收敛并且可以使用强连通分量线性求解。 This thread讨论这个案例。

关于python - 在图形结构中传播评级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13875640/

相关文章:

Python 模拟 call_args_list 解包元组以对参数进行断言

python - 将单个 python 可执行文件添加到多台计算机的 Windows 系统路径中?

javascript - 代码战斗 : Correct solution but system does not accept it

algorithm - 单位长度闭区间

algorithm - 编辑问题

jquery - 整数 x 轴 Jquery flot 图

c - 在图上搜索顶点的最佳和最简单算法?

python - Python 引用中的 "DEDENT"是什么?

python - 带箭头的 matplotlib 3d 线图无法接受 kwargs

r - R 中多种图形类型的对齐(最好在 ggplot2 或 lattice 中)