Я использую пакет networkDynamic, и у меня возникают проблемы с использованием назначенных мною весов (в качестве атрибутов ребер) для использования в качестве параметров расстояния.
У меня есть три момента времени, с 6 ребрами в первом моменте времени, относящемся к 3 узлам, 12 во втором, относящемся к 4 узлам, и 20 в третьем, относящемся к 5 узлам.Каждый вес назначается для каждого края.
Когда я рендерим временную сеть как фильм, мой код эффективен в назначении цветов узлам и размеру.Однако мои веса не работают в качестве параметров расстояния (которые должны вызывать близость на каждый увеличивающийся вес), как это определено выбранным параметром weight.dist = TRUE в функции compute.animation.Вместо точного представления близости по краям, я получаю узлы на одинаковом расстоянии друг от друга.
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')