The main advantage of this approach is that the pseudo code is written in the blog posts in plain encased in a pre statement, and the equations are also just vanilla latex in a pre statement. So if we wanted to think about the betweenness centrality of a graph we have the equation:
C_B(v)= \sum_{s \neq v \neq t \in V \atop s \neq t}\frac{\sigma_{st}(v)}{\sigma_{st}}
and in python for a given graph object we could use the excellent networkx package to calculate it like so
import networkx as nx #import networkx
G=nx.read_adjlist("graph.adjlist") # read in a graph graph
nodes_betweenness_centrality = nx.betweenness_centrality(G) # returns a dictionary
for node_betweenness_centrality in nodes_betweenness_centrality:
print node_betweenness_centrality
No comments:
Post a Comment