测量网络中的社区间交互性

时间:2018-08-10 10:30:36

标签: networkx graph-theory modularity gephi

问题

我有一个定向网络,其中的节点是唯一用户,边缘表示转发。我已将其导入Gephi,并使用其模块化度量进行社区检测,现在为每个用户都有一个社区标签。

集群运行良好,但是现在我想知道每个组中的用户与社区外的用户进行交互的程度。是否有图论为此问题设计的统计数据(最好在Gephi或Networkx中实现)?

我尝试了以下详细的我自己的粗略衡量标准,但是如果有的话,我宁愿选择更好的衡量标准。

我的(粗略)方法

到目前为止,我已经通过在Pandas中生成一个显示以下内容的表格来做到这一点……

interaction_df (pd.DateFrame)
    source_user  target user  source_class  target_class  inter_group_interaction
    a            b            5             5             False
    a            c            5             8             True             
    b            c            5             8             True
    c            d            8             10            True
    d            e            10            10            False
    e            a            10            5             True

...然后....

interaction_counts = interaction_df.groupby('source_class').sum()['inter_group_interaction']
source_class
5     2.0
8     1.0
10    1.0
Name: inter_group_interaction, dtype: float64

...为我提供了每个社区inter_group_interaction发生的class个实例的计数。如果将其除以每个组中唯一身份用户的数量,我得到的度量值inter_group_interaction ...

group_counts = interaction_df.drop_duplicates('source_user').source_class.value_counts()
5     2
10    2
8     1
Name: source_class, dtype: int64

interaction_counts / group_counts
5     1.0
8     1.0
10    0.5
dtype: float64

表明社区10中的用户与社区之外的用户进行交互的程度是其他两个社区的一半。

0 个答案:

没有答案