VisNetwork from IGraph - Can't Implement Cluster Colors to Vertices

后端 未结 1 611
情歌与酒
情歌与酒 2021-01-24 12:00

I am starting to use the package called visNetworkand I feel like it has a ton of potential for User-Interface use in the future.

There are few things that

相关标签:
1条回答
  • 2021-01-24 12:34

    Here is a solution. Just build the plain graph with igraph and then make the cosmetic changes using visNetwork:

    Code:

     i96e = graph.adjacency(g96e, mode = "undirected", weighted = TRUE,    diag=FALSE)
     fc<-fastgreedy.community(i96e, merges=TRUE, modularity=TRUE,
                         membership=TRUE, weights=E(i96e)$weight)
     library (visNetwork)
     dummy <- toVisNetworkData(i96e)
     my.edges <- dummy$edges
     my.nodes <- dummy$nodes
     my.nodes$groups <- fc$membership
     my.nodes$color.background <- c("red", "blue", "green" ,"yellow")[my.nodes$groups]
     my.nodes$color.border <- c("red", "blue", "green" ,"yellow")[my.nodes$groups]
     my.nodes$size = 5
     my.edges$color <- "black"
     visNetwork(my.nodes, my.edges)%>%
     visIgraphLayout()
    
    0 讨论(0)
提交回复
热议问题