Subgraph of a graphSource:
subgraph() creates a subgraph of a graph, containing only the specified
vertices and all the edges among them.
subgraph(graph, vids) induced_subgraph( graph, vids, impl = c("auto", "copy_and_delete", "create_from_scratch") ) subgraph.edges(graph, eids, delete.vertices = TRUE)
The original graph.
Numeric vector, the vertices of the original graph which will form the subgraph.
Character scalar, to choose between two implementation of the subgraph calculation. ‘
copy_and_delete’ copies the graph first, and then deletes the vertices and edges that are not included in the result graph. ‘
create_from_scratch’ searches for all vertices and edges that must be kept and then uses them to create the graph from scratch. ‘
auto’ chooses between the two implementations automatically, using heuristics based on the size of the original and the result graph.
The edge ids of the edges that will be kept in the result graph.
Logical scalar, whether to remove vertices that do not have any adjacent edges in
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 them 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
subgraph() in the next major version of igraph.
subgraph() function currently does the same as
auto’ as the
impl argument), but this behaviour
is deprecated. In the next major version,
subgraph() will overtake the
Gabor Csardi email@example.com
g <- make_ring(10) g2 <- induced_subgraph(g, 1:7) g3 <- subgraph.edges(g, 1:5, 1:5)