To open the files, you can use system, e.g.: l.files <- system('ls *.csv'', intern=T) file.objs <- lapply(l.files, read.table) Then you should be able to easily convert the items in file.objs to edgelists....
Here's one way: library(sna) library(network) source("modifieddatafromgist.R") plot.network(data, vertex.col="#FF000020", vertex.border="#FF000020", edge.col="#FFFFFF") First, I added a data <- to the gist so it could be sourced. Second, you need to ensure the proper library calls so the object classes are assigned correctly and the proper plot function will be used. Third, you...
You could split on the field of interest, compute all pairs (combn can be useful here), and then combine: get.pairs <- function(colname) { spl <- split(df, df[,colname]) do.call(rbind, lapply(spl, function(x) { if (nrow(x) == 1) { return(NULL) # No duplicates for this value } else { combs <- combn(nrow(x), 2)...
You could do it this way: # largest subgraph gs <- induced.subgraph(g, c$membership==order(-c$csize)[1]) # second largest subgraph gs <- induced.subgraph(g, c$membership==order(-c$csize)[2]) # etc... Here's a working example. library(igraph) g <- graph.full(5) %du% graph.full(4) %du% graph.full(3) set.seed(1) # for reproducible plots par(mar=c(0,0,0,0),mfrow=c(1,2)) plot(g) c <- clusters(g) gs <- induced.subgraph(g, c$membership==order(-c$csize)[1]) plot(gs)...
r,igraph,bipartite,sna,clique-problem
I managed to find a script for this in the Sisob workbench computeBicliques <- function(graph, k, l) { vMode1 <- c() if (!is.null(V(graph)$type)) { vMode1 <- which(!V(graph)$type) vMode1 <- intersect(vMode1, which(degree(graph) >= l)) } nb <- get.adjlist(graph) bicliques <- list() if (length(vMode1) >= k) { comb <- combn(vMode1, k) i...
python-2.7,igraph,networkx,bipartite,sna
There is an example in the documentation you reference at https://networkx.github.io/documentation/latest/reference/generated/networkx.algorithms.bipartite.projection.generic_weighted_projected_graph.html of how to do exactly this. It goes like this: import networkx as nx from networkx.algorithms import bipartite edges = [('A1','B1',3), ('A1','B2',7), ('A2','B1',2), ('A2','B2',4), ] B = nx.Graph() B.add_weighted_edges_from(edges) def my_weight(G, u, v, weight='weight'): w = 0 for nbr...
Here is the solution, provided by my colleague Benjamin Lind: all_files <- list.files("./edgelists") # reading file names datanames <- strsplit(all_files, split = "\\.") # removing file extension datanames <- sapply(datanames, "[[", 1) # getting names of egos # Helper function to load data fun1 <- function(x){ pathname <- paste("./edgelists/", x,...