Home Wiki Blog Forum GEXF.net

Gephi forums

Community support

how to import node label file?

Get help with your data

how to import node label file?

Postby wakeupbuddy » 13 Jan 2014 04:02

say I have a graph with 2000 nodes,and each node belongs to a class i, where i belongs to {1, 2, 3, 4}. So I have two files describing this: one file is AdjacentMatrix.csv (2000 columns and 2000 rows), and another NodeLabel.csv (2000 columns, each column is a class label for a node). I know how to import the adjacentMatrix.csv file, but have no idea how to import the class label file. I believe there should be some method to do this in Gephi, any clues?

PS: I want to visualize nodes with different colors according to its class label.
wakeupbuddy
 
Posts: 2
Joined: 13 Jan 2014 03:51
Location: United States

Re: how to import node label file?

Postby francis_flavin » 13 Jan 2014 22:17

You could just write a quick program in Python or some other language to create a one-off routine that does what you need.

Or, if you're not a programmer, you could use a spreadsheet program (like Excel) and a database program (like Access) to do this. I'm not entirely sure how your data is structured, but maybe this would work (presuming at your NodeLabel.csv has the label for the nth node in the nth column and that your nodes are numbered 1-n):

1.) Import AdjacentMatrix.csv into Gephi.
2.) Export the resultant graph's edge table as a .CSV called nodes.csv and node table as a .CSV called edges.csv.
3.) Using a spreadsheet, turn your 2000-column row of labels in NodeLabel.csv into a 2000-row column of labels.
4.) Using a spreadsheet, auto-number the rows so that the auto-number corresponds to the node ID and save the resultant spreadsheet as a .CSV called Nodes_w_Labels.csv (the idea is to have a column for node ID from the adjacency matrix AND a label column that contains the each node's proper label value).
5.) Import your node.csv into a SQL table; import your Nodes_w_Labels.csv into an SQL table; then execute a join that joins the nodes from nodes.csv with the Nodes_with_Labels table, using the node id as the join field.
6.) Save your joined table as a .CSV called "nodes_new.csv".
7.) Open a new Gephi project.
8.) In the data laboratory, import a nodes_new.csv as a your node table, then import your edges.csv as your edge table.

I left out a little detail, but this should give you the general idea about how to use the Data Lab to import and export nodes and edges as needed.

Good luck!


F




Good luck!
francis_flavin
 
Posts: 67
Joined: 21 Jan 2012 19:34
Location: Washington, DC, USA

Re: how to import node label file?

Postby wakeupbuddy » 14 Jan 2014 20:46

Thanks so much for your elaborate answer. It works. Acturally I didn't find the export button there when I posted the question. Then, a simple script will do it. Thanks a lot!


francis_flavin wrote:You could just write a quick program in Python or some other language to create a one-off routine that does what you need.

Or, if you're not a programmer, you could use a spreadsheet program (like Excel) and a database program (like Access) to do this. I'm not entirely sure how your data is structured, but maybe this would work (presuming at your NodeLabel.csv has the label for the nth node in the nth column and that your nodes are numbered 1-n):

1.) Import AdjacentMatrix.csv into Gephi.
2.) Export the resultant graph's edge table as a .CSV called nodes.csv and node table as a .CSV called edges.csv.
3.) Using a spreadsheet, turn your 2000-column row of labels in NodeLabel.csv into a 2000-row column of labels.
4.) Using a spreadsheet, auto-number the rows so that the auto-number corresponds to the node ID and save the resultant spreadsheet as a .CSV called Nodes_w_Labels.csv (the idea is to have a column for node ID from the adjacency matrix AND a label column that contains the each node's proper label value).
5.) Import your node.csv into a SQL table; import your Nodes_w_Labels.csv into an SQL table; then execute a join that joins the nodes from nodes.csv with the Nodes_with_Labels table, using the node id as the join field.
6.) Save your joined table as a .CSV called "nodes_new.csv".
7.) Open a new Gephi project.
8.) In the data laboratory, import a nodes_new.csv as a your node table, then import your edges.csv as your edge table.

I left out a little detail, but this should give you the general idea about how to use the Data Lab to import and export nodes and edges as needed.

Good luck!


F




Good luck!
wakeupbuddy
 
Posts: 2
Joined: 13 Jan 2014 03:51
Location: United States

Re: how to import node label file?

Postby francis_flavin » 14 Jan 2014 22:20

Glad to hear. Have fun with Gephi--it's an amazing tool!
francis_flavin
 
Posts: 67
Joined: 21 Jan 2012 19:34
Location: Washington, DC, USA


Return to Data Import / Export

Who is online

Users browsing this forum: No registered users and 0 guests

sports medicine portsmouth nh where to buy metronidazole