deeenes

order vertices by degree

Jun 2nd, 2013
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.17 KB | None | 0 0
  1. d <- degree(G)
  2. p <- seq(1:length(V(G)))
  3. i <- 1
  4.  
  5. for(dd in rev(levels(as.factor(d)))){
  6.     for(pp in V(G)[d==dd]){
  7.         p[pp] <- i
  8.         i <- i+1
  9.     }
  10. }
  11.  
  12. G <- permute.vertices(G,p)
Advertisement
Add Comment
Please, Sign In to add comment