Q:

r igraph: remove edges from 2 groups of vectors

I am trying to network my collaborations through my publication network. I used igraph which is great for it. However, since I have edges from my vertex (the one representing me in the network) to all co-authors I end up with a pretty packed graph. I would like to remove edges from my vertex to some authors that are only related through another author. Basically authors where I was only co-authoring. Anyway, I have identified these vertices and I know my vertex. Now I can't find a way to remove edges that link this set of edges to me only.
More generally how do you remove edges from 2 groups of vectors, such as V(g)[a] and V(g)[b]?
thanks,
here is an example:
au1 <- c('deb', 'art', 'deb', 'seb', 'deb', 'deb', 'mar', 'mar', 'joy', 'deb')
au2 <- c('art', 'deb', 'soy', 'deb', 'joy', 'ani', 'deb', 'deb', 'nem', 'mar')
au3 <- c('mar', 'lio', 'mil', 'mar', 'ani', 'lul', 'nem', 'art', 'deb', 'tat')

tata <- data.frame(au1, au2, au3)
xaulist2 <- levels(factor(unlist(tata[,])))
xaulist <- levels(as.factor(xaulist2))
xaulist_att <- c(rep('prime', 2), 'main', 'second', 'second', rep('prime', 3), 'second', rep('prime', 3))
au_att <- data.frame(au_name=xaulist, level=xaulist_att)

# matrix list preparation
tutu <- matrix(NA, nrow=length(xaulist), ncol=dim(tata)[1]) # row are authors and col are papers
for (i in 1:length(xaulist))
{
  for (j in 1:dim(tata)[1])
  {
  ifelse('TRUE' %in% as.character(tata[j,]==xaulist[i]), tutu[i,j] <- 1,  tutu[i,j] <- 0)
  }
}
tutu[is.na(tutu)] <- 0

tutu[tutu>=1] <- 1 # change it to a Boolean matrix
termMatrix <- tutu %*% t(tutu)

# build a graph from the above matrix
g <- graph.adjacency(termMatrix, weighted=T, mode = 'undirected')
g <- simplify(g) # remove loops
V(g)$label <- xaulist # set labels of vertices
V(g)$degree <- degree(g) # set degrees of vertices
V(g)[xaulist_att=='second']$color <- 'red'
V(g)[xaulist_att=='main']$color <- 'blue'
set.seed(112) # set seed to make the layout reproducible
plot(g)

So the question is how do you remove edges from authors that have attribute 'second' to the one that has attribute 'main', that is from the red ones to the blue one?
Thanks again,

A:

Here is one way to do it, it think it is very readable:
g2 <- delete.edges(g, E(g)[ V(g)[xaulist_att == 'second'] %--% 
                            V(g)[xaulist_att == 'main'  ] ])

## plot the results
coords <- layout.auto(g)
layout(rbind(1:2))
plot(g, layout=coords, main="g")
plot(g2, layout=coords, main="g2")

See ?iterators for the details.

