node operations {bnlearn} | R Documentation

## Manipulate nodes in a graph

### Description

Add, remove and rename nodes in a graph.

### Usage

    # add and remove nodes.
    add.node(x, node)
    remove.node(x, node)

    # re-label nodes.
    rename.nodes(x, names)
    ## S4 replacement method for signature 'bn'
    nodes(object) <- value
    ## S4 replacement method for signature 'bn.fit'
    nodes(object) <- value

### Arguments

`x` | an object of class `bn` for `add.node()` and `remove.node()`; an object of class `bn` or `bn.fit` for `rename.nodes()`.
`object` | an object of class `bn` or `bn.fit`.
`node` | a character string, the label of a node.
`value, names` | a vector of character strings, the new set of labels that wll be used as to rename the nodes.

### Details

`add.node()` adds a new (isolated) node to an existing `bn` object.

`remove.node()` removes a node from a `bn` object.

`rename.nodes()` replaces the node labels with new ones, relabelling the whole node set. The assignment method for `nodes()` is an alias of `rename.nodes()`.

### Value

`add.node()`, `remove.node()` and `rename.nodes()` return an updated `bn` object.

### Author(s)

Marco Scutari

### Examples

    dag = random.graph(LETTERS[1:5])
    add.node(dag, "Z")
    remove.node(dag, "A")

    nodes(dag)
    nodes(dag) = LETTERS[6:10]
    nodes(dag)

[Package bnlearn version 4.7.1 Index]