Converting 2-mode networks to 1-mode networks

April 4th: There is now a plugin for Gephi which will convert from multi-modal to 1-mode networks:

Say you’re interested in patterns of communication between individuals who are members of multiple organizations (like for instance historical societies), or artefact types across multiple sites. You might like to map the network between these individuals and those organizations to understand something of how information flows in that world, how social norms permeate, or ideologies of consumption or display map across space (as Tom Brughmans does here and I’ve done in other places).

You’ll need Gephi and Sci2. Download and install these. Registration is required for Sci2. Any work you do with these tools, if published, requires the citation of the tool. Don’t forget!

1. Make a list. Every time you encounter an individual mentioned as a member of a group, write it out. Two columns: Source, Target. Shawn Graham, Carleton University. You might include a third column called ‘weight’ which gives some measure of the importance of that connection.  Why ‘source’, why ‘target’? Because we’re going to import that list into Gephi, and that’s how Gephi requires the information. However, when we do any sort of metrics, we’ll always treat this network as undirected; that is, we’re making no claim to know anything about the direction of the relationship (in a directed network, Alice’s connection to Bob is different than Bob’s connection to Alice). Save that list as a .csv file. If you graphed this right now, you’d have a network where there are two kinds of nodes; hence a two-mode network. Network statistics envision a network where the modes are all of the same kind, which is why we’re doing this tutorial.

2. Import the list into Gephi. Open Gephi, start a new project. Click on the ‘data laboratory’ lab. Under ‘data table’ click on ‘edges’ (this is important; if you click on ‘nodes’, this doesn’t work correctly). Click on ‘import spreadsheet’. Select your csv file, and make sure that ‘as table:’ is set to ‘edges table’. Click next. Click Finish.

3. Go to File ->> export ->> graph file. Save as file type .net (Pajek).

4. Open Sci2; click on File >> Load and select your .net file.

5. Click ‘data preparation’ >> extract reference co-occurence (bibliographic coupling) network. (see also 5.b, below under ‘variations’)

6. Click ‘preprocessing’ >> networks >> delete isolates.  You’ve now collapsed your two-mode network into a one mode network where your nodes under ‘target’ are now all connected to each other. If your source, target was ‘site’, ‘ware’, you’ve got a one mode network where wares are connected to each other by virtue of being listed at the same site, ie, the linkage implies the site. (If you’ve done step 5.b, your one mode network would be sites connected to each other by virtue of sharing the same wares; the linkage implies the ware.)

7. At this point, go to file >> view and your notepad application will open, displaying a table where each node in your network has its own unique id, and ‘label*string’, which is your original label. You’ll Save this from notepad as a txt file. You might call it ‘ware to ware index’ (following our example in 6).

8.This is where things get a bit tricky. Click ‘File’ >> ‘save’. Select ‘pajek .net’ as your file type.(see also 8.b below, under ‘variations’)

9. You can then go back to Gephi, start a new project, click ‘open’ and select the .net file you just created. Your one mode network will load up. HOWEVER Gephi won’t recognize the original node lables anymore. This is why you need the index you saved in step 7, so that when you run metrics on this one mode network, you’ll know that ‘node 342 is actually Stamped Brick CIL XV.1 841.d (for instance). (see also 9.b below, under ‘variations’)


5.b In step 5, you created a one mode network based on your ‘target’ column. To create a one mode network based on your ‘source’ column, click ‘data preparation’ >> extract document co-citation network. Resume at step 6.

8.b If you want to preserve the node labels in Gephi, instead of step 8.a, click on Visualization >> Networks >> GUESS. This is a small visualization tool (that allows you to do some network metrics; but if your network is v. big, > 1000 nodes, this might not be a good idea). In GUESS, click File >> export graph. Give it a file name that makes sense, and don’t forget to type in the extension .gdf; otherwise it won’t export. Go to step 9b.

