is.GNARnet {GNAR}R Documentation

Functions to check and create GNARnet objects

Description

is.GNARnet returns either TRUE or FALSE according to a series of GNARnet checks. as.GNARnet returns a GNARnet object from an input weights matrix, 'igraph' object, or a GNARnet without assigned class.

Usage

is.GNARnet(x)
as.GNARnet(x)

Arguments

x

the network to be tested or object to be converted

Details

The is.GNARnet function checks whether the network passes a series of tests:

The as.GNARnet function converts igraph objects to GNARnet form, other possible inputs are adjacency matrices, and lists with $edges and $dist entries of the correct form.

Value

is.GNARnet returns TRUE or FALSE corresponding to passing the above tests. as.GNARnet returns a GNARnet object.

Examples

#check that the example network meets the criteria above
is.GNARnet(fiveNet)

#convert to igraph and back again
as.GNARnet(GNARtoigraph(fiveNet))

#generate a new network with three nodes
#edges 1->2, 2->1, 2->3
#dist 1, 2, 1
#note 1->2 and 2->1 are of different lengths
threeEdge <- list(c(2), c(1,3), NULL)
threeDist <- list(c(1), c(2,1), NULL)
threeNet <- list(edges=threeEdge, dist=threeDist)
#check if this is a GNARnet
is.GNARnet(threeNet)
#use as.GNARnet to change the class
threeNet <- as.GNARnet(threeNet)
#check if this is a GNARnet now
is.GNARnet(threeNet)

[Package GNAR version 1.1.3 Index]