igraph-help
[Top][All Lists]
Advanced

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

## Re: [igraph] how to change attributes to a randomly selected nodes of a

 From: giorgio delzeri Subject: Re: [igraph] how to change attributes to a randomly selected nodes of a network in igraph Date: Fri, 12 May 2017 00:09:56 +0200

Ok, perfect!
Anyway, I think I was not so clear at describing wath the algorithm should must do.
there are only 4 compartment in total, A, B, C, D.
At the beginning of the algorithm, all nodes are in the compartment A.
The first sample turn 10 nodes from A to B, and this is the only part of the program that some of the nodes goes in B.
In the repaet until loop, some nodes turn from A to C, and some other from C to D.
However, you've been kind to devote your time to help me.
And, believe me, you helped me a lot!!

Il 11 mag 2017 23:16, "Chris Watson" <address@hidden> ha scritto:
1) The "i <- 3" is there because I assign the letters "A" and "B" already before the while loop; so then the following assignment will be "C" (i.e., the 3rd element/letter in the "cnames" vector)
2) The 0.15 was included because I thought you wanted to sample only 15% of the nodes. I included "round" to avoid any potential issues with decimals, which I think is already handled by "sample" anyway.
3) In the last 2 lines of code, I increment "i" so a new letter is chosen for the next "compartment". The line before that one is to assign that new compartment only if there is at least 1 sampled neighbor.
4) No, the "unique" line does not remove vertices. The function "adjacent_vertices" returns a list (since "x" can be more than 1 node), so I "unlist" it to make it a numeric vector. I call "unique" to remove any possible duplicates.

On Thu, May 11, 2017 at 4:00 PM, mario rossi wrote:
I was reading more carefully your code, Chris.
I noticed that there is "  unique(unlist(adjacent_vertices(g, x)))  ".
This fuction does not remove any vertices or edges, I am right?
Is only an assignement, or not?
Because in the algorithm I have not to change anything in the original network, I have only to "assign" attributes to the vertices...
As you can see, I am not a good igraph expert ;-)

_______________________________________________
igraph-help mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help

_______________________________________________
igraph-help mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help

reply via email to

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