Functions API Reference
This page documents all functions available in DynamicNetworks.jl.
Spell Operations
Adding Spells
DynamicNetworks.add_spell! — Function
add_spell!(dnet::DynamicNetwork, spell::Spell; vertex=nothing, edge=nothing,
merge=true) -> dnetAdd an activity spell to a vertex or edge (an edge is added to the base network if needed). With merge=true (default) the element's spells are merged on insertion as R networkDynamic's activate.* do: overlapping and adjacent intervals coalesce, and a point spell inside an interval (or duplicating another point spell) is absorbed; see merge_spells!. merge=false stores the spell as given (the spell vector is still kept sorted).
Example
using DynamicNetworks
dnet = DynamicNetwork(3; observation_start=0.0, observation_end=10.0)
add_spell!(dnet, Spell(0.0, 5.0); edge=(1, 2))
add_spell!(dnet, Spell(5.0, 8.0); edge=(1, 2))
get_spells(dnet; edge=(1, 2)) # [Spell[0.0, 8.0)]: merged, as in RDynamicNetworks.activate! — Function
activate!(dnet::DynamicNetwork, onset, terminus; vertex=nothing, edge=nothing) -> dnetMake a vertex or edge active during [onset, terminus) (R's activate.vertices/activate.edges); onset == terminus records an instantaneous event. Spells are merged on insertion, as in R.
Example
using DynamicNetworks
dnet = DynamicNetwork(3; observation_start=0.0, observation_end=10.0)
activate!(dnet, 0.0, 5.0; vertex=1)
activate!(dnet, 1.0, 4.0; edge=(1, 2))
activate!(dnet, 7.0, 7.0; edge=(2, 3)) # point spell (contact at t = 7)
is_active(dnet, 7.0; edge=(2, 3)) # trueDynamicNetworks.activate_vertices! — Function
activate_vertices!(dnet::DynamicNetwork, vertices, onset, terminus) -> dnetActivate several vertices for the spell [onset, terminus).
Example
using DynamicNetworks
dnet = DynamicNetwork(4; observation_start=0.0, observation_end=10.0)
activate_vertices!(dnet, [1, 2, 3], 0.0, 5.0)
active_vertices(dnet, 7.0) # [4]: vertex 4 has no spells (active by default)DynamicNetworks.activate_edges! — Function
activate_edges!(dnet::DynamicNetwork, edges, onset, terminus) -> dnetActivate several edges (a vector of (i, j) tuples) for the spell [onset, terminus); edges missing from the base network are added.
Example
using DynamicNetworks
dnet = DynamicNetwork(3; observation_start=0.0, observation_end=10.0)
activate_edges!(dnet, [(1, 2), (2, 3)], 0.0, 5.0)
sort(active_edges(dnet, 1.0)) # [(1, 2), (2, 3)]Removing and Merging Spells
DynamicNetworks.remove_spell! — Function
remove_spell!(dnet::DynamicNetwork, spell::Spell; vertex=nothing, edge=nothing) -> dnetRemove a stored spell (matched on onset and terminus) from a vertex or edge. Because spells are merged on insertion, the stored spell may be a union of several activations; to cut activity out of a spell use deactivate!. An element whose last spell is removed is inactive.
Example
using DynamicNetworks
dnet = DynamicNetwork(2; observation_start=0.0, observation_end=10.0)
activate!(dnet, 0.0, 5.0; vertex=1)
remove_spell!(dnet, Spell(0.0, 5.0); vertex=1)
is_active(dnet, 1.0; vertex=1) # false: an empty record means inactiveDynamicNetworks.deactivate! — Function
deactivate!(dnet::DynamicNetwork, onset, terminus; vertex=nothing, edge=nothing) -> dnetRemove activity in [onset, terminus) from a vertex or edge (R's deactivate.vertices/deactivate.edges). Existing spells are truncated or split so that no remaining spell overlaps the interval; spells entirely inside it are removed. Censoring flags are preserved on the surviving spell fragments. A point (zero-duration) interval [t, t) removes only point spells at exactly t (half-open interval spells are unaffected).
An element with no spell record is active by default, i.e. equivalent to the spell (-Inf, Inf) (the extreme values on axes without infinities), and is cut the same way: deactivating [2, 4) leaves [-Inf, 2) and [4, Inf), as in R. An element whose last spell is removed is inactive (an empty record). An edge that is not in the base network has nothing to deactivate.
Example
using DynamicNetworks
dnet = DynamicNetwork(2; observation_start=0.0, observation_end=10.0)
activate!(dnet, 0.0, 10.0; vertex=1)
deactivate!(dnet, 3.0, 6.0; vertex=1)
get_spells(dnet; vertex=1) # [Spell[0.0, 3.0), Spell[6.0, 10.0)]
deactivate!(dnet, 2.0, 4.0; vertex=2)
get_spells(dnet; vertex=2) # [Spell[-Inf, 2.0), Spell[4.0, Inf)]DynamicNetworks.merge_spells! — Function
merge_spells!(dnet::DynamicNetwork; vertex=nothing, edge=nothing) -> dnetMerge the stored spells of a vertex or edge — of every vertex and edge when neither keyword is given — into R networkDynamic's canonical form: overlapping or adjacent intervals coalesce; a point spell [t,t) is absorbed by an interval with onset <= t < terminus and by an identical point spell, and is kept otherwise (so [0,5) and [5,5) stay two spells: the point spell is the activity at t = 5). Censoring flags are preserved: the merged spell keeps the onset censoring of the spell supplying its onset and the terminus censoring of the spell supplying its terminus.
Spells added through activate!/add_spell! are already merged; this is needed only after add_spell!(...; merge=false).
Example
using DynamicNetworks
dnet = DynamicNetwork(2; observation_start=0.0, observation_end=10.0)
add_spell!(dnet, Spell(0.0, 6.0); vertex=1, merge=false)
add_spell!(dnet, Spell(4.0, 10.0); vertex=1, merge=false)
merge_spells!(dnet; vertex=1)
get_spells(dnet; vertex=1) # [Spell[0.0, 10.0)]DynamicNetworks.merge_spell_vector — Function
DynamicNetworks.merge_spell_vector(spells) -> Vector{Spell}Return the canonical (merged, sorted) form of a spell vector without mutating it, with the rules of merge_spells!: overlapping or adjacent intervals coalesce, a point spell inside an interval or duplicating another point spell is absorbed, censoring flags travel with the bound they describe. Public so that consumers (TSNA.jl) that need one lifetime per contiguous activity can merge spells they did not create.
Example
using DynamicNetworks
DynamicNetworks.merge_spell_vector([Spell(0.0, 5.0), Spell(5.0, 10.0), Spell(2.0, 2.0)])
# [Spell[0.0, 10.0)]Retrieving Spells
DynamicNetworks.get_spells — Function
get_spells(dnet::DynamicNetwork; vertex=nothing, edge=nothing) -> Vector{Spell}The spells stored for a vertex or edge (sorted). An element with no spell record returns an empty vector, although it is active by default; use get_vertex_activity/get_edge_activity for R's active.default view.
Example
using DynamicNetworks
dnet = DynamicNetwork(2; observation_start=0.0, observation_end=10.0)
activate!(dnet, 1.0, 3.0; edge=(1, 2))
get_spells(dnet; edge=(1, 2)) # [Spell[1.0, 3.0)]
get_spells(dnet; vertex=1) # Spell{Float64}[]: no recordDynamicNetworks.when_vertex — Function
when_vertex(dnet::DynamicNetwork, v) -> Vector{Spell}The stored activity spells of vertex v (same as get_spells(dnet; vertex=v)).
Example
using DynamicNetworks
dnet = DynamicNetwork(2; observation_start=0.0, observation_end=10.0)
activate!(dnet, 2.0, 4.0; vertex=1)
when_vertex(dnet, 1) # [Spell[2.0, 4.0)]DynamicNetworks.when_edge — Function
when_edge(dnet::DynamicNetwork, i, j) -> Vector{Spell}The stored activity spells of edge (i, j) (same as get_spells(dnet; edge=(i, j))).
Example
using DynamicNetworks
dnet = DynamicNetwork(2; observation_start=0.0, observation_end=10.0)
activate!(dnet, 2.0, 4.0; edge=(1, 2))
when_edge(dnet, 1, 2) # [Spell[2.0, 4.0)]DynamicNetworks.get_activity_range — Function
get_activity_range(dnet::DynamicNetwork; vertex=nothing, edge=nothing) -> Union{Tuple, Nothing}The earliest onset and latest terminus of an element's stored spells, or nothing when it has none.
Note: censored spells report their observed bounds, so with onset_censored/terminus_censored spells this is the observed, not the true, activity range.
Example
using DynamicNetworks
dnet = DynamicNetwork(2; observation_start=0.0, observation_end=10.0)
activate!(dnet, 1.0, 3.0; vertex=1)
activate!(dnet, 6.0, 9.0; vertex=1)
get_activity_range(dnet; vertex=1) # (1.0, 9.0)Activity Queries
The qualified helpers below are public for downstream packages:
DynamicNetworks.spell_active_at — Function
DynamicNetworks.spell_active_at(s::Spell, at) -> BoolTest a half-open activity spell at one instant. A point spell [t,t) is active exactly at t. This public, qualified helper is shared with TSNA.
Example
using DynamicNetworks
DynamicNetworks.spell_active_at(Spell(0.0, 5.0), 5.0) # false: terminus excluded
DynamicNetworks.spell_active_at(Spell(5.0, 5.0), 5.0) # true: point spellDynamicNetworks.elapsed_seconds — Function
DynamicNetworks.elapsed_seconds(duration) -> Float64Convert a fixed Dates duration to seconds, preserving sub-millisecond units. Numeric durations retain their native time unit. Calendar months and years need an origin date and are rejected; subtract two dates or timestamps first.
Example
using DynamicNetworks, Dates
DynamicNetworks.elapsed_seconds(Hour(1)) # 3600.0
DynamicNetworks.elapsed_seconds(2.5) # 2.5 (numeric axes keep their unit)Point and Interval Queries
DynamicNetworks.is_active — Function
is_active(dnet::DynamicNetwork, at; vertex=nothing, edge=nothing, active_default=true) -> Bool
is_active(dnet::DynamicNetwork, onset, terminus; vertex=nothing, edge=nothing,
rule=:any, active_default=true) -> BoolIs a vertex or edge active at the instant at, or during [onset, terminus) (rule=:any: at any point; rule=:all: throughout, possibly across several adjacent spells)? As in R's is.active, an element with no spell record is active when active_default=true. An edge that is not in the base network is never active.
Example
using DynamicNetworks
dnet = DynamicNetwork(3; observation_start=0.0, observation_end=10.0)
activate!(dnet, 0.0, 5.0; vertex=1)
is_active(dnet, 2.0; vertex=1) # true
is_active(dnet, 5.0; vertex=1) # false: terminus excluded
is_active(dnet, 2.0; vertex=2) # true: no record
is_active(dnet, 2.0; vertex=2, active_default=false) # false
is_active(dnet, 3.0, 8.0; vertex=1, rule=:all) # falseDynamicNetworks.get_vertex_activity — Function
get_vertex_activity(dnet::DynamicNetwork, v; active_default=true) -> Vector{Spell}The activity spells of vertex v, after R networkDynamic's get.vertex.activity: a vertex with no spell record is reported as the unbounded spell (-Inf, Inf) when active_default=true (an empty vector otherwise).
Example
using DynamicNetworks
dnet = DynamicNetwork(2; observation_start=0.0, observation_end=10.0)
activate!(dnet, 0.0, 5.0; vertex=1)
get_vertex_activity(dnet, 1) # [Spell[0.0, 5.0)]
get_vertex_activity(dnet, 2) # [Spell[-Inf, Inf)]: active by defaultDynamicNetworks.get_edge_activity — Function
get_edge_activity(dnet::DynamicNetwork, i, j; active_default=true) -> Vector{Spell}The activity spells of edge (i, j), after R networkDynamic's get.edge.activity: an edge of the base network with no spell record is reported as (-Inf, Inf) when active_default=true. An edge that is not in the base network has no spells.
Example
using DynamicNetworks
dnet = DynamicNetwork(2; observation_start=0.0, observation_end=10.0)
activate!(dnet, 1.0, 4.0; edge=(1, 2))
get_edge_activity(dnet, 1, 2) # [Spell[1.0, 4.0)]Active Element Listing
DynamicNetworks.active_vertices — Function
active_vertices(dnet::DynamicNetwork, at; active_default=true) -> VectorThe vertices active at time at (vertices with no spell record count as active when active_default=true).
Example
using DynamicNetworks
dnet = DynamicNetwork(3; observation_start=0.0, observation_end=10.0)
activate!(dnet, 0.0, 5.0; vertex=1)
active_vertices(dnet, 6.0) # [2, 3]DynamicNetworks.active_edges — Function
active_edges(dnet::DynamicNetwork, at; active_default=true) -> Vector{Tuple}The edges of the base network active at time at, as (i, j) tuples ((min, max) on undirected networks); edges with no spell record count as active when active_default=true. Edge activity does not look at the endpoints' activity (as in R); network_extract does.
Example
using DynamicNetworks
dnet = DynamicNetwork(3; observation_start=0.0, observation_end=10.0)
activate!(dnet, 0.0, 5.0; edge=(1, 2))
activate!(dnet, 4.0, 8.0; edge=(2, 3))
sort(active_edges(dnet, 4.5)) # [(1, 2), (2, 3)]Network Extraction
DynamicNetworks.network_extract — Function
network_extract(dnet::DynamicNetwork, at; retain_all_vertices=false,
active_default=true, report=false) -> Network
network_extract(dnet::DynamicNetwork, onset, terminus; rule=:any,
retain_all_vertices=false, active_default=true, report=false) -> NetworkExtract the static network active at the instant at, or during [onset, terminus) (rule=:any: active at any point; rule=:all: active throughout, across adjacent spells). A vertex is included when active; an edge when it is active and both endpoints are (R's network.extract). Elements with no spell record are active when active_default=true (R's default).
With retain_all_vertices=true, all base vertices are kept (inactive ones as isolates), so vertex IDs are stable across time slices. With the default retain_all_vertices=false, inactive vertices are dropped and survivors are renumbered densely to 1:k; each extracted vertex's original ID is recorded in the :vertex_pid vertex attribute (persistent ID, after R networkDynamic's vertex.pid) so slices can still be aligned over time.
Conversion invariants
Preserved either way: directedness, the loops flag, static vertex, edge and network attributes, and the missing-dyad mask (an unobserved dyad of the base network is unobserved in every snapshot of it — it does not silently become an absent tie). Two-mode metadata survives only under retain_all_vertices=true; renumbering destroys the mode partition.
Inherently dropped (a static network has no time axis): spells, time-varying attributes, and the observation period. Pass report=true to get (net, ::NetworkCore.ConversionReport) naming everything the extraction dropped.
Example
using DynamicNetworks, NetworkCore # NetworkCore for nv/ne
dnet = DynamicNetwork(3; observation_start=0.0, observation_end=10.0)
activate!(dnet, 0.0, 5.0; edge=(1, 2))
activate!(dnet, 4.0, 8.0; edge=(2, 3))
activate!(dnet, 0.0, 3.0; vertex=3)
snap = network_extract(dnet, 4.5) # vertex 3 inactive, so (2,3) is dropped
nv(snap), ne(snap) # (2, 1)
ne(network_extract(dnet, 0.0, 10.0)) # 2: union over the intervalDynamicNetworks.network_slice — Function
network_slice(dnet::DynamicNetwork, times::AbstractVector; kwargs...) -> Vector{Network}Extract a sequence of static networks at the given instants. Keyword arguments (retain_all_vertices, active_default) are forwarded to network_extract; report=true is not meaningful here and is rejected.
Example
using DynamicNetworks, NetworkCore # NetworkCore for nv/ne
dnet = DynamicNetwork(3; observation_start=0.0, observation_end=10.0)
activate!(dnet, 0.0, 5.0; edge=(1, 2))
ne.(network_slice(dnet, [1.0, 6.0])) # [1, 0]DynamicNetworks.network_collapse — Function
network_collapse(dnet::DynamicNetwork; onset=nothing, terminus=nothing,
rule=:any, active_default=true, report=false) -> NetworkCollapse the dynamic network to a static one: R's network.collapse, which is network.extract over [onset, terminus) (the whole time axis when they are not given) under rule (:any: active at some point; :all: throughout, possibly across adjacent spells). An edge is included when it and both its endpoints are active under that rule; elements with no spell record are active when active_default=true.
One deliberate difference from R: all base vertices are kept (vertex IDs are stable, inactive vertices are isolates), so the result equals network_extract(dnet, onset, terminus; rule, retain_all_vertices=true). R's attribute aggregation (activity.count, activity.duration, TEA summaries) is not implemented.
Because vertex IDs are stable, everything the static target can hold survives: directedness, loops, two-mode metadata, static vertex/edge/network attributes, and the full missing-dyad mask. Spells, time-varying attributes and the observation window are dropped by nature; pass report=true for (net, ::NetworkCore.ConversionReport) naming them.
Example
using DynamicNetworks, NetworkCore # NetworkCore for nv/ne
dnet = DynamicNetwork(3; observation_start=0.0, observation_end=20.0)
activate!(dnet, 0.0, 5.0; edge=(1, 2))
activate!(dnet, 5.0, 10.0; edge=(1, 2)) # adjacent: merged to [0, 10)
activate!(dnet, 12.0, 15.0; edge=(2, 3))
ne(network_collapse(dnet)) # 2
ne(network_collapse(dnet; onset=2.0, terminus=8.0, rule=:all)) # 1Time-Varying Attributes
Vertex Attributes
DynamicNetworks.set_vertex_attribute_active! — Function
set_vertex_attribute_active!(dnet, v, attr, value, onset, terminus) -> dnetSet a time-varying vertex attribute: attr of vertex v takes value during [onset, terminus) (R's activate.vertex.attribute).
Example
using DynamicNetworks
dnet = DynamicNetwork(2; observation_start=0.0, observation_end=10.0)
set_vertex_attribute_active!(dnet, 1, :status, "S", 0.0, 4.0)
set_vertex_attribute_active!(dnet, 1, :status, "I", 4.0, 10.0)
get_vertex_attribute_active(dnet, 1, :status, 5.0) # "I"DynamicNetworks.get_vertex_attribute_active — Function
get_vertex_attribute_active(dnet, v, attr, at) -> valueThe value of a time-varying vertex attribute at time at, or nothing (R's get.vertex.attribute.active). When several attribute spells cover at, the most recently set value wins.
Example
using DynamicNetworks
dnet = DynamicNetwork(2; observation_start=0.0, observation_end=10.0)
set_vertex_attribute_active!(dnet, 1, :age, 30, 0.0, 5.0)
get_vertex_attribute_active(dnet, 1, :age, 2.0) # 30
get_vertex_attribute_active(dnet, 1, :age, 7.0) # nothingDynamicNetworks.list_vertex_attributes_active — Function
list_vertex_attributes_active(dnet::DynamicNetwork) -> Vector{Symbol}The names of all time-varying vertex attributes.
Example
using DynamicNetworks
dnet = DynamicNetwork(2; observation_start=0.0, observation_end=10.0)
set_vertex_attribute_active!(dnet, 1, :status, "S", 0.0, 4.0)
list_vertex_attributes_active(dnet) # [:status]Edge Attributes
DynamicNetworks.set_edge_attribute_active! — Function
set_edge_attribute_active!(dnet, i, j, attr, value, onset, terminus) -> dnetSet a time-varying edge attribute: attr of edge (i, j) takes value during [onset, terminus) (R's activate.edge.attribute).
Example
using DynamicNetworks
dnet = DynamicNetwork(2; observation_start=0.0, observation_end=10.0)
activate!(dnet, 0.0, 10.0; edge=(1, 2))
set_edge_attribute_active!(dnet, 1, 2, :weight, 0.5, 0.0, 5.0)
get_edge_attribute_active(dnet, 1, 2, :weight, 1.0) # 0.5DynamicNetworks.get_edge_attribute_active — Function
get_edge_attribute_active(dnet, i, j, attr, at) -> valueThe value of a time-varying edge attribute at time at, or nothing (R's get.edge.attribute.active). When several attribute spells cover at, the most recently set value wins.
Example
using DynamicNetworks
dnet = DynamicNetwork(2; directed=false, observation_start=0.0, observation_end=10.0)
set_edge_attribute_active!(dnet, 1, 2, :weight, 2.0, 0.0, 5.0)
get_edge_attribute_active(dnet, 2, 1, :weight, 3.0) # 2.0 (undirected)DynamicNetworks.list_edge_attributes_active — Function
list_edge_attributes_active(dnet::DynamicNetwork) -> Vector{Symbol}The names of all time-varying edge attributes.
Example
using DynamicNetworks
dnet = DynamicNetwork(2; observation_start=0.0, observation_end=10.0)
set_edge_attribute_active!(dnet, 1, 2, :weight, 1.0, 0.0, 4.0)
list_edge_attributes_active(dnet) # [:weight]Observation Period
DynamicNetworks.get_observation_period — Function
get_observation_period(dnet::DynamicNetwork) -> Union{Tuple, Nothing}The observation window (start, end) (R's net.obs.period), or nothing when none was given.
A window is given by the observation_start/observation_end constructor keywords, by set_observation_period!, by as_dynamic_network and by the panel constructor. Without one, nothing is derived from the data, just as R's nd %n% "net.obs.period" is NULL: each consumer applies R's own rule for that case. TSNA.jl follows tsna (lifetimes over the whole time axis, with Inf durations for open spells; event series over the closed range of get_change_times), and NDTV.jl animates the closed range of the change times, as ndtv does. A consumer that needs a finite range and finds none raises an ArgumentError that asks for a window; no placeholder range is ever used.
Example
using DynamicNetworks
dnet = DynamicNetwork(3)
activate!(dnet, 2.0, 7.0; edge=(1, 2))
get_observation_period(dnet) # nothing: no window was given
extrema(get_change_times(dnet)) # (2.0, 7.0): the range of the data
set_observation_period!(dnet, 0.0, 10.0)
get_observation_period(dnet) # (0.0, 10.0)DynamicNetworks.set_observation_period! — Function
set_observation_period!(dnet::DynamicNetwork, start, stop) -> dnetSet the observation window (R's net.obs.period). Activity outside it is not clipped; the window is what duration and censoring computations (TSNA.jl) and default animation ranges (NDTV.jl) use.
Example
using DynamicNetworks
dnet = DynamicNetwork(3)
set_observation_period!(dnet, 0.0, 52.0)
get_observation_period(dnet) # (0.0, 52.0)DynamicNetworks.get_change_times — Function
get_change_times(dnet::DynamicNetwork; vertex_activity=true, edge_activity=true,
vertex_attribute_activity=true, edge_attribute_activity=true,
ignore_inf=true) -> VectorThe sorted, unique onsets and termini of the network's spells (R networkDynamic's get.change.times). The keywords choose which spells are included; ignore_inf=true drops infinite bounds.
Example
using DynamicNetworks
dnet = DynamicNetwork(3)
activate!(dnet, 0.0, 4.0; vertex=1)
activate!(dnet, 2.0, 6.0; edge=(1, 2))
get_change_times(dnet) # [0.0, 2.0, 4.0, 6.0]DynamicNetworks.get_timing_info — Function
get_timing_info(dnet::DynamicNetwork) -> NamedTupleSummary timing information: the observation window (get_observation_period; nothing when none was given), the earliest onset and latest terminus of the stored spells (nothing when there are none), and the stored vertex and edge spell counts.
Example
using DynamicNetworks
dnet = DynamicNetwork(3; observation_start=0.0, observation_end=10.0)
activate!(dnet, 2.0, 6.0; edge=(1, 2))
info = get_timing_info(dnet)
info.data_start, info.data_end, info.n_edge_spells # (2.0, 6.0, 1)Conversion and Reconciliation
DynamicNetworks.as_dynamic_network — Function
as_dynamic_network(net::Network; onset=0.0, terminus=1.0, report=false) -> DynamicNetworkConvert a static network to a dynamic network with all elements active during the specified period. Mixed numeric onset/terminus types are promoted (e.g. onset=0, terminus=10.0 gives a Float64 time axis); DateTime/Date values give a calendar time axis.
Conversion invariants
This direction is lossless: a DynamicNetwork wraps a Network, so the whole source object is carried into it by copy — directedness, the loops flag, two-mode metadata, vertex, edge and network attributes, and the missing-dyad mask (a dyad that was unobserved statically is unobserved for the whole observation window). Every vertex and every edge gets the single spell [onset, terminus), and the observation window is set to it, so network_collapse(as_dynamic_network(net)) reproduces net.
report=true returns (dnet, ::NetworkCore.ConversionReport); the report is lossless.
Example
using DynamicNetworks, NetworkCore
net = network(3; directed=false)
add_edge!(net, 1, 2)
dnet = as_dynamic_network(net; onset=0.0, terminus=10.0)
is_active(dnet, 5.0; edge=(2, 1)) # trueas_dynamic_network(networks::AbstractVector{<:Network}; onsets=nothing,
termini=nothing, start=nothing, report=false) -> DynamicNetwork
DynamicNetwork(networks::AbstractVector{<:Network}; onsets=nothing,
termini=nothing, start=nothing) -> DynamicNetworkBuild a dynamic network from a panel of static networks observed one after another: R networkDynamic's networkDynamic(network.list = networks), with its discrete-spell semantics.
- Network
kholds during[onsets[k], termini[k]). By default each panel is one time step long:onsets = start .+ (0:K-1)andtermini = onsets .+ 1, withstart = 0(R's "each network in network.list should have a discrete spell of length 1"). - Every vertex is active in every panel's spell, and every tie present in panel
kis active during that panel's spell. Spells are merged, so a tie present in consecutive panels has one spell (it forms once), as in R. - The observation window is
(minimum(onsets), maximum(termini)). R records each panel's spell innet.obs.period; aDynamicNetworkholds one window, so gaps between non-contiguous panels are not recorded (tsna uses only the outer range ofnet.obs.periodeither way). - Vertices are matched by position: every panel must have the same number of vertices, directedness,
loopsflag and two-mode partition (R'svertex.pidmatching of panels with different vertex sets is not implemented, and is refused with anArgumentError).
Conversion invariants
The base network takes the static vertex and network attributes of the first panel (R's base.net default). A missing-dyad mask is carried when every panel has the same one; panels with different masks are refused, because a DynamicNetwork has no time-varying mask. Edge attributes, and vertex or network attributes that differ in later panels, have no slot (R would need create.TEAs = TRUE) and are named in the NetworkCore.ConversionReport that report=true returns as (dnet, rep).
Example
using DynamicNetworks, NetworkCore
w1 = network(3); add_edge!(w1, 1, 2)
w2 = network(3); add_edge!(w2, 1, 2); add_edge!(w2, 2, 3)
w3 = network(3); add_edge!(w3, 2, 3)
dnet = DynamicNetwork([w1, w2, w3])
get_spells(dnet; edge=(1, 2)) # [Spell[0.0, 2.0)]: waves 1 and 2, one spell
get_spells(dnet; edge=(2, 3)) # [Spell[1.0, 3.0)]
get_observation_period(dnet) # (0.0, 3.0)DynamicNetworks.reconcile_activity! — Function
reconcile_activity!(dnet::DynamicNetwork) -> dnetMake edge activity consistent with vertex activity: an edge is kept active only while both endpoints are active (R networkDynamic's reconcile.edge.activity(mode = "reduce.to.vertices")). Elements with no spell record are active by default, so
- an edge whose endpoints both have no vertex record is left unchanged;
- an edge with no record of its own becomes the intersection of its endpoints' activity;
- an endpoint whose spells were all removed (never active) leaves the edge inactive.
Point spells survive (an instantaneous edge event inside vertex activity is kept), and censoring flags travel with the bound that survives.
Example
using DynamicNetworks
dnet = DynamicNetwork(3; observation_start=0.0, observation_end=10.0)
activate!(dnet, 0.0, 4.0; vertex=1)
activate!(dnet, 2.0, 8.0; vertex=2)
activate!(dnet, 0.0, 10.0; edge=(1, 2))
reconcile_activity!(dnet)
get_spells(dnet; edge=(1, 2)) # [Spell[2.0, 4.0)]