[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] how to select transitive node in neighborhood
From: |
Simone Gabbriellini |
Subject: |
Re: [igraph] how to select transitive node in neighborhood |
Date: |
Tue, 10 Mar 2009 10:29:00 +0100 |
Dear Tamas,
that's exactly what I wanted! I wrote a much more complicated code...
so inelegant and probably inefficient!!!
thank you very much,
simone
2009/3/9 Tamas Nepusz <address@hidden>:
> 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.
>
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>