network: Coercion between 'diffnet', 'network' and 'networkDynamic'

networkR Documentation

Coercion between diffnet, network and networkDynamic

Description

Coercion between diffnet, network and networkDynamic

Usage

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
)

Arguments

graph

An object of class diffnet

slices

An integer vector indicating the slices to subset

...

Further arguments passed to networkDynamic

diffnet2net.args

List of arguments passed to diffnet_to_network.

netdyn.args

List of arguments passed to networkDynamic

toavar

Character scalar. Name of the vertex attribute that holds the times of adoption.

graph.list

A list of network objects.

t0

Integer scalar. Passed to new_diffnet.

t1

Integer scalar. Passed to new_diffnet.

Details

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.

Value

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.

Caveats

Since diffnet does not support edges attributes, these will be lost when converting from network-type objects. The same applies to network attributes.

See Also

Other Foreign: igraph, read_pajek(), read_ucinet_head()

Examples

# Cohersing a diffnet to a list of networks ---------------------------------
set.seed(1)
ans <- diffnet_to_network(rdiffnet(20, 2))
ans

# and back
network_to_diffnet(graph.list = ans, toavar="toa")

# If it was static, we can use -graph- instead
network_to_diffnet(ans[[1]], toavar="toa")

# A random diffusion network ------------------------------------------------
set.seed(87)
dn  <- rdiffnet(50, 4)
ans <- diffnet_to_networkDynamic(dn)

# and back
networkDynamic_to_diffnet(ans, toavar = "toa")


srdyal/diffusiontest documentation built on Dec. 9, 2024, 1:14 a.m.