I would say,
f = lambda x: (1-x)**(k_n-2)
alpha_ij = 1 - (k_n-1)*integrate.quad(f, 0, pij)[0]
On Jun 20, 12:14 pm, Brian Keegan <
bkee...@northwestern.edu> wrote:
> Wasn't an approximation, probably me just doing it wrong. Using your
> approach, should the code look like this?
>
> def extract_backbone(g, alpha):
> backbone_graph = nx.Graph()
> for node in g:
> k_n = len(g[node])
> if k_n > 1:
> sum_w = sum( g[node][neighbor]['weight'] for neighbor in g[node] )
> for neighbor in g[node]:
> edgeWeight = g[node][neighbor]['weight']
> pij = float(edgeWeight)/sum_w
> f = lambda p,k: (1-p)**(k-2)
> x = 1-(k_n-1)*integrate.quad(f,0.,pij,args=(k_n))[0] #
> equation 2
> if x < alpha:
> backbone_graph.add_edge( node,neighbor, weight =
> edgeWeight)
> return backbone_graph
>
> On Wed, Jun 20, 2012 at 11:07 AM, Brian Keegan <
bkee...@northwestern.edu>wrote:
>
>
>
>
>
>
>
>
>
> > I'm not sure if this is exactly right (i.e., translating math to code),
> > but it appears to accomplish the intended result. Thanks to Michael Conover
> > at Indiana for help with it.
>
> > Does this correspond to what you are using Qian?
>
> > def extract_backbone(g, alpha):
> > backbone_graph = nx.Graph()
> > for node in g:
> > k_n = len(g[node])
> > if k_n > 1:
> > sum_w = sum( g[node][neighbor]['weight'] for neighbor in g[node]
> > )
> > for neighbor in g[node]:
> > edgeWeight = g[node][neighbor]['weight']
> > pij = float(edgeWeight)/sum_w
> > if (1-pij)**(k_n-2) < alpha: # equation 2
> > backbone_graph.add_edge( node,neighbor, weight =
> > edgeWeight)
> > return backbone_graph
>
> > On Wed, Jun 20, 2012 at 10:05 AM, Qian <
zhangqian.r...@gmail.com> wrote:
>
> >> i have a python version for directed weighted networks (without using
> >> networkx), and a matlab version for undirected ones.
>
> >> On Tuesday, June 5, 2012 3:19:47 PM UTC-4, Brian Keegan wrote:
>
> >>> Has anyone implemented or know of a Pythonic implementation of the
> >>> edge-weight filter proposed in [1] within NetworkX?
>
> >>> Best,
>
> >>> Brian
>
> >>> [1] Serrano, Boguna, & Vespignani (2009)
http://www.pnas.org/**
> >>> content/106/16/6483.abstract<
http://www.pnas.org/content/106/16/6483.abstract>