These functions allow users to add and delete nodes:

  • add_nodes() adds an additional number of nodes to network data.

  • delete_nodes() deletes nodes from network data.

  • filter_nodes() subsets nodes based on some nodal attribute-related logical statement.

While add_*()/delete_*() functions operate similarly as comparable {igraph} functions, filter_*(), works like a {tidyverse} or {dplyr}-style function.

add_nodes(.data, nodes, attribute = NULL)

delete_nodes(.data, nodes)

filter_nodes(.data, ..., .by = NULL)

Arguments

.data

An object of a {manynet}-consistent class:

  • matrix (adjacency or incidence) from {base} R

  • edgelist, a data frame from {base} R or tibble from {tibble}

  • igraph, from the {igraph} package

  • network, from the {network} package

  • tbl_graph, from the {tidygraph} package

nodes

The number of nodes to be added.

attribute

A named list to be added as tie or node attributes.

...

Additional parameters and arguments passed on internally.

.by

An attribute name to join objects by. By default, NULL.

Value

A data object of the same class as the function was given.

Details

Not all functions have methods available for all object classes. Below are the currently implemented S3 methods:

igraphnetworktbl_graph
add_nodes111
delete_nodes111

Examples

  other <- create_filled(4) |> mutate(name = c("A", "B", "C", "D"))
  add_nodes(other, 4, list(name = c("Matthew", "Mark", "Luke", "Tim")))
#> 
#> ── # Filled network ────────────────────────────────────────────────────────────
#> # A labelled, undirected network of 8 nodes and 6 ties
#> 
#> ── Nodes 
#> # A tibble: 8 × 1
#>   name   
#>   <chr>  
#> 1 A      
#> 2 B      
#> 3 C      
#> 4 D      
#> 5 Matthew
#> 6 Mark   
#> # ℹ 2 more rows
#> 
#> ── Ties 
#> # A tibble: 6 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 2     1     3
#> 3     1     4
#> 4     2     3
#> 5     2     4
#> 6     3     4
#>