tests/testthat/test_getNearestNeighborFeatureSet.R

context("test Feature-set: NEAREST NEIGHBOR")

test_that("getNearestNeighborFeatureSet does produce reasonable results", {
    x = generateSimpleTestNetwork()

    # check the unexposed method which simply returns a vector of distances
    nn.distances = salesperson:::getNearestNeighbourDistancesCPP(x$distance.matrix)
    expect_equal(length(nn.distances), getNumberOfNodes(x))
    expect_true(all(nn.distances == 1))

    # check the exposed method
    nn.feats = getNearestNeighbourFeatureSet(x)
    expect_feature_list(nn.feats, feature.set = "NearestNeighbor")
})
jakobbossek/salesperson documentation built on Dec. 11, 2021, 4:54 a.m.