Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

subGraph

Create a Subgraph


Description

Given a set of nodes and a graph this function creates and returns subgraph with only the supplied nodes and any edges between them.

Usage

subGraph(snodes, graph)

Arguments

snodes

A character vector of node labels.

graph

A graph object, it must inherit from the graph class.

Details

The returned subgraph is a copy of the graph. Implementations for Implementations for graphNEL, distGraph and clusterGraph.

Value

A graph of the same class as the graph argument but with only the supplied nodes.

Author(s)

R. Gentleman

See Also

Examples

set.seed(123)
        x <- rnorm(26)
        names(x) <- letters
        library(stats)
        d1 <- dist(x)
        g1 <- new("distGraph", Dist=d1)
        subGraph(letters[1:5], g1)

graph

graph: A package to handle graph data structures

v1.68.0
Artistic-2.0
Authors
R. Gentleman, Elizabeth Whalen, W. Huber, S. Falcon
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.