~mvngu/igraph/doc

« back to all changes in this revision

Viewing changes to nexus/download/hep-th.R

  • Committer: Gabor Csardi
  • Date: 2012-02-21 04:05:12 UTC
  • mfrom: (2640.1.1 0.6-main)
  • Revision ID: csardi.gabor@gmail.com-20120221040512-n2orudv0a2cdw3g1
Merged Nexus branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
url <- "http://www-personal.umich.edu/~mejn/netdata/hep-th.zip"
 
3
tmp <- tempdir()
 
4
dest <- paste(sep="", tmp, "/", "hep-th.zip")
 
5
 
 
6
download.file(url, dest)
 
7
system(paste("cd ", tmp, "; unzip hep-th.zip"))
 
8
 
 
9
txt <- readLines(paste(sep="", tmp, "/hep-th.txt"))
 
10
gml <- paste(sep="", tmp, "/hep-th.gml")
 
11
 
 
12
library(igraph)
 
13
g <- read.graph(gml, format="gml")
 
14
 
 
15
g <- remove.vertex.attribute(g, "id")
 
16
 
 
17
V(g)$name <- V(g)$label
 
18
g <- remove.vertex.attribute(g, "label")
 
19
 
 
20
E(g)$weight <- E(g)$value
 
21
g <- remove.edge.attribute(g, "value")
 
22
 
 
23
g$name <- "High energy physics collaborations"
 
24
g$Author <- "Mark E. J. Newman"
 
25
g$Citation <- "M. E. J. Newman, The structure of scientific collaboration networks, Proc. Natl. Acad. Sci. USA 98, 404-409 (2001)."
 
26
g$URL <- "http://www-personal.umich.edu/~mejn/netdata/"
 
27
g$Description <- paste(paste(collapse="\n", txt), sep="", "\n")
 
28
 
 
29
hepcollab <- g
 
30
save(hepcollab, file="/tmp/hepcollab.Rdata")