[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] How to make read.graph and maximal.clique faster in R?
From: |
Mona Jalal |
Subject: |
Re: [igraph] How to make read.graph and maximal.clique faster in R? |
Date: |
Sun, 16 Feb 2014 22:22:07 -0600 |
My code didn't come here properly. Here's the code:
http://stackoverflow.com/questions/21818697/dealing-with-large-matrix-graphs-in-r-how-to-make-the-operations-in-igraph-fast
Sorry about that,
Mona.
On 02/16/14, Mona Jalal wrote:
> Hi,
>
> Is there anyway to make the following code work faster? It really takes till
> forever and it gets stuck in finding the edges that belong to a triangle in a
> large graph.
>
>
> I am reading "cit-Patents.txt" from the following link:
> https://snap.stanford.edu/data/cit-Patents.txt.gz
>
> library(igraph) #xlist<-read.table("cit-Patents.txt")
> read.graph_xlist<-read.graph("cit-Patents.txt",
> format="edgelist",directed=TRUE) #xlist <- graph.data.frame(xlist) ij <-
> get.edgelist(read.graph_xlist) library(Matrix) m <- sparseMatrix( i =
> rep(seq(nrow(ij)), each=2), j = as.vector(t(ij)), x = 1 ) cl <-
> maximal.cliques(read.graph_xlist) cl <- cl[ sapply(cl, length) > 2 ]
> print(cl) # Function to test if an edge is part of a triangle triangle <-
> function(e) { any( sapply( cl, function(u) all( e %in% u ) ) ) }
> print(triangle) # Only keep those edges kl <- ij[ apply(ij, 1, triangle), ]
> print(kl) # Same code as before m <- sparseMatrix( i = rep(seq(nrow(kl)),
> each=2), j = as.vector(t(kl)), x = 1 )
>
>
>
>
> Thanks,
>
> Mona.
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help