powered by
Convert permutation to characteristic vector.
permutationToCharVec(perm, n)
[integer] Characteristic vector cv with cv[i] = 1 if the i-th edge is in the tree.
integer
[integer] Permutation of nodes, e.g., solution of a TSP.
[integer] Number of nodes of the problem.
Other transformation functions: edgeListToCharVec, permutationToEdgelist, prueferToCharVec, prueferToEdgeList
edgeListToCharVec
permutationToEdgelist
prueferToCharVec
prueferToEdgeList
# 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)
Run the code above in your browser using DataLab