I am trying to subset a igraph graph by an edge characteristics (like its label). In the reproducible example I have shamelessly stolen from another post with a little modif
I suggest you read ?V
and ?E
to see how to select edges and vertices. A quite compact and readable solution to your question is
subgraph.edges(g, E(g)[label=="FAM"])
subgraph.edges(g, E(g)[label=="BF"])
This removes the vertices as well, if they don't have an incident edge of the specified label. See ?subgraph.edges
for details.