igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Sorting a graph or assigning attributes based on vertex nam


From: Alan Labouseur
Subject: Re: [igraph] Sorting a graph or assigning attributes based on vertex nam
Date: Fri, 2 Nov 2012 12:56:42 -0400

Thanks, Gabor. That's both more simple and more elegant than my code. I shall 
begin using it at once.

Very cool.

-Alan



> Hi,
> 
> you can actually assign the bucket attributes all at once, and this is
> relatively fast, the graph is only copied once.
> 
> ## Some example data
> g <- degree.sequence.game(sample(2:10), method="simple")
> buckets <- letters[seq_len(vcount(g))]
> 
> ## Assign buckets
> V(g)$bucket[order(degree(g), decreasing=TRUE)] <- buckets
> 
> ## Check result
> V(g)$bucket
> 
> ## This gives the same solution as your function:
> V(foo(g, buckets))$bucket
> 
> Gabor



reply via email to

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