Posted on: 13 April 2009 in latex, centrality, blog, equation

I've decided to use syntaxhiligher2 to do syntax hi-lighting and a call to Yourequations.com for rendering latex on the blog. Bot Cyborg has a good description of how to get this to work on blogger.

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

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

## Comments