9.b Go to Gephi, start a new project, click on ‘open’, and select the .gdf file you just created. Your node labels will now be present in the graph, and so you don’t need that index file you created. Perhaps a bug: In my experiments, node labels don’t seem to appear in the ‘graph overview’ pane, when working with the gdf file. Your experience might be different. However, they do appear when I export an image of the network, under ‘preview’ >> export.

Fin. Let me know if/how your experience differs, or if these steps require clarification.

10 thoughts on “Converting 2-mode networks to 1-mode networks

  1. Dear Shawn,

    Thanks for posting such a clear and useful tutorial – I’m using Gephi to prepare images and make calculations for my upcoming paper at the Connected Past conference as well, and this little trick is going to save me a lot of time.

    A couple comments basted on my experience: I had much more success with importing the .gdf format from GUESS to Gephi (variation 8.b) (although I found the same “bug” you did – no node labels in Overview, just in Preview). When I attempted the more direct version of saving the one-mode network as a file and bringing it into Gephi, some of my nodes kept their original name labels, while others were assigned random label numbers. I don’t program, so the text file is relatively incomprehensible to me, and I’m not sure where/how the error happened.

    Do you know of any other straightforward overview tutorials such as this one for importing and manipulating data in Gephi? I’m particularly trying to figure out the time interval function, and am able to pick up bits and pieces from the Gephi forums, but it’s an uphill battle.


    1. Hi Kate,

      I’m glad it was useful – I owe a debt to Scott Weingart for this little trick! If you haven’t already, he might be a person to contact, as well as Elijah Meeks, with regard to the time interval problem. I’m not very familiar with that at all… currently, I’m having trouble with Gephi not opening saved projects of mine. Grrr!

  2. Hi,

    I followed this tutorial and succeedeed to get a one-mode network with this method.
    By chance, i found a way to save easily the nodes labels : you just need to give them a two part name (for example : «label name» or «labelname _») ! I don’t know exactly how it works, but it works! (of course, you may find that such label names do not look nice… but it’s simple).

    Thks for the tutorial,

    1. Hi Sebastien

      Thank you for the hint! That will certainly make things a bit clearer.


  3. Hi Shawn,

    Thank you for this! It all seems to work perfectly fine, except for the labels. I have created a csv file with two columns ‘Source’ and ‘Target’, but should I add something else? How do I create my ‘original label’? These do not even show up in the .txt file.
    And how does setp 8b work? When I click on GUESS, not much happens, whereas you just state immediately afterwards ‘In GUESS, click …’. Should a separate window open?



  4. Hmm …

    I may have been a bit too enthousiast. Further problems arose.
    When I save the file in Gephi, I get this message:

    Save… was selected.
    Warning: Attempting to convert data without validating the output since the validator failed with this problem:
    Problem converting data from text/nwb to .net during the necessary intermediate conversion from application/pajeknet to .net (See the log file for more details):
    Sorry, your file does not seem to comply with the Pajek .net File Format Specification.We are writing it out anyway.
    Please review the latest NET File Format Specification at, and update your file.The stated total number of vertices (10) does not match the calculated number of vertices (6)
    Saved: /Users/mark/Desktop/test network

    I may have missed that the first time.
    This probably explains the isolated dots in the graph.

    Anyway, without information about the nodes, it’s all guesswork. Hope you can tell me what I do wrong.



    1. Hmmm. I’ll play with it a bit more, and see what I can figure out. This whole approach was suggested to me by Scott Weingart so you might want to get in touch with him, for his perspective.

  5. Very useful post Shawn!

    I was really annoyed when I found out Cytoscape does not have a built-in feature for transforming 2-mode data to 1-mode, although I might not have searched through the plugins enough. I am glad to know Gephi is an alternative, because until now I had to go through Pajek. Most interestingly, I also found Cytoscape terribly unreliable for opening previously saved sessions. Strange that Gephi seems to have a similar problem.

    Looking forward to playing with Gephi more soon.
    Does anyone know if NodeXL allows for 2-mode/1-mode projections?


Comments are closed.