Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to plot the same graph in iGraph two times with two different colorings

Tags:

I use iGraph in combination with python.
I calculated communities on my graph with two different algorithms. To compare them visually I want to plot the graph with a specific layout, i.e. in my case fruchterman–reingold and color the vertices according to the first community structure.
Then I want to change all colors to the second community structure, but preserve the position of all vertices.
Alternatively I could draw the graph, color my vertices according to the first community structure and give each vertex a color-coat according to the second one.
Is one of these ideas doable with iGraph?

like image 732
Xenthor Avatar asked May 20 '16 11:05

Xenthor


1 Answers

Set seed for the same value for two plots. The algorithm is random, but after setting seed for the same value, it will output the same result two times. I tried it with R and igraph and it works, so I believe it works also for Python.

It will be something like that:

random.seed(123)
plot1
random.seed(123)
plot2
like image 83
bartoszukm Avatar answered Sep 28 '22 01:09

bartoszukm