Skip to contents

BFS from every node; pairs with no path are assigned UNREACHABLE so they can take a special bias rather than producing NaNs downstream.

Usage

morie_grphmr_sp(adj, n)

Arguments

adj

Adjacency list: list of numeric neighbour vectors.

n

Number of nodes.

Value

A list with distance (N x N integer matrix), unreachable, n_unreachable.

Examples

adj <- list(c(2), c(1, 3), c(2), numeric(0))   # path 1-2-3 plus an isolated node 4
morie_grphmr_sp(adj, n = 4)$distance
#>      [,1] [,2] [,3] [,4]
#> [1,]    0   -1    1   -1
#> [2,]   -1    0   -1    1
#> [3,]   -1   -1    0   -1
#> [4,]   -1   -1   -1    0