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
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help

Reply via email to