subgraph creates a subgraph of a graph, containing
only the specified vertices and all the edges among them.induced.subgraph(graph, vids, impl=c("auto", "copy_and_delete",
"create_from_scratch"))
subgraph.edges(graph, eids, delete.vertices = TRUE)
subgraph(graph, v)copy_and_deleteeids.induced.subgraph calculates the induced subgraph of a set of
vertices in a graph. This means that exactly the specified vertices
and all the edges between then will be kept in the result graph. subgraph.edges calculates the subgraph of a graph. For this
function one can specify the vertices and edges to keep. This
function will be renamed to subgraph in the next major
version of igraph.
The subgraph function does the same as induced.graph
currently (assuming autoimpl
argument), but it is deprecated and will be removed in the next
major version of igraph.
g <- graph.ring(10)
g2 <- induced.subgraph(g, 1:7)
g3 <- subgraph.edges(g, 1:5, 1:5)Run the code above in your browser using DataLab