add.methods.networkDynamic: PID-aware versions of functions for adding edges and vertices...

add.methodsR Documentation

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

See also persistent.ids, add.vertices, add.edge, add.edges in network.

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 documentation built on May 29, 2024, 1:16 a.m.