igraph-help
[Top][All Lists]
Advanced

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

[igraph] How to make read.graph and maximal.clique faster in R?


From: Mona Jalal
Subject: [igraph] How to make read.graph and maximal.clique faster in R?
Date: Sun, 16 Feb 2014 22:18:39 -0600

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.



reply via email to

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