Clustering nodes based on their color

Computing metrics, community detection and data handling
Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
akjoshi
Posts:8
Joined:07 Jun 2012 13:48
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
Clustering nodes based on their color

Post by akjoshi » 07 Jun 2012 13:52

Hi,
I am new to Gephi, so I am not able to find how to cluster nodes based on their color.
Like red colored nodes would be in one cluster and blue ones in other. Can you tell me how to do that?

Also suppose a node belongs to two clusters, so in the graph the position of the node should be in between the cluster ( or at centriod of both the clusters ). Can you also tell me how to do that?

Thanks,
Akshay

User avatar
seinecle
Gephi Community Support
Posts:546
Joined:08 Feb 2010 16:55
Location:Lyon, France
Contact:

Re: Clustering nodes based on their color

Post by seinecle » 08 Jun 2012 10:55

Hi,

For the color issue:
Think the other way round. Gephi finds the clusters, and then put a different color on each cluster. The question is, how does Geph find the cluster in the first place?
In the statistics panel -> Modularity and run it.
Then go the partition panel, and run a partition based on the modularity attribute you just created. This blog posts shows how to do it:
http://blog.ouseful.info/2011/07/07/vis ... s-network/

You should now see each cluster in different color.

But maybe I misunderstood your question: you already have clusters (defined by yourself, not the clusters found by Gephi with the modularity function), and you want to color them. Then:
- each node should have an attribute where the cluster it belongs to is indicated. In practice, in the data laboratory window, look at the columns: each column is an attribute. One of these columns should represent a cluster, with the values on each row corresponding to which cluster the node belongs to.
- back to the overview window. There, select the partition panel. Select the attribute which corresponds to your cluster. Run the partition. That's it, each node will have a color corresponding to the cluster it belongs to.

Finally, for overlapping clusters: Gephi does not have an algo which finds overlapping coomunities and I don't have an idea of how they could be represented with Gephi. If this is absolutely necessary to your research question, you can try another software, called CFinder (http://www.cfinder.org/). Its capabilities are much less powerful than Gephi but is is specially made for the detection and visual representation of overlapping communities.

Best,

Clement

akjoshi
Posts:8
Joined:07 Jun 2012 13:48
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: Clustering nodes based on their color

Post by akjoshi » 08 Jun 2012 11:44

Hi Clement,
Apologies for not explaining my question clearly and thanks for giving me an idea.

Actually, I have coloured the nodes in the .gexf file itself because I want to cluster the graph depending upon the colour of node.
So, when I open the .gexf file in Gephi, the graph apears haywired. I want the graph to orient into clusters of nodes having the same colour ( as I have defined it myself ).

Also about the approach you suggested about adding one additional column which you can view in Data Laboratory. Can you tell me how to add that column in .gexf file itself as I directly import it in Gephi.


Thanks,
Akshay
Last edited by akjoshi on 08 Jun 2012 13:11, edited 1 time in total.

akjoshi
Posts:8
Joined:07 Jun 2012 13:48
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: Clustering nodes based on their color

Post by akjoshi » 08 Jun 2012 11:46

I am attaching a sample gexf file of mine.
That new coloumn must be added in each node right?

Thanks,
Akshay
Attachments
SMJ_Episode2.gexf
Sample Gexf file
(25.9KiB)Downloaded 648 times

akjoshi
Posts:8
Joined:07 Jun 2012 13:48
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: Clustering nodes based on their color

Post by akjoshi » 08 Jun 2012 12:04

Hi Clement,
I figured out how to add an attribute , I have attached my .gexf file.
But it is only colouring my nodes.
What I want to do is these nodes should now automatically be reaaranged themselves to form clusters of the same color.

How to do that?

Thanks,
Akshay
Attachments
SMJ_Episode2.gexf
Sample .gexf file
(31.07KiB)Downloaded 526 times

User avatar
seinecle
Gephi Community Support
Posts:546
Joined:08 Feb 2010 16:55
Location:Lyon, France
Contact:

Re: Clustering nodes based on their color

Post by seinecle » 11 Jun 2012 11:49

Hi Akshay,

Sorry for the late reply.

I am afraid there is no layout algorithm which would do that. In Gephi, and in other network viz software as well, layouts have traditionally been developed to spatialize the network according to its topology - that is, according to the patterns made by nodes and edges. Node attributes do not come into consideration here. That's quite frustrating I know. Research is done in this domain (http://nrl.northumbria.ac.uk/833/) and there might be software implementing this kind of layout, but I can't remember any at the moment.

In the case of geospatial data (imagine that nodes represent cities, for example), Alexis Jacomy has developed the "geolayout plugin" which places nodes according to their longitude and latitude. (https://gephi.org/plugins/geolayout/). Longitude and latitude can simply be stored in the gexf file as regular node attributes. In your case, you could download and install this plugin then hack this layout to spatialize nodes according to their attributes, but this demands some effort:
=> you would code your attribute as a longitude and latitude. For example, a high value of your attribute would be coded as a high latitude ("up north in the northern hemisphere"), and a low value would be "down south in the southern hemisphere". Use longitude to spread the nodes on the horizontal axis ("west east axis"), so that they don't all overlap on the same vertical line.

Good luck,

Clement

Frieder
Posts:28
Joined:05 May 2012 21:16
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: Clustering nodes based on their color

Post by Frieder » 15 Jun 2012 08:59

seinecle wrote:Hi,

For the color issue:
Think the other way round. Gephi finds the clusters, and then put a different color on each cluster. The question is, how does Geph find the cluster in the first place?
In the statistics panel -> Modularity and run it.
Then go the partition panel, and run a partition based on the modularity attribute you just created. This blog posts shows how to do it:
http://blog.ouseful.info/2011/07/07/vis ... s-network/

You should now see each cluster in different color.

But maybe I misunderstood your question: you already have clusters (defined by yourself, not the clusters found by Gephi with the modularity function), and you want to color them. Then:
- each node should have an attribute where the cluster it belongs to is indicated. In practice, in the data laboratory window, look at the columns: each column is an attribute. One of these columns should represent a cluster, with the values on each row corresponding to which cluster the node belongs to.
- back to the overview window. There, select the partition panel. Select the attribute which corresponds to your cluster. Run the partition. That's it, each node will have a color corresponding to the cluster it belongs to.

Finally, for overlapping clusters: Gephi does not have an algo which finds overlapping coomunities and I don't have an idea of how they could be represented with Gephi. If this is absolutely necessary to your research question, you can try another software, called CFinder (http://www.cfinder.org/). Its capabilities are much less powerful than Gephi but is is specially made for the detection and visual representation of overlapping communities.

Best,

Clement
Seems to me the original poster has the same problem I have. What is needed from my perspective is a quick visual clue as to who it is that is part of the cluster. Lets say we have a SNA of the network of two (big) departments in university. I want dep 1 to be red and dep 2 to be green so that AFTER I run modularity I can see if they cluster according to department or if they according to some other attribute (which I would have to find out)
Also in another post it said that if I filter according to an attribute and the select "all nodes" an editing panel would appear in which I could "batch color" all selected nodes - exactly what I need. Beu when I tried it no editing windo appeared...

thanks in advance

Freddy

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable