Categories
Uncategorized

Colouring Clusters – Python

The Graph file The Python bit The Graph

Categories
data science

Colouring Nodes According to Centrality – R

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 […]

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

Setting Node Attributes in Igraph – Python

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

Categories
Uncategorized

Draw Quick Graph with igraph – Python

You start with a pajek file, called something_pajek.net, then you run this code. You should end up with something like this.

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 […]