How to increase the distance between the clusters using igraph?

I have nodes and edges information, and trying to make a network plot with that. The nodes information has 1552 rows with information like below:

The nodes file is here - nodes information file

And the edges information is with four columns with 1203576 entries:

The edges file is here - edges information file

Using the above nodes and edges data I used below code to make a network plot.

library(igraph)
net <- graph_from_data_frame(d=edges, vertices=nodes, directed=F)

plot(net, edge.arrow.size=.4,vertex.label=NA, 
     vertex.color=as.numeric(factor(nodes$type)))

Grouped.net = net
E(Grouped.net)$weight = 1

colnames(nodes)[4] <- "Clusters"

## Add edges with high weight between all nodes in the same group
for(Clus in unique(nodes$Clusters)) {
  GroupV = which(nodes$Clusters == Clus)
  Grouped.net = add_edges(Grouped.net, combn(GroupV, 2), attr=list(weight=80))
} 


## Now create a layout based on G_Grouped
set.seed(567)
LO = layout_with_fr(Grouped.net)

# Generate colors based on media type:
colrs <- c("gray50", "yellow", "tomato")
V(net)$color <- colrs[V(net)$type_num]


plot(net, layout=LO, edge.arrow.size=.1,vertex.label=NA, verte.size=1)
legend(x=-1.5, y=-1.1, c("typeA","typeB", "typeC"), pch=21,
       col="#777777", pt.bg=colrs, pt.cex=2, cex=.8, bty="n", ncol=1)

The plot I got looks like below:

enter image description here

In the above figure there are 5 clusters. And it looks like all the clusters are very close.

  1. How do I increase the space between the clusters? How to move them far?

  2. How to name the clusters in the Figure?

  3. How to bring the nodes typeC to the top?

Any help is appreciated. thanq.

I don’t understand exactly what you write here. In the figure I see many more nodes than 6. Perhaps first make sure you construct the Grouped.net correctly by using contract (and simplify) as explained in your other question: How to make a plot that groups different type of nodes by cluster? - #4 by vtraag.

Hi Traag,

I made some changes to the post. If you see the image now there are 5 clusters clearly. I created this network with the data I posted above in the links [both nodes and edges data]. I’m able to create a network, 1) but only problem is I don’t know how to move the clusters far, because the clusters are very close in the Figure above. 2) And naming the Clusters in the Figure. 3) How to bring the typeC nodes to the top (because they are very less in number and were below the grey color typeA nodes)

It looks bit confusing to me in using contract and simplify. If you don’t mind could you please show me how to use contract and simplify on the above data. thanq

I tried increasing the weight to 500 Grouped.net = add_edges(Grouped.net, combn(GroupV, 2), attr=list(weight=500)) and now the Figure looks like this:

Screen Shot 2020-09-26 at 13.46.33

The are too many edges and I see lot of grey color for the edges. The typeC are not visible here. Is there a way to bring them to the top? and how to name the clusters?

I want the figure to be looked something like this

Any help is appreciated. thanq