[Top][All Lists]

[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: Chris Watson
Subject: Re: [igraph] how to change attributes to a randomly selected nodes of a network in igraph
Date: Thu, 11 May 2017 16:16:09 -0500

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 <address@hidden> 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

reply via email to

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