Remove the edges that connect rel==0
and rel==1
vertices, and then just calculate the degree of the vertices.
el <- get.edgelist(g)
el[] <- V(g)$rel[el]
g2 <- delete.edges(g, which(el[,1] == el[,2]))
degree(g2)
# [1] 3 2 4 1 3 2 2 4 4 3
If the attribute is not numeric (EDIT)
el <- get.edgelist(g)
mode(el) <- "character"
el[] <- V(g)$rel[el]
g2 <- delete.edges(g, which(el[,1] == el[,2]))
degree(g2)
# [1] 3 2 4 1 3 2 2 4 4 3