Learn R Programming

networkDynamic (version 0.4.1)

network.collapse: Convert a time range of a networkDynamic object into a static network object.

Description

First performs an extraction of the passed networkDynamic object with the specified time range. Computes some crude summary attributes for edge and vertex spells (activity.count, activity.duration), extracts appropriate values from any dynamic attributes and stores them as static attributes. Then removes all temporal information and returns a plain network object.

Usage

network.collapse(dnet, onset = NULL, terminus = NULL, at = NULL, length = NULL, 
                 rule = c("any", "all"), active.default = TRUE, 
                 retain.all.vertices=FALSE, ...)

Arguments

dnet
A networkDynamic object with possible vertex, edge, network, and attribute spell information.
onset
optionally, the start of the specified interval. This must be accompanied by one of terminus or length.
terminus
optionally, the end of the specified interval. This must be accompanied by one of onset or length.
length
optionally, the length of the specified interval. This must be accompanied by one of onset or terminus.
at
optionally, a single time point.
rule
a text string for defining active for this call: any if elements active at any time during the interval are to be used, or all if elements must be active over the entire interval.
active.default
logical; should elements without an activity attribute be regarded as active by default?
retain.all.vertices
logical; should the extracted network retain all vertices, ignoring the vertex activity spells of x in order to ensure that the network returned has the same size as dnet?
...
Possible additional arguments (not yet invented) to handle aggregation of attributes.

Value

  • A new 'static' network object corresponding to the specified time range of the networkDynamic argument. If the original network contained dynamic TEA attributes (i.e. 'weight.active'), the appropriate (if possible) value is queried and stored as a non-TEA attribute ('weight').

Details

If no temporal arguments are specified, defaults to collapsing entire time range of the input network (onset=-Inf,terminus=Inf). Original network is not modified.

See Also

See Also as network.extract for extracting sub-ranges of a networkDynamic, get.vertex.attribute.active for more on TEA attributes, and as.network.networkDynamic for stripping the the networkDynamic class from an object.

Examples

Run this code
# create a network with some basic activity
test<-network.initialize(5)
add.edges.active(test, tail=c(1,2,3), head=c(2,3,4),onset=0,terminus=1)
activate.edges(test,onset=3,terminus=5)
activate.edges(test,onset=-2,terminus=-1)

# collapse the whole thing
net <-network.collapse(test)
is.networkDynamic(net)
get.vertex.attribute(net,'activity.duration')
get.edge.value(net,'activity.count')
get.edge.value(net,'activity.duration')

# add a dynamic edge attribute
activate.edge.attribute(test,'weight',5,onset=3,terminus=4)
activate.edge.attribute(test,'weight',3,onset=4,terminus=5)

# collapse with an interval query
net3<-network.collapse(test,onset=3,terminus=4)
get.edge.value(net3,'weight')

# note that if we use a query that intersects mutiple 
# attribute values it will generate a warning. 
# try commented line below:

# net3<-network.collapse(test,onset=3,terminus=5)

# but should be safe from attribute issues when
# collapsing with a point query
net3<-network.collapse(test,at=3)
get.edge.value(net3,'weight')

# can use operator version for point query instead
net3<-test%k%4.5
get.edge.value(net3,'weight')

Run the code above in your browser using DataLab