assign a (numeric real) value to vertex in network graph

别说谁变了你拦得住时间么 提交于 2019-12-11 18:54:45

问题


I wanted to assign or associate each node in the network plot with some real value (say some score) in R. Which need to be updated in iterations. Finally to plot the network graph with size of vertex according to its latest value (score).

Which property of a vertex I can use for this purpose and how? If it's not possible in igraph, is there any other way to achieve this purpose in R?

I'm new to R. Anybody please help me to sort out this problem.


回答1:


I create my gaph

graph2 <- read.table(text = '1 2 
1 3 
2 5 
3 4 
3 5 
4 5 
5 6 ')                    
par(mfrow =c(1,2)) 
graph2 <- graph.data.frame(graph2, 
           vertices = data.frame(symbols = 1:6,label   = 1:6),directed=FALSE)
plot(graph2,main='simple graph')

I change the weight property , here you can pput yor proper compting process

E(graph2)$weight <- seq(ecount(graph2))
graph.strength(graph2)

I modify property width, to visualize the weight effect

E(graph2)$width <-E(graph2)$weight                     
plot(graph2,main='weighted graph')



来源:https://stackoverflow.com/questions/13699931/assign-a-numeric-real-value-to-vertex-in-network-graph

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!