permutationToCharVec: Convert permutation to characteristic vector.

View source: R/transformations.R

permutationToCharVecR Documentation

Convert permutation to characteristic vector.

Description

Convert permutation to characteristic vector.

Usage

permutationToCharVec(perm, n)

Arguments

perm

[integer]
Permutation of nodes, e.g., solution of a TSP.

n

[integer]
Number of nodes of the problem.

Value

[integer] Characteristic vector cv with cv[i] = 1 if the i-th edge is in the tree.

See Also

Other transformation functions: charVecToEdgelist(), edgeListToCharVec(), nodelistToEdgelist(), permutationToEdgelist(), prueferToCharVec(), prueferToEdgeList()

Examples

# first generate a random permutation, e.g., representing
# a roundtrip tour in a graph
perm = sample(1:10)
print(perm)
# now convert into an edge list
permutationToCharVec(perm, n = 10)

jakobbossek/mcMST documentation built on March 14, 2023, 4:28 p.m.