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

removeNode

removeNode


Description

A function to remove a node from a graph. All edges to and from the node are also removed.

Usage

removeNode(node, object)

Arguments

node

The label of the node to be removed.

object

The graph to remove the node from.

Details

The specified node is removed from the graph as are all edges to and from that node. A new instance of the same class as object with the specified node(s) is returned.

Note, node can be a vector of labels, in which case all nodes are removed.

This is similar to subGraph.

Value

A new instance of a graph of the same class as object but with all specified nodes removed.

Author(s)

R. Gentleman

See Also

Examples

V <- LETTERS[1:4]
  edL2 <- vector("list", length=4)
  names(edL2) <- V
  for(i in 1:4)
    edL2[[i]] <- list(edges=c(2,1,2,1)[i], weights=sqrt(i))
  gR2 <- graphNEL(nodes=V, edgeL=edL2, edgemode="directed")
  gX <- removeNode("C", gR2)

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.