Coercion between diffnet
, network
and networkDynamic
diffnet_to_network(graph, slices = 1:nslices(graph), ...) diffnet_to_networkDynamic( graph, slices = 1:nslices(graph), diffnet2net.args = list(), netdyn.args = list() ) networkDynamic_to_diffnet(graph, toavar) network_to_diffnet( graph = NULL, graph.list = NULL, toavar, t0 = NULL, t1 = NULL )
graph | An object of class |
---|---|
slices | An integer vector indicating the slices to subset |
... | Further arguments passed to |
diffnet2net.args | List of arguments passed to |
netdyn.args | List of arguments passed to |
toavar | Character scalar. Name of the vertex attribute that holds the times of adoption. |
graph.list | A list of |
t0 | Integer scalar. Passed to |
t1 | Integer scalar. Passed to |
diffnet_to_network
returns a list of length length(slices)
in which
each element is a network
object corresponding a slice of the
graph
(diffnet
object). The attributes list will include toa
(time of
adoption).
An object of class networkDynamic
.
diffnet_to_networkDynamic
calls diffnet_to_network
and
uses the output to call networkDynamic
, passing the resulting list of
network
objects as network.list
(see networkDynamic
).
By default, diffnet_to_networkDynamic
passes net.obs.period
as
net.obs.period = list( observations = list(range(graph$meta$pers)), mode="discrete", time.increment = 1, time.unit = "step" )
By default, networkDynamic_to_diffnet
uses the first slice as reference for
vertex attributes and times of adoption.
By default, network_to_diffnet
uses the first element of graph
(a list) as reference for vertex attributes and times of adoption.
Since diffnet
does not support edges attributes, these will be lost when
converting from network
-type objects. The same applies to network
attributes.
Other Foreign:
igraph
,
read_pajek()
,
read_ucinet_head()
# Cohersing a diffnet to a list of networks --------------------------------- set.seed(1) ans <- diffnet_to_network(rdiffnet(20, 2)) ans#> $`1` #> Network attributes: #> vertices = 20 #> directed = TRUE #> hyper = FALSE #> loops = TRUE #> multiple = FALSE #> bipartite = FALSE #> name = A diffusion network #> behavior = Random contagion #> total edges= 20 #> missing edges= 0 #> non-missing edges= 20 #> #> Vertex attribute names: #> real_threshold toa vertex.names #> #> No edge attributes #> #> $`2` #> Network attributes: #> vertices = 20 #> directed = TRUE #> hyper = FALSE #> loops = TRUE #> multiple = FALSE #> bipartite = FALSE #> name = A diffusion network #> behavior = Random contagion #> total edges= 20 #> missing edges= 0 #> non-missing edges= 20 #> #> Vertex attribute names: #> real_threshold toa vertex.names #> #> No edge attributes #># and back network_to_diffnet(graph.list = ans, toavar="toa")#> Dynamic network of class -diffnet- #> Name : A diffusion network #> Behavior : Random contagion #> # of nodes : 20 (1, 2, 3, 4, 5, 6, 7, 8, ...) #> # of time periods : 2 (1 - 2) #> Type : directed #> Final prevalence : 0.20 #> Static attributes : - #> Dynamic attributes : na, real_threshold (2)# If it was static, we can use -graph- instead network_to_diffnet(ans[[1]], toavar="toa")#> Warning: -graph- is static and will be recycled (see ?new_diffnet).#> Dynamic network of class -diffnet- #> Name : A diffusion network #> Behavior : Random contagion #> # of nodes : 20 (1, 2, 3, 4, 5, 6, 7, 8, ...) #> # of time periods : 2 (1 - 2) #> Type : directed #> Final prevalence : 0.20 #> Static attributes : na, real_threshold (2) #> Dynamic attributes : -# A random diffusion network ------------------------------------------------ set.seed(87) dn <- rdiffnet(50, 4) ans <- diffnet_to_networkDynamic(dn)#> Argument base.net not specified, using first element of network.list instead #> Created net.obs.period to describe network #> Network observation period info: #> Number of observation spells: 1 #> Maximal time range observed: 1 until 4 #> Temporal mode: discrete #> Time unit: step #> Suggested time increment: 1# and back networkDynamic_to_diffnet(ans, toavar = "toa")#> Dynamic network of class -diffnet- #> Name : A diffusion network #> Behavior : Random contagion #> # of nodes : 50 (1, 2, 3, 4, 5, 6, 7, 8, ...) #> # of time periods : 4 (1 - 4) #> Type : directed #> Final prevalence : 0.12 #> Static attributes : - #> Dynamic attributes : na, real_threshold (2)