|
Enigma 1468
Posted on: Thursday 29/11, 2007; 2:12 PM
Load the Combinatorica package for doing operations on graphs.
Define a function for omputing 2D indexing from 1D indexing on a 6 by 6 array.
Define a function for computing if a pair of nodes is adjacent in a Manhattan metric. You could use GridGraph[6,6] instead, but I want to show how to use an explicit adjacency function here.
Define a function for testing if adjacency between a pair of nodes is excluded.
Use these adjacency functions to define an adjacency matrix.
Use this adjacency matrix to define an adjacency function.
Define the layout (i.e. embedding) of the graph.
Display the graph.
HamiltonianCycle is not designed to work on directed graphs, so the following step is not strictly valid.
Compute all of the Hamiltonian cycles in the graph. There is only one, as expected.
Extract the edges in the Hamiltonian cycle.
Define a function for drawing only the edges that lie on the Hamiltonian cycle.
Display the Hamiltonian cycle.
Rotate the Hamiltonian cycle so that it starts at the correct node.
Compute which positions in the Hamiltonian cycle fall on the nodes labelled "ENIGMA".
Permalink Notebook
|