线性阈值模型(LT模型)算法实现(Python实现)

盼盼    2020-03-01 09:18

该算法每个节点的阈值设为 0.5
用Buv表示节点u对其邻居节点的影响力:Buv=1/Lin;Lin(v)-------点v的入度。

2、LT传播模型算法实现
linear_threshold.py (LT传播模型算法)
Implement linear threshold models
社交网络影响力最大化 传播模型——线性阈值(LT)模型算法实现
def linear_threshold(G, seeds, steps=0):           #LT线性阈值算法
  """
  Parameters
  ----------
  G : networkx graph                     #所有节点构成的图
      The number of nodes.
  seeds: list of nodes                   #子节点集
      The seed nodes of the graph
  steps: int                             #激活节点的层数(深度),当steps<=0时,返回子节点集能激活的所有节点
      The number of steps to diffuse
      When steps <= 0, the model diffuses until no more nodes
      can be activated
  Return
  ------
  layer_i_nodes : list of list of activated nodes
    layer_i_nodes[0]: the seeds                  #子节点集
    layer_i_nodes[k]: the nodes activated at the kth diffusion step   #该子节点集激活的节点集
  Notes
  -----
  1. Each node is supposed to have an attribute "threshold".  If not, the
     default value is given (0.5).    #每个节点有一个阈值,这里默认阈值为:0.5
  2. Each edge is supposed to have an attribute "influence".  If not, the
     default value is given (1/in_degree)  #每个边有一个权重值,这里默认为:1/入度
  References
  ----------
  [1] GranovetterMark. Threshold models of collective behavior.
      The American journal of sociology, 1978.
  """
 
 
Last Modified: 2020-03-01 09:18
Views: 3.6K

[[total]] comments

Post your comment
  1. [[item.time]]
    [[item.user.username]] [[item.floor]]Floor
  2. Click to load more...
  3. Post your comment