Let's store the alias count in a lookup-table with row names:
> aliases=data.frame(count=c(1,2,2,3,2,1))
> row.names(aliases)=c("A","B","C","E","F","G")
This function expands a row of the data frame, and numbers the original thing with a zero:
expand.row=function(r){
e1=r[1];e2=r[2]
n1=aliases[e1,1];n2=aliases[e2,1]
expand.grid(
paste(e1,seq_len(n1)-1,sep=""),
paste(e2,seq_len(n2)-1,sep=""))
}
So that:
> expand.row(c("B","E"))
Var1 Var2
1 B0 E0
2 B1 E0
3 B0 E1
4 B1 E1
5 B0 E2
6 B1 E2
Then apply over the edge data frame, merge the bits into a single matrix:
> full = do.call(rbind,apply(as.matrix(d),1,expand.row))
> full
Var1 Var2
1 A0 E0
2 A0 E1
3 A0 E2
4 B0 F0
5 B1 F0
6 B0 F1
7 B1 F1
8 C0 G0
9 C1 G0
and there's your graph:
> g = graph.edgelist(as.matrix(full))
> plot(g)