我正在使用networkDynamic软件包,但在使用我创建的分配的权重(作为边缘属性)用作距离参数时遇到麻烦。
我有三个时间点,第一个时间点有6个边沿关联3个节点,第二个时间点有12个关联4个节点,第三个时间点的20个关联5个节点。每条边都有规定的重量。当我将时间网络渲染为电影时,我的代码可以高效地为节点分配颜色和大小。但是,我的权重不能用作由compute.animation函数中选定的weight.dist = TRUE参数定义的距离参数(每增加的权重会引起距离)。我没有按照边缘精确地表示紧密度,而是收到彼此等距的节点。
TemporalNetwork <- network.initialize(5)
add.edges.active(TemporalNetwork,tail=c(2:3),head=c(1),onset=1, terminus=2) #edgeset 1
add.edges.active(TemporalNetwork,tail=c(1),head=c(2:3),onset=1, terminus=2) #edgeset 1
add.edges.active(TemporalNetwork,tail=c(2),head=c(3),onset=1, terminus=2) #edgeset 1
add.edges.active(TemporalNetwork,tail=c(3),head=c(2),onset=1, terminus=2) #edgeset 1
add.edges.active(TemporalNetwork,tail=c(2:4),head=c(1),onset=2, terminus=3) #edgeset 2
add.edges.active(TemporalNetwork,tail=c(1),head=c(2:4),onset=2, terminus=3) #edgeset 2
add.edges.active(TemporalNetwork,tail=c(2),head=c(3,4),onset=2, terminus=3) #edgeset 2
add.edges.active(TemporalNetwork,tail=c(3),head=c(2,4),onset=2, terminus=3) #edgeset 2
add.edges.active(TemporalNetwork,tail=c(4),head=c(2,3),onset=2, terminus=3) #edgeset 2
add.edges.active(TemporalNetwork,tail= c(2:5),head=c(1),onset=3, terminus=3) #edgeset 3
add.edges.active(TemporalNetwork,tail= c(1),head=c(2:5),onset=3, terminus=3) #edgeset 3
add.edges.active(TemporalNetwork,tail= c(2),head=c(3,4,5),onset=3, terminus=3) #edgeset 3
add.edges.active(TemporalNetwork,tail= c(3),head=c(2,4,5),onset=3, terminus=3) #edgeset 3
add.edges.active(TemporalNetwork,tail= c(4),head=c(2,3,5),onset=3, terminus=3) #edgeset 3
add.edges.active(TemporalNetwork,tail= c(5),head=c(2,3,4),onset=3, terminus=3) #edgeset 3, 5 person equivalent network created
activate.edge.attribute(TemporalNetwork,'weight',0,onset=-Inf,terminus=Inf)
activate.edge.attribute(TemporalNetwork, 'weight',1.0833333, onset=1,terminus=2, e =1 )
activate.edge.attribute(TemporalNetwork, 'weight',0.9916667, onset=1,terminus=2, e =2 )
activate.edge.attribute(TemporalNetwork, 'weight',1.1166667, onset=1,terminus=2, e =3 )
activate.edge.attribute(TemporalNetwork, 'weight',0.8833333, onset=1,terminus=2, e =4 )
activate.edge.attribute(TemporalNetwork, 'weight',0.9166667, onset=1,terminus=2, e =5 )
activate.edge.attribute(TemporalNetwork, 'weight',1.0083333, onset=1,terminus=2, e =6 )
activate.edge.attribute(TemporalNetwork, 'weight',1.1333333, onset=2,terminus=3, e =7 )
activate.edge.attribute(TemporalNetwork, 'weight',1.0444444, onset=2,terminus=3, e =8 )
activate.edge.attribute(TemporalNetwork, 'weight',1.0444444, onset=2,terminus=3, e =9 )
activate.edge.attribute(TemporalNetwork, 'weight',1.0962963, onset=2,terminus=3, e =10 )
activate.edge.attribute(TemporalNetwork, 'weight',0.9777778, onset=2,terminus=3, e =11 )
activate.edge.attribute(TemporalNetwork, 'weight',0.9259259, onset=2,terminus=3, e =12 )
activate.edge.attribute(TemporalNetwork, 'weight',1.0148148, onset=2,terminus=3, e =13 )
activate.edge.attribute(TemporalNetwork, 'weight',0.8518519, onset=2,terminus=3, e =14 )
activate.edge.attribute(TemporalNetwork, 'weight',0.9629630, onset=2,terminus=3, e =15 )
activate.edge.attribute(TemporalNetwork, 'weight',0.9925926, onset=2,terminus=3, e =16 )
activate.edge.attribute(TemporalNetwork, 'weight',0.9037037, onset=2,terminus=3, e =17 )
activate.edge.attribute(TemporalNetwork, 'weight',1.0518519, onset=2,terminus=3, e =18)
activate.edge.attribute(TemporalNetwork, 'weight',1.2403846, onset=3,terminus=3, e =19 )
activate.edge.attribute(TemporalNetwork, 'weight',1.1634615, onset=3,terminus=3, e =20 )
activate.edge.attribute(TemporalNetwork, 'weight',1.1057692, onset=3,terminus=3, e =21 )
activate.edge.attribute(TemporalNetwork, 'weight',0.9807692, onset=3,terminus=3, e =22 )
activate.edge.attribute(TemporalNetwork, 'weight',1.2019231, onset=3,terminus=3, e =23 )
activate.edge.attribute(TemporalNetwork, 'weight',1.0576923, onset=3,terminus=3, e =24 )
activate.edge.attribute(TemporalNetwork, 'weight',1.0096154, onset=3,terminus=3, e =25 )
activate.edge.attribute(TemporalNetwork, 'weight',0.7307692, onset=3,terminus=3, e =26 )
activate.edge.attribute(TemporalNetwork, 'weight',1.0480769, onset=3,terminus=3, e =27 )
activate.edge.attribute(TemporalNetwork, 'weight',0.9230769, onset=3,terminus=3, e =28 )
activate.edge.attribute(TemporalNetwork, 'weight',0.7884615, onset=3,terminus=3, e =29 )
activate.edge.attribute(TemporalNetwork, 'weight',1.0096154, onset=3,terminus=3, e =30 )
activate.edge.attribute(TemporalNetwork, 'weight',0.9903846, onset=3,terminus=3, e =31 )
activate.edge.attribute(TemporalNetwork, 'weight',0.8365385, onset=3,terminus=3, e =32 )
activate.edge.attribute(TemporalNetwork, 'weight',1.0096154, onset=3,terminus=3, e =33 )
activate.edge.attribute(TemporalNetwork, 'weight',0.9711538, onset=3,terminus=3, e =34 )
activate.edge.attribute(TemporalNetwork, 'weight',0.9134615, onset=3,terminus=3, e =35 )
activate.edge.attribute(TemporalNetwork, 'weight',0.9903846, onset=3,terminus=3, e =36 )
activate.edge.attribute(TemporalNetwork, 'weight',0.9519231, onset=3,terminus=3, e =37 )
activate.edge.attribute(TemporalNetwork, 'weight',1.0769231, onset=3,terminus=3, e =38 )
activate.vertex.attribute(TemporalNetwork,'color','gray',onset=-Inf,terminus=Inf)
activate.vertex.attribute(TemporalNetwork,'color','blue',onset=1,terminus=Inf,v=1)
activate.vertex.attribute(TemporalNetwork,'color','red',onset=1,terminus=Inf,v=2)
activate.vertex.attribute(TemporalNetwork,'color','red',onset=1,terminus=Inf,v=3) activate.vertex.attribute(TemporalNetwork,'color','red',onset=1,terminus=Inf,v=4) activate.vertex.attribute(TemporalNetwork,'color','red',onset=1,terminus=Inf,v=5)
activate.vertex.attribute(TemporalNetwork,'mySize',2, onset=1,terminus=Inf)
compute.animation(
TemporalNetwork, weight.attr='weight',
weight.dist=TRUE,
slice.par = list(
start = 1,
end = 3,
interval = 1,
aggregate.dur = 1,
rule = "any"
)
)
render.d3movie(
TemporalNetwork,
displaylabels=TRUE, vertex.col='color',
verbose=FALSE,vertex.cex='mySize')