graphdf: Produce a 'data.frame' containing the structure and...

graphdfR Documentation

Produce a data.frame containing the structure and associated attributes

Description

Produce a data.frame containing the node (vertex) and link (edge) structure as well as the associated attributes for these. This provides an easy way to create data tables describing graphs, particularly helpful for users unfamiliar with the structure of igraph objects.

Usage

graphdf(x, ...)

## S4 method for signature 'list'
graphdf(x, ...)

## S4 method for signature 'goc'
graphdf(x, ...)

## S4 method for signature 'grain'
graphdf(x, ...)

## S4 method for signature 'mpg'
graphdf(x, ...)

## S4 method for signature 'igraph'
graphdf(x, ...)

Arguments

x

A goc, mpg, igraph, or list object.

...

Additional arguments (not used).

Value

A list object containing:

v

node (vertex) names and associated attributes;

e

link (edge) lists and associated attributes.

Please see MPG() and GOC() for details about the attributes.

For GOC() objects which typically contain multiple thresholds, an enumerated list of the same length as the number of thresholds is returned each containing v and e elements.

Author(s)

Paul Galpern and Alex Chubaty

See Also

MPG(), GOC()

Examples

## Load raster landscape
tiny <- raster::raster(system.file("extdata/tiny.asc", package = "grainscape"))

## Create a resistance surface from a raster using an is-becomes reclassification
tinyCost <- raster::reclassify(tiny, rcl = cbind(c(1, 2, 3, 4), c(1, 5, 10, 12)))
## Produce a patch-based MPG where patches are resistance features=1
tinyPatchMPG <- MPG(cost = tinyCost, patch = tinyCost == 1)
## Extract a representative subset of 5 grains of connectivity
tinyPatchGOC <- GOC(tinyPatchMPG, nThresh = 5)
## Create a data.frame with the structure and attributes of a MPG object
tinyPatchMPG_df <- graphdf(tinyPatchMPG) # nolint

## Create a data.frame with the structure and attributes of a GOC object
tinyPatchGOC_df <- graphdf(tinyPatchGOC) # nolint

## Create a data.frame with the structure and attributes of any igraph object
graphdf(tinyPatchGOC@th[[1]]$goc)

grainscape documentation built on April 20, 2023, 9:12 a.m.