igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] How to Get Datasets


From: Gábor Csárdi
Subject: Re: [igraph] How to Get Datasets
Date: Thu, 26 Mar 2009 17:33:46 +0100

Hmmmm, interesting, you can easily load this into R:

--------------------------------------------
library(igraph)

data <- 
readLines("http://research.cs.queensu.ca/~daver/235/C1352963146/E20070302133910/Media/LondonUnderground.txt";)

edges <- grep("^[(]", data)
empty <- grep("^[\t ]*$", data)
nodes <- seq_along(data)[-c(empty,edges)]

data <- gsub("[(|)| ]", "", data)

df.nodes <- data.frame(data[nodes])
df.edges <- as.data.frame(matrix(unlist(strsplit(data[edges], ",")),
                                       nc=3, byrow=TRUE))

colnames(df.edges) <- c("from", "to", "line")

metro <- graph.data.frame(df.edges, vertices=df.nodes, dir=FALSE)
-------------------------------

But then you run clusters() for checking and see that there are three
isolate vertices in the network, so most likely there are some
spelling mistakes in the file, perhaps in lines 19, 109 and 151, but
maybe not. FYI.

Best,
Gabor

On Thu, Mar 26, 2009 at 4:58 PM, Tamas Nepusz <address@hidden> wrote:
>> As for the London underground, you can probably type in the data in a
>> couple of hours, I cannot see any possibility to download it in a
>> graph form.
>
> Here's a London Underground data file, you'll have to parse it, but I guess
> it's just a matter of some sed and awk scripts to transform it into a proper
> edge list or something:
>
> http://research.cs.queensu.ca/~daver/235/C1352963146/E20070302133910/Media/LondonUnderground.txt
>
> --
> T.
>
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>



-- 
Gabor Csardi <address@hidden>     UNIL DGM




reply via email to

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