Skip to content

Instantly share code, notes, and snippets.

@abitofalchemy
Last active December 28, 2015 10:47
Show Gist options
  • Save abitofalchemy/caedfb0c0cab5b39a64a to your computer and use it in GitHub Desktop.
Save abitofalchemy/caedfb0c0cab5b39a64a to your computer and use it in GitHub Desktop.
igraph to metis graph format: Metis sample (toy) graph
## edge list graph for the toy graph in page 11 of the Metis User's Manual
## Reference: https://lists.nongnu.org/archive/html/igraph-help/2012-11/msg00023.html
## The graph in edge list format below written to 'toy.el'
#0 2
#0 4
#0 1
#2 1
#2 3
#3 5
#3 6
#5 4
#5 6
cat("7 11",file="outfile.txt",sep="\n")
toyg <- read_graph("/Users/saguinag/Research/datasets/toynetwork/toy.el",format="edgelist")
al <- get.adjlist(toyg)
lapply(al, cat, "\n", file="outfile.txt", append=TRUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment