[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[igraph] Re: how to increment reciprocity
From: |
Simone Gabbriellini |
Subject: |
[igraph] Re: how to increment reciprocity |
Date: |
Wed, 28 Jan 2009 10:36:50 +0100 |
sorry, I made a mistake in the code... here it is:
for node in g.vs:
nei_vertex = g.neighbors(node, type="in")
if (g.vs[node]["experience"] >= 20) and
(g.vs[node]["experience"] <= 60):
selectedNodeId = self.pickupEQ(nei_vertex)
self.do_link(node, selectedNodeId)
def pickupEQ(self, nei_vertex):
selectedNodeId = random.sample(nei_vertex, 1)[0]
return selectedNodeId
def do_link(self, node, selectedNodeId):
try:
eid = g.get_eid(node, selectedNodeId)
except:
max_edge_id = g.ecount()
g.add_edges((node, selectedNodeId))
g.es[max_edge_id]["color"] = "orange"
g.es[max_edge_id]["weight"] = 1
else:
g.es[eid]["weight"] += 1
could there be better ways to accomplish my task?
best regards,
simone