library("network")
library("networkD3")
library("igraph")
df1 <- read.table(text = "src target
cllient1 cllient2
cllient1 cllient4
cllient1 cllient6
cllient2 cllient3
cllient4 cllient1
cllient4 cllient3
cllient5 cllient6
cllient6 cllient5", header = TRUE)
lesmis <- graph_from_data_frame(df1)
wc <- cluster_walktrap(lesmis)
members <- membership(wc)
lesmis <- igraph_to_networkD3(lesmis, group = members)
D3_network_LM <- networkD3::forceNetwork(Links = lesmis$links, Nodes = lesmis$nodes,
Source = 'source', Target = 'target',
NodeID = 'name', Group = 'group',
opacity = 1,zoom = TRUE)
networkD3::saveNetwork(D3_network_LM, "test.html", selfcontained = TRUE)
So close we got a network. After that we create new graph by merging several vertices into one. In our case those vertices that belong to particular community.
lesmis <- graph_from_data_frame(df1)
cg <- contract.vertices(lesmis, members)
ay <- as_long_data_frame(cg)
View(ay)
we got new graph,
from to
1 2
We may built again new graph where now these nodes are the groups, but their names are 1 and 2, my question is how we can add clients names to this new graph. So that, when hovering , we may get not only the number of the node(group) but also the list of client that belongs to this new node(group).