[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: [igraph] Network with a Bifurcation

**From**: |
Tamas Nepusz |

**Subject**: |
Re: [igraph] Network with a Bifurcation |

**Date**: |
Fri, 13 Mar 2015 11:59:01 +0100 |

**User-agent**: |
Mutt/1.5.23 (2014-03-12) |

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.