Skip to content

Instantly share code, notes, and snippets.

@gweissman
Created April 17, 2012 02:26
Show Gist options
  • Save gweissman/2403004 to your computer and use it in GitHub Desktop.
Save gweissman/2403004 to your computer and use it in GitHub Desktop.
sample calculating mixing matrix and assortativity coefficient with igraph
# sample calculating mixing matrix and assortativity coefficient with igraph
require(igraph)
set.seed(12)
# create a random graph
g <- random.graph.game(1000,0.15)
# assign some characteristics
V(g)$color <- c('red','white','blue','orange','green')
# calculate the mixing matrix
m <- mixmat(g,'color')
# now calculate the assortativity coefficient
assortcoeff(m)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment