Categories
Uncategorized

Pajek to database – Python

This is how you read a pajek file and move it all to a database. This consists of three files, all in the same directory sample.txt – the pajek sample file pajek_rw.py – module that reads the pajek file g2db.py – which moves all the data to a database sample.txt This is what the pajek […]

Categories
Uncategorized

ncol2pajek – Python

I’ve just written a very short Python script that will change an ncol graph file to Pajek format. https://github.com/jose187/ncol2pajek Some info on how to use it The ncol File The format of the ncol file will normally be like this The node names should not have any spaces and they should be separated by a […]

Categories
Uncategorized

Coordinates for a sphere layout – Python

We want to create the coordinates for 40 nodes using the sphere layout in igraph, which will then be used on a Pajek file. Creating the Coordinates Load the igraph module and create an empty graph, then add the 40 nodes. Good, so we have a graph with 40 nodes, and no edges. Now we […]

Categories
Uncategorized

From ncol to Pajek – Python

Here is a small script that will change an ncol file to a pajek one. The ncol file The ncol looks something like this where each column is divided by a single space, and the last column is the edge color. The Pajek file The final pajek file will be formated like this The Python […]

Categories
data science

Connections Between Networks – R

This graph shows how connected each network is within a system. Each node represents a network, and each edges represents a person overlapping them. The darker the edge color, the more people spanning across the two communities. This post explains the method in a bit more detail. This graph was made in R, with the […]

Categories
Uncategorized

Graph Degree Centrality iGraph – Pythom

This Python code will read a Pajek graph and calculate its degree centrality using this formula … To test the result I will be using example 17 from Freeman’s (1978) Centrality in Social Networks: Conceptual Clarification. Freeman’s calculation for this example is 0.42. The graph is written in a file named graph17.net, which reads: This […]