考虑这个简单的例子
#python bros
pd.DataFrame({'id' : [1,1,2,3],
'time_in' : [0,30,1,5],
'time_out' : [2,35,3,6]})
Out[66]:
id time_in time_out
0 1 0 2
1 1 30 35
2 2 1 3
3 3 5 6
#R bros
dplyr::data_frame(id = c(1,1,2,3),
time_in = c(0,30,1,5),
time_out = c(2,35,3,6))
在这里,解释很简单。你知道吗
个体1
在时间0
和时间2
之间停留在一个给定的地方。个体2
停留在时间1
和时间3
之间。因此,个体2
遇到了个体1
,并在我的网络中连接到它。你知道吗
也就是说,我的网络的节点是id
,如果两个节点的[time_in, time_out]
间隔重叠,那么它们之间就有一条边。你知道吗
有没有一种有效的方法从这个输入数据中生成adjacency matrix
或edge list
,这样我就可以在networkx
这样的网络包中使用它?我真正的数据集远不止这些。你知道吗
谢谢!你知道吗
我认为这是一个可能的解决办法,使邻接矩阵。其思想是将每个时隙相互比较,然后通过顶点组减少比较。你知道吗
输出:
相关问题 更多 >
编程相关推荐