liveBook · Manning

Permutation

As explained in Advanced Algorithms and Data Structures

A permutation is an arrangement of the elements of a sequence in which each element occurs exactly once.

A permutation arranges sequence elements so each occurs exactly once. In route optimization, a permutation of graph vertices represents a candidate tour: visit every vertex once, then return to the starting vertex. section 17.2.2 section 17.2.4

When permutations encode a traveling-salesperson solution, preserve these constraints and implementation choices:

  • Use every vertex exactly once; represent each gene as a vertex index, with no repeated value. section 18.2.1
  • Evaluate adjacent edges and include the wraparound edge from the final vertex to the first. section 17.2.4
  • Fix a required starting vertex to remove equivalent cyclic shifts; six vertices therefore shrink from 720 arrangements to 120. section 17.2.3
  • Choose transitions according to the search behavior needed: adjacent swaps make local changes, arbitrary swaps explore farther, and random permutation makes large jumps. section 17.2.4

A six-vertex tour

For six cities, [New Carthage, Happy Harbor, Gotham City, Metropolis, Opal City, Civic City] is one permutation. Rotating the same sequence produces an equivalent closed tour, while reversing it can produce another equivalent solution in an undirected graph. section 17.2.2 section 17.2.3

Listing 17.2 Cost function for TSP
function tspTourCost(graph, P)                                       #1
  cost ← 0
  for k in {0..|P|} do                                               #2
    cost ← cost + graph.edgeBetween(P[k], P[(k+1)%|P|]).weight       #3
  return cost

Inspect the cost-function pseudocode to see how a permutation becomes a closed tour by summing edge weights with modular wraparound. section 17.2.4

How Advanced Algorithms and Data Structures covers it

How deep it goes
Defines the representation, cost calculation, symmetry pruning, initialization, and transition operators, but not permutation theory beyond optimization.
Examples
Uses six-city and ten-vertex tours, explicit city sequences, cost landscapes, random initialization, swaps, and random-permutation transitions.
What it assumes
Assumes basic graphs, edge weights, and optimization, while explaining permutation encoding and tour constraints through concrete routes.
What you can do after
Build candidate TSP solutions, calculate closed-tour costs, prune equivalent arrangements, and select search transitions.
How it connects
Connects permutations with graphs, the traveling salesperson problem, simulated annealing, genetic algorithms, chromosomes, fitness functions, and local search.

Also explained in

Compare how 9 books explain permutation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Advanced Algorithms and Data Structures. The section links point to the parts of the book it draws on.