Hi Lorenzo, > For a simple illustration of what I have in mind, have a look at > > https://dl.dropboxusercontent.com/u/5685598/network-sketch.pdf
You can either generate the edge list "by hand", or construct the chains one by one and then fuse them together at the end. The first approach is probably easier. If you have 3 chains and the length of the chains are i, j and k, then the edge list will look like this: first chain: (1, 2), (2, 3), ..., (i, i+1), second chain: (1, i+2), (i+2, i+3), ... (i+j, i+j+1), third chain: (1, i+j+2), (i+j+2, i+j+3), ... (i+j+k, i+j+k+1) If you look at the second column of the above edge list, it is exactly 2:(i+j+k+1). The first column is "almost" 1:(i+j+k) but you have to update the 1st, (i+1)th, (i+j+1)th entries to 1 in the first column. So you can do this: lengths <- c(i, j, k) first.col <- 1:sum(lengths) second.col <- first.col + 1 items.to.update <- c(0, cumsum(lengths)) + 1 first.col[items.to.update] <- 1 edgelist <- as.vector(rbind(first.col, second.col)) g <- graph(edgelist) -- T. _______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
