[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] problem with get_eid with neighbors
From: |
simone gabbriellini |
Subject: |
Re: [igraph] problem with get_eid with neighbors |
Date: |
Mon, 6 Apr 2009 21:51:17 +0200 |
Hi Tamas,
yes, I do agree with you.
I tryied another way using a dictionary like:
weight_dict = dict(zip(g.get_edgelist(), g.es["weight"]))
for node in self.agentset:
SWG_bandwagon = 0.0
L2_bandwagon = 0.0
in_nei = g.neighbors(node.index, type="in")
#
if len(in_nei) > 0:
for vicino in g.vs[in_nei]:
if vicino["color"] == "blue":
SWG_bandwagon += self.weight_dict[vicino.index,
node.index]
elif vicino["color"] == "red":
L2_bandwagon += self.weight_dict[vicino.index,
node.index]
but I have a key error if node is an isolated.
yes, checking explicitly if in_nei is empty makes things work!
sorry for the little bug discovery.
cheers,
simone
Il giorno 06/apr/09, alle ore 21:39, Tamas Nepusz ha scritto:
Hi Simone,
Apparently you have hit a bug in the Python interface :( The
exception happens when in_nei is empty; in this case, g.vs[in_nei]
is still the complete VertexSeq of the graph instead of an empty
VertexSeq. I'll try to commit a fix soon; in the meanwhile, check
explicitly if in_nei is empty:
for node in g.vs:
in_nei = g.neighbors(node.index, type="in")
if not in_nei: continue
for vicino in g.vs[in_nei]:
if vicino["color"] == "blue":
eid = g.get_eid(vicino.index, node.index, directed=True)
Best,
--
Tamas
_______________________________________________
igraph-help mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/igraph-help