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

add.methods.networkDynamic

PID-aware versions of functions for adding edges and vertices to networkDynamic objects


Description

The methods (add.vertices.networkDynamic, add.edge.networkDynamic, add.edges.networkDynamic) override their network-package counterparts in order to permit assigning persistent.ids to newly-added elements if the pid is defined. They can be defined by the user with the vertex.pids argument, or, if not specified, a unique random id will be generated. (Note that any new values added by default to a vertex.names pid will not be numeric.)

Usage

## S3 method for class 'networkDynamic'
add.vertices(x, nv, vattr = NULL, last.mode = TRUE, 
    vertex.pid = NULL, ...)

## S3 method for class 'networkDynamic'
add.edges(x, tail, head, names.eval = NULL, vals.eval = NULL, 
    edge.pid = NULL, ...)
    
## S3 method for class 'networkDynamic'
add.edge(x, tail, head, names.eval = NULL, vals.eval = NULL, 
    edge.check = FALSE, edge.pid = NULL, ...)

Arguments

x

an object of class network or networkDynamic (see add.vertices in network)

nv

number of vertices to be added. (see add.vertices in network)

vattr

optionally, a list of attributes with one entry per new vertex. (see add.vertices in network), not interpreted as a dynamic attribute

last.mode

logical; should the new vertices be added to the last (rather than the first) mode of a bipartite network? (see add.vertices in network)

vertex.pid

a vector of vertex.pids to be assigned to the newly-added vertices

edge.pid

a vector of edge.pids to be assigned to the newly-added edges

names.eval

see add.edges in network), not interpreted as a dynamic attribute

vals.eval

see add.edges in network), not interpreted as a dynamic attribute

edge.check

see add.edges in network)

head

see add.edges in network)

tail

see add.edges in network)

...

possible additional arguments

Details

The networkDynamic versions of these methods call the network versions internally. See persistent.ids for additional details about the PID mechanism.

Value

  • add.verticies (invisibly) returns a reference to the network with the new vertices added. Pids will be added/created if a vertex.pid attribute is set.

  • add.edge and add.edges (invisibly) return a reference to the network with the new edges added. Pids will be added/created if a vertex.pid attribute is set.

Note

Adding edges via the extraction/replacement operators [,] bypasses the pid code and will break the edge pids defined for the network. Similarly, add.vertices.active and add.edges.active do not yet support including pids.

Author(s)

lxwang, skyebend, the statnet team

See Also

Examples

# add vertices while using vertex.names as pids
nd <- as.networkDynamic(network.initialize(3))
set.network.attribute(nd,"vertex.pid","vertex.names")
add.vertices(nd,nv=2,vertex.pid=c(4,5)) # specify pids for two new vertices
network.vertex.names(nd) # peek at pids

# add vertices and edges w/ auto-generated pids
nd <- as.networkDynamic(network.initialize(3))
initialize.pids(nd)
get.vertex.attribute(nd,'vertex.pid') # peek at pids
add.vertices(nd,nv=2) # silently generate pids for vertices
get.vertex.attribute(nd,'vertex.pid') # peek at pids
add.edges(nd,1,2) # silently generate a pid for the edge
get.edge.attribute(nd,'edge.pid')

networkDynamic

Dynamic Extensions for Network Objects

v0.10.1
GPL-3
Authors
Carter T. Butts [aut], Ayn Leslie-Cook [aut], Pavel N. Krivitsky [aut], Skye Bender-deMoll [aut, cre], Zack Almquist [ctb], David R. Hunter [ctb], Li Wang [ctb], Kirk Li [ctb], Steven M. Goodreau [ctb], Jeffrey Horner [ctb], Martina Morris [ctb]
Initial release
2020-01-16

We don't support your browser anymore

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