
activate
and deactivate
set spells of activity and inactivity respectively for elements (edges and vertices) in a dynamic network.activate.edges(x, onset = NULL, terminus = NULL, length = NULL, at = NULL,
e = seq_along(x$mel))
activate.vertices(x, onset = NULL, terminus = NULL, length = NULL, at = NULL,
v = seq_len(network.size(x)))
deactivate.edges(x, onset = NULL, terminus = NULL, length = NULL, at = NULL,
e = seq_along(x$mel))
deactivate.vertices(x, onset = NULL, terminus = NULL, length = NULL, at = NULL,
v = seq_len(network.size(x)), deactivate.edges = FALSE)
network
.terminus
or length
.onset
or length
.onset
or terminus
.activate
and deactivate
functions provide an interface for controlling the state of the elements in a dynamic network.
activate.edges
and activate.vertices
have identical behavior, except for the elements they modify (the same is true for the deactivate.*
functions).
There are several ways to specify the activity spell, and the general syntax rules are described at activity.attribute
. Activity can be set for a single time point, using either at
, or by setting onset=terminus. Activity can be set for an interval [onset,terminus), using a valid combination of the onset
, terminus
and length
attributes.
This allows for a wide range of options when specifying spells, but a correct specification must use only one of these forms:
at
onset and terminus
onset and length
terminus and length
or, you can provide no timing information
If provided with no timing information, the element is activated/deactivated from -Inf
to Inf
.
The specified interval spans the period from the onset (inclusive) to the terminus (exclusive), so [onset,terminus).
There are some special behaviors associated with the arguments Inf
and -Inf
.
c(-Inf,x)
includes-Inf
. For consistency, we also allow the open-ended intervalc(x, Inf)
to includeInf
.
Thus [onset, terminus) will be interpreted as [onset, terminus] when terminus =Inf
.Inf
or-Inf
are only valid when used to specify an interval, they can not be used
to specify status at a time point usingat
. In addition, they cannot be paired with themselves in a call.
That is, both(Inf,Inf)
and(-Inf,-Inf)
are not valid specifications for any spell.deactivate.*(x)
anddeactivate.*(x, -Inf, Inf)
create the null spell -- specifying inactivity over the entire time span. Note that
by convention the null spell is stored as(Inf,Inf)
.at=c(1,3,5 7), v=c(1:4)
) allows multiple elements in the network
to be activated/deactivated simultaneously (note, not multiple spells for a single element).
The spell modifiers are applied sequentially to the selected elements.
If the length of the spell vector is less than the number of elements,
the spell modifiers are recycled as needed.
When multiple network elements are activated in a single call, the spell modifiers must all be of one type,
either at
, or a valid mix of onset
, terminus
and length
.
The activate.*
and deactivate.*
functions in general modify spells in similar, if opposite, ways.
However, there are some behaviors that are specific to each function.
activate.*
.at
specification.e
or v
input vectors.
Edge/vertex activity is tracked through an attribute called (eponymously) get.edge.attribute
), as well as the specialized methods described here.is.active
triangle <- network.initialize(3) # create a toy network
add.edge(triangle,1,2) # add an edge between vertices 1 and 2
add.edge(triangle,2,3) # add more edges
add.edge(triangle,3,1)
# turn on all edges at time 1 only (0 length spell)
activate.edges(triangle,at=1)
# activate edge (1,2) from t=2 to t=3
activate.edges(triangle,onset=2, terminus=3,
e=get.edgeIDs(triangle,v=1,alter=2))
# activate edge (2,3) from t=4 for 2 time lengths
activate.edges(triangle,onset=4, length=2,
e=get.edgeIDs(triangle,v=2,alter=3))
deactivate.edges(triangle, at=2, e=1) # does not work since the spell is not 0-length
is.active(triangle, at=2, e=1:3)
deactivate.edges(triangle, e=1, onset=2, length=0.1) # this deactivates the vertex
is.active(triangle, at=2, e=1:3)
# this activates edges 2 and 3 at time 5
activate.edges(triangle, e=2:3, at=5)
# this doesn't do what you think; multiple spells for a single element is not allowed
activate.edges(triangle, e=1, at=6:8)
is.active(triangle, at=6, e=1:3)
is.active(triangle, at=7, e=1:3)
is.active(triangle, at=8, e=1:3)
Run the code above in your browser using DataLab