ShortestPaths-methods: 'ShortestPaths'

ShortestPathsR Documentation

ShortestPaths

Description

Methods for function ShortestPaths in package EpiContactTrace to get the shortest distance from/to the root given by the contact tracing.

Usage

ShortestPaths(x, ...)

## S4 method for signature 'ContactTrace'
ShortestPaths(x)

## S4 method for signature 'data.frame'
ShortestPaths(
  x,
  root,
  tEnd = NULL,
  days = NULL,
  inBegin = NULL,
  inEnd = NULL,
  outBegin = NULL,
  outEnd = NULL
)

Arguments

x

a ContactTrace object, or a data.frame with movements of animals between holdings, see Trace for details.

...

Additional arguments to the method

root

vector of roots to calculate shortest path for.

tEnd

the last date to include ingoing movements. Defaults to NULL

days

the number of previous days before tEnd to include ingoing movements. Defaults to NULL

inBegin

the first date to include ingoing movements. Defaults to NULL

inEnd

the last date to include ingoing movements. Defaults to NULL

outBegin

the first date to include outgoing movements. Defaults to NULL

outEnd

the last date to include outgoing movements. Defaults to NULL

Details

The contact tracing performs a depth first search starting at the root. The ShortestPaths gives the shortest distance from root at each node. The network tree structure given by the depth first search is shown by show.

Value

A data.frame with the following columns:

root

The root of the contact tracing

inBegin

If the direction is ingoing, then inBegin equals inBegin in Trace else NA.

inEnd

If the direction is ingoing, then inEnd equals inEnd in Trace else NA.

outBegin

If the direction is outgoing, then outBegin equals outBegin in Trace else NA.

outEnd

If the direction is outgoing, then outEnd equals outEnd in Trace else NA.

direction

If the direction is ingoing, then direction equals 'in' else 'out'

source

The source of the contact at distance from root

destination

The destination of the contact at distance from root

distance

The shortest distance from/to root in the depth first search

Methods

signature(object = "ContactTrace")

Get the shortest paths for the ingoing and outgoing Contacts of a ContactTrace object.

signature(x = "data.frame")

Get the shortest paths for a data.frame with movements, see details and examples.

See Also

show and NetworkStructure.

Examples

## Not run: 

## Load data
data(transfers)

## Perform contact tracing
contactTrace <- Trace(movements = transfers,
                      root = 2645,
                      tEnd = "2005-10-31",
                      days = 90)

ShortestPaths(contactTrace)

## Calculate shortest paths for all included herds
## First extract all source and destination from the dataset
root <- sort(unique(c(transfers$source, transfers$destination)))

sp <- ShortestPaths(transfers,
                    root = root,
                    tEnd = "2005-10-31",
                    days = 90)

## End(Not run)

EpiContactTrace documentation built on April 3, 2023, 5:22 p.m.