Degree distribution
The degree of a node is the number of connections (links) with other nodes. In the case of directed graphs, each node has two degrees: the out degree and the in degree. In the undirected graph, the relationship is mutual, so we just have a single degree for each node. In the following code snippet we get the source node and target node references from the file links.csv
. Then we create a single list to merge the two lists (target and source). Finally, we get a dictionary (dic
) of how many times each node appears in the list and we plot the result in a bar chart using matplotlib
.
The file links.csv
will look as follows:
edgedef>node1 VARCHAR,node2 VARCHAR 23917067,35702006 23917067,629395837 23917067,747343482 23917067,755605075 23917067,1186286815 . . .
The complete code snippet looks as follows:
import numpy as np import matplotlib.pyplot as plt links = np.genfromtxt("links.csv", dtype=str, delimiter=',', ...