title: R igraph iterate through edge list and get attributes
body: <p>I'm trying to write an efficient way to print out the edges between two groups. The problem is I can't seem to figure out how to get any information from the edge when I am iterating through the edges below, thanks!</p>
  
  <pre><code>myG &lt;- erdos.renyi.game(100, 10/100)
  
  E(myG)$weight &lt;- runif(ecount(myG))
  
  V(myG)$group &lt;- ifelse(runif(100)&gt;0.5,1,2)
  V(myG)$origIndex &lt;- seq(1,vcount(myG))
  V(myG)$label &lt;- paste(sample(LETTERS,vcount(myG), replace=TRUE),     sample(LETTERS,vcount(myG), replace=TRUE),sample(LETTERS,vcount(myG), replace=TRUE),sep="-")
  
  indices1 &lt;- which(V(myG)$group == 1)
  indices2 &lt;- which(V(myG)$group == 2)
  edgeIDsOfAllBetween &lt;- myG[[indices1, indices2, edges=TRUE]]
  
  uniqueEdgeIDs &lt;- unique(unlist(edgeIDsOfAllBetween))
  edgeList &lt;- E(myG)[uniqueEdgeIDs] 
  rows &lt;- length(edgeList)
  
  if(rows&gt;0){
    for(r in 1:rows){
  
      edgeIndex &lt;- edgeList[r]  #how to get the original index??
      weight &lt;- get.edge.attribute(myG, "weight", index= edgeIndex)
      n1Index &lt;- edgeList[r,1] #how to get the index of the first vertex????
      n2Index &lt;- edgeList[r,2] #how to get the index of the second vertex????
      n1IndexisIN1 &lt;- n1Index %in% indices1
  
      n1 &lt;- get.vertex.attribute(myG,"label",index = n1Index)
      n2 &lt;- get.vertex.attribute(myG,"label",index = n2Index)
  
      if(n1IndexisIN1){
        n1 &lt;- paste("group1_",n1,sep="")
        n2 &lt;- paste("group2_",n2,sep="")
      }else{
        n1 &lt;- paste("group2_",n1,sep="")
        n2 &lt;- paste("group1_",n2,sep="")
      }
  
      print(paste(n1, " ", n2, "  weight: ", weight, sep=""))
    }
  }
  </code></pre>
  
  <p>Update:
  Is there a faster way than converting to a data.frame?:</p>
  
  <pre><code>MyEdges &lt;- as.data.frame(get.edgelist(myG))
  MyEdges$origindex &lt;- seq(1, ecount(myG))
  MyEdges &lt;- subset(MyEdges, origindex %in% uniqueEdgeIDs )
  
  rows &lt;- nrow(MyEdges)
  </code></pre>