ncol2pajek – Python

I’ve just written a very short Python script that will change an ncol graph file to Pajek format.

Some info on how to use it

The ncol File

The format of the ncol file will normally be like this

    "node_1" "node_2"
    "node_2" "node_3"

The node names should not have any spaces and they should be separated by a space.

The Pajek File

The output file will look like this

    *Vertices 3
    1 "node_1"
    2 "node_2"
    3 "node_3"
    1 2
    2 3

For not it will only do vertices and edges, no archs.

Using it

First, you need to make file executable using chmod.

Another option is to run it like this in the terminal

$ python [path]/[to_the]/

You may have to cd to the directory with the ncol file.

You will then be prompted to enter the name of the input and output file.

If all goes well, you will get something like this in the terminal

+ - - Loading File - - - +
|  Vertices: 3
|     Edges: 2
+ - - Pajek Complete - - +

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s