[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[igraph] how to increment reciprocity
From: |
Simone Gabbriellini |
Subject: |
[igraph] how to increment reciprocity |
Date: |
Wed, 28 Jan 2009 10:34:10 +0100 |
Dear List,
I am trying to write a routine that adds edges to a graph in order to
increment the reciprocity of the graph...
my code, but it doesn't work well, is something like:
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
# costruisci un link con quel nodo, oppure aggiungi 1 al peso del link esistente
def do_link(self, node, selectedNodeId):
try:
eid = self.SNA.network.get_eid(node, selectedNodeId)
except:
max_edge_id = self.SNA.network.ecount()
self.SNA.network.add_edges((node, selectedNodeId))
self.SNA.network.es[max_edge_id]["color"] = "orange"
self.SNA.network.es[max_edge_id]["weight"] = 1
else:
self.SNA.network.es[eid]["weight"] += 1
could there be better ways to accomplish my task?
best regards,
simone
- [igraph] how to increment reciprocity,
Simone Gabbriellini <=