3

I was wondering if gephi supports importing a cluster file that has the community assignment of each node in a graph on a separate line (similar to the Pajek .clu format)? I am looking for a way to color the nodes belonging to the same community. In igraph (for R), I can import this file and set the vertex color attributes based on it. Was wondering if gephi had a similar feature?

I saw this answer here from over 5 years ago saying that it wasn't possible, was wondering if that had changed now?

Thanks!

muddy
  • 187
  • 2
  • 8

1 Answers1

1

The .clu file contains one line per node with the cluster number at least the example I see here. Gephi cannot import it directly but you can trick it to obtain the same result. Here are the steps I propose:

  1. Import your .net file with Gephi
  2. Go to Data Laboratory and sort your nodes according to the Id column, by clicking on the column name
  3. Create a new column called Cluster by pressing Add column the bottom of the screen. The default String type will do
  4. Click Export table, select only the fields Id and Cluster, and export the file somewhere
  5. Open the CSV file with e.g. Excel or LibreOffice
  6. Open your .clu file with a text editor, even Notepad will do
  7. Copy all the numbers in the file and paste them in the Cluster column of your CSV. Save your CSV
  8. Import the CSV back into Gephi, by clicking Import Spreadsheet and press ok through the next steps.

At the end you should see your Cluster values having the same values as in the .clu file!

Make sure that the same field delimiter is used throughout in steps 4. and 8. I would suggest to use ; as Excel directly understands it.

You are welcome to report back if you are still having problems

Community
  • 1
  • 1
Yannis P.
  • 2,745
  • 1
  • 24
  • 39
  • Thank you! Apologies about the delay in my response. I was able to import the cluster values successfully. Is there any way to color the nodes based on the cluster column? Sorry if that is trivial question, this is my first few attempts at using Gephi for visualization. – muddy Mar 12 '16 at 17:18
  • Yes it is, check my answer [here](http://stackoverflow.com/questions/35215145/gephi-0-9-0-partition-panel/35225455#35225455)! I hope that the cluster numbers are recognized as strings which then makes them categorical attributes. Do you have Gephi 0.9.1? – Yannis P. Mar 12 '16 at 18:24
  • Yes, I'm using 0.9.1. I was able to color the nodes by following the steps provided in the link you gave. Thank you for your help! :) – muddy Mar 12 '16 at 19:54
  • Excellent! Could you accept the answer as correct to help others who read SO? – Yannis P. Mar 12 '16 at 20:02
  • For sure, I actually did accept your answer when I commented earlier. Does it not show at your end? – muddy Mar 12 '16 at 21:16
  • Now it does. Good luck with your project – Yannis P. Mar 13 '16 at 00:01