igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Leverage centrality implementation in igraph


From: Alex Upton
Subject: Re: [igraph] Leverage centrality implementation in igraph
Date: Thu, 26 Jul 2012 12:37:09 +0100

Hi all,


Thank you for your help and suggestions. I am using igraph in R, and have tried 
translating the code for leverage centrality kindly suggested by Tamás from 
Python to R. However, I am getting errors with this, so if it is not too much 
trouble, could someone suggest an R implementation of the following code:


def leverage_centrality(graph):
    k = graph.degree()
    n = graph.vcount()
    result = []
    for i in xrange(n):
        ki = k[i]
        if ki == 0:
            result.append(0.0)
        else:
            result.append(sum((ki-k[j])/(ki+k[j]) for j in graph.neighbors(i)) 
/ ki)
    return result


Thank you for your feedback as well Bernie, I have noticed that there are a 
number of centrality metrics out there that seem to be well-suited to only type 
of application. 

Kind regards,

Alex


Hi Alex, 

As Bernie has mentioned, the measure itself is relatively simple to calculate 
and it does not have a significant uptake in the scientific community yet, so I 
don't think that a low-level C implementation of the measure will be added to 
igraph any time soon (unless someone is willing to provide a patch). It is 
relatively easy to calculate using either the R or the Python interface; a 
quick (untested) Python implementation is as follows:

def leverage_centrality(graph):
    k = graph.degree()
    n = graph.vcount()
    result = []
    for i in xrange(n):
        ki = k[i]
        if ki == 0:
            result.append(0.0)
        else:
            result.append(sum((ki-k[j])/(ki+k[j]) for j in graph.neighbors(i)) 
/ ki)
    return result

-- 
T.

--------------------------------------------------------------------------------------------
Alex Upton, BEng, MRes, PG Cert Business Administration

PhD Researcher Biomedical Informatics, Signals and Systems 
School of Electronic, Electrical and Computer Engineering, 
College of Engineering and Physical Sciences, University of Birmingham
Edgbaston, Birmingham, B15 2TT, United Kingdom

Fax: +44 121 4144291 (school general office)
Email: address@hidden

Personal Web: http://postgrad.eee.bham.ac.uk/uptona/
--------------------------------------------------------------------------------------------


reply via email to

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