Ok, I know it’s summer, most of you are taking a well-deserved break, and there are a lot more fun things to do than dealing with networks. For those of you nodding fervently in agreement: shame on you! A plague on all your houses! Except Gryffindor, I’m in that one. And no, I didn’t just pick that one because Harry Potter‘s in it. I got sorted, the proper way. At Pottermore.com. You should really try it, it’s so much fun!
Anywho, I recently got a cry for help concerning Gephi, and I thought: there may be more lost souls out there, struggling to get this right. So here’s the pickle: can you visualize different types of edges in Gephi?
Not all your relationships are the same: you don’t hang with yo brudda of da same mudda in the same way as you do with your bros, and you don’t treat them the same as your hos. Like chicks before dicks, ya know? This was already true 100, 200, 500, even 1,000 years ago. People had family (through descent as well as marriage: sometimes it’s useful to distinguish between the two), friends, colleagues, superiors, inferiors, extraterrestrial acquaintances, … . Or you might want to look at different kinds of interactions between individuals: who writes/ lends money/ sells a slave/ … to whom, whatever, you name it!
Although you’ll probably end up filtering your networks according to specific types of relations anyway, it’s not a bad idea to start out with the complete picture, to capture and appreciate the complexity of a person or a group of people’s network. These different types of relationships are not independent of one another, they all influence other social circles and aspects of a person’s life.
So instead of going through the ridiculously time-consuming process of creating separate edgelists and graphs for each of those relations, you can start out with one giant (or not so giant, if you’re working with a limited data set. No biggie!) network that incorporates all types of edges.
This is a very very very simplistic network of six people that I, in a moment of unsurpassable inspiration, have named A, B, C, D, E and F. Some of them are related, some are friends, and some work together. To assign different colors to these different types of relationships, all you have to do is create a new column in your edgelist in Gephi (or in your original csv file) and code these relations.
You can do this by assigning a code word to each of them (in this example, I’ve used the very enigmatic designations ‘friend’, ‘family’ and ‘business’), or, if the relation you want to describe is too complex to capture in one word, you can number them: 1 = X writes to Y, 2 = X greets Y, 3 = X gave Y a wedgy, … (but make sure to keep a list somewhere: it would be a shame if you’ve gone through all the effort of documenting 10 different types of relations, only to have forgotten that 8 stands for ‘decapitated his sister’s Barbie doll’…).
Then when you go to the ‘overview’ window and to the ‘partition’ tab on the left, go to ‘edges’, click on the refresh button, and your new column should appear in the drop-down menu. You can then assign different colors to each type of relationship!
If you then want to filter your graph by types of relationships, use the, you got it, ‘filters’ tab on the right side of the screen.
Drop down the ‘attributes’ folder, and then the ‘partition’ folder. Your extra column should appear there, and then you can drag it to the ‘queries’ pane and play around with it. If you click on the drop-down arrow to the left of ‘partition (type)’, the option ‘parameters’ will appear and if you click on that you can choose which of the relationships you would like to include in /exclude from your graph.
So here I’ve only chosen family and friend relations, so the business ones are left out, resulting in an isolate node (D) in the middle of the graph (this can be filtered out as well if you don’t want those drifting about: in the ’statistics’ tab, run the average degree algorithm, then go back to ‘filters < attributes < range’ and drag the ‘degree’ filter and place it as a subfilter under the first one. Click on its parameters again and then slide the bar at the bottom of the screen until the minimum degree on the left reads ‘1’, and the nodes that have lost their edges should be hidden from view).
Another Gephi tip: you can export these filtered subsets of your network to a separate workspace, that way you don’t have to start over your statistics or filtering each time you want to switch between the whole network and just a specific relationship. To do this, click on the middle button right below the ‘filters’ tab.
Gephi then jumps to the new workspace automatically (you can access your different workspaces at the bottom right corner of the screen. The first one is always numbered ‘0’), and in this network only those nodes and edges that you filtered are included (also in the data laboratory). When saving your document, Gephi saves all workspaces in the same file, so when you shut it down and open it again later, you still have your original network, plus all the subsets in the separate workspaces. Pretty neat, huh?