The Graph file The Python bit The Graph
This R function will draw a graph and then colour the nodes according to centrality. There are three colours, red for high centrality, purple for medium centrality, and blue for low centrality. Node centrality was calculated using the betweenness( ) function in the igraph R library. It was then normalised manually so that we are […]
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 […]
Creating a simple graph python terminal It should look something like this. Set the coordinates The coordinates can be set using lists. Change Node Size and Colour The final product should be this
You start with a pajek file, called something_pajek.net, then you run this code. You should end up with something like this.
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 […]