[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[igraph] Betweenness centralization in python snippet

From: Bernie Hogan
Subject: [igraph] Betweenness centralization in python snippet
Date: Thu, 24 Feb 2011 19:06:50 +0000

Hi all,

I'm not sure if this has been posted before (I'm filtering a lot of
mail these days), but based on the R recipe I've coded up betweenness
centralization in the python version of igraph. I tested the result
against the most recent Pajek, and its the same to as many digits as
Pajek displays (3 significant digits). Enjoy. Its clearly not robust -
so if you have a graph with less than 3 nodes or all isolates you
might get funny results.

def betweenness_centralization(G):
        vnum = G.vcount()
        denom = ((vnum-1)*(vnum-2))

        temparr = [2*i/denom for i in G.betweenness()]
        result = sum([max(temparr)-i for i in temparr])/(vnum-1)

        return result

G = Graph()
print betweenness_centralization(G)

Take care,
Dr Bernie Hogan
Research Fellow, Oxford Internet Institute
University of Oxford

reply via email to

[Prev in Thread] Current Thread [Next in Thread]