I have a directed graph that ends to point '12'. I have calculated all the nodes attribute values based on the out-degree distribution. Now I am not able to assign the node's attribute value to its edges as weights. The help in this regard would be highly appreciated..
Please see the graph attached here.
These are my sample codes.
nodes <- read.csv("test_nodes1.csv", header=T, as.is=T)
links <- read.csv("test_edge1.csv", header=T, as.is=T)
links <- links[order(links$from, links$to),]
G <- graph_from_data_frame(d=links, vertices=nodes$id, directed=T)
V(G)$dist <- 1
for (i in V(G)$name) {
out_deg_i <- degree(G,i, mode = "out")
if (out_deg_i >1){
V(G)[i]$dist = V(G)[i]$dist/out_deg_i
}
else{
V(G)[i]$dist =1
}
}
V(G)$name
V(G)$dist
[1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13"
[1] 1.0 0.5 1.0 1.0 1.0 1.0 1.0 1.0 1.0 0.5 1.0 1.0 1.0

