create_network: Create an network object and maintain it

Description Usage Arguments See Also Examples

View source: R/network.R

Description

Create a network object in NetSim from a matrix, set particular ties of the network and transform it back into a matrix

Usage

1
2
3
4
5
6
7
	create_network(matrix, directed = TRUE, reflexive = FALSE)
	set_tie(network, i, j, value)
	network_as_matrix(network)
	## S3 method for class 'NetSimNetwork'
as.matrix(x, ...)
	## S3 method for class 'NetSimNetwork'
print(x, ...)

Arguments

matrix

A (squared) matrix object

directed

Indicates whether the network is directed (TRUE) or undirected (FALSE)

reflexive

Indicates whether the matrix is reflexive (TRUE) or not (FALSE)

network

A NetSim network object

i,j

index of one particular tie. The index starts counting from 0.

value

A value a tie is set to (1 or 0 in binary networks)

x

A NetSim network object

...

Additional arguments

See Also

create_process_state create_attribute_container add_random_ties_to_network add_ring_lattice_to_network

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
nActors <- 5
network <- create_network(matrix(1, nActors, nActors))

# set ties
set_tie(network, i = 0, j = 1, value = 0)
set_tie(network, i = 0, j = 2, value = 0)
# returns FALSE and keeps the network unchanged as the network is not reflexive
set_tie(network, i = 0, j = 0, value = 1)

# there are two equivalent ways to re-transform the network into a matrix
as.matrix(network)
network_as_matrix(network)

NetSim documentation built on May 29, 2017, 6:41 p.m.