igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] how to select transitive node in neighborhood


From: Tamas Nepusz
Subject: Re: [igraph] how to select transitive node in neighborhood
Date: Mon, 9 Mar 2009 14:40:45 +0000

Dear Simone,

node_B = random.sample(g.vs[in_nei].select(attribute1_ne = 0,
attribute2_le = 20), 1)[0].index
Sidenote: you could use random.choice here as you are sampling only one node.

What should I do to find a node B that has the same properties as
above, but that also is transitive with a node C in the neighborhood
of node A?
What I'd do:

node_A = ...
candidates = g.vs[in_nei].select(attribute1_ne = 0, attribute2_le = 20)
filtered_candidates = []
for node_B in candidates:
  for node_C in g.vs[in_nei]:
    if g.are_connected(node_B.index, node_C.index):
      filtered_candidates.append(node_B)
node_B = random.choice(filtered_candidates).index

I hope that's what you wanted.

--
T.





reply via email to

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