Calculate tree distance

Description

Compute the number of transmission links separating two nodes in a transmission tree.

Usage

1
translinks(p1, p2, patID, psource)

Arguments

p1

Patient ID 1.

p2

Patient ID 2.

patID

Vector of patient IDs.

psource

Vector of transmission sources corresponding to patID.

Details

Returns the number of transmission links separating two patients in the transmission tree. If patients belong to unconnected transmission trees, -1 is returned. Directions of transmission links are disregarded.

Examples

1
2
3
4
5
data(hospitaldata)
# Patients 48 and 58 are 3 links apart
translinks(48,58,hospitaldata$epi[,1],hospitaldata$epi[,5])
# Patients 89 and 58 are in separate transmission chains
translinks(89,58,hospitaldata$epi[,1],hospitaldata$epi[,5])