igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Do Bipartite Projections edges inherit the original graph w


From: Tamas Nepusz
Subject: Re: [igraph] Do Bipartite Projections edges inherit the original graph weights?
Date: Tue, 2 Dec 2014 10:04:56 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

Hello,

Unfortunately the bipartite projection routine in igraph is not able to
calculate what you want out-of-the-box, although I think it would be
a straightforward generalization of the current implementation (since you can
recover the current implementation by assuming that each edge involved in
a projection has weight=1). I think it would be a nice addition so if you feel
like doing so, please file a feature request at
https://github.com/igraph/igraph/issues. We cannot promise anything re the
implementation yet but at least it keeps the idea on our radar.

In the meanwhile, I'm afraid that you'll have to re-implement the projection
yourself in Python. You can probably iterate over all "artifact" vertices and
then for each vertex, iterate over each possible pair of "commenter" neighbors
of the current "artifact" vertex and add the edge weights leading to these
neighbors. Something like:


from itertools import combinations, izip

artifacts = g.vs.select(type=False)
weights = g.es["weight"]
projection_weights = defaultdict(int)
for v in artifacts:
    neighbors = g.neighbors(v)
    for u, w in combinations(neighbors, 2):
            eid1, eid2 = g.get_eids(path=(u, v, w))
                projection_weights[u, w] += weights[eid1] + weights[eid2]

edges, projection_weights = izip(projection_weights.iteritems())
projection = Graph(edges, weight=projection_weights)
projection.simplify(combine_edges={"weight": "sum"})


The above is untested but shows the general idea. Hope it helps a bit. The
simplification in the last step is needed because projection_weights will
contain separate entries for (u, w) and (w, u) depending on the order in which
they turned up in the combinations() iterator and we need to collapse these
duplicate edges into a single one.

All the best,
T.

On 12/01, Carlos Andrade wrote:
> Dear all,
> 
> I have a large (30k+ nodes and edges) directed bipartite weighted graph
> where one mode are people and the other are artifacts (each interaction
> generates a comment).  I am trying to assess how connected the communities
> are by means of artifacts. Amount of interaction of artifacts are annotated
> within the edges of the original graph 'g'.
> 
> Once I generate the projections 'g1' (commenters) and 'g2' (artifacts), I
> would like to observe the generated edges among users being the sum of the
> weights of the interactions on the original graph, as this is a reflection
> of how many times those two users commented on the same post on 'g'.
> 
> I am using igraph on python, and I noticed the method has the attribute
> 'multiplicity', however it seemed to me it accounts for summing up the
> relation of a given user interacting with different artifacts, and ignoring
> 'g' weights. Did I misunderstand?
> 
> The graph on ipython is considered 'directed', I am unsure if being
> 'directed' or 'indirected' impacts over the transfer of weights as well.
> 
> Thank you for your attention,
> 
> Carlos A.

> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help


-- 
T.



reply via email to

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