MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Hamiltoncircuits on polyhedra


Dear Mr. Lucassen,

Hamiltonian circuits on polyhedra?

The function "HamiltonianCycle" is available in the package
DiscreteMath`Combinatorica`

Example of a cube :

In[1]:=<<DiscreteMath`Combinatorica`

In[2]:=verts = Range[8]

Out[2]={1,2,3,4,5,6,7,8}

In[3]:=eds = {{1,2},{2,3},{3,4},{4,1},
{1,5},{2,6},{3,7},{4,8},
{5,6},{6,7},{7,8},{8,5}};

In[4]:=conn[x_,y_] := MemberQ[eds,{x,y}] || MemberQ[eds,{y,x}]

In[5]:=gr = MakeGraph[verts,conn];

In[6]:=HamiltonianCycle[gr,All]

Out[6]=
{{1,2,3,4,8,7,6,5,1},
{1,2,3,7,6,5,8,4,1},
{1,2,6,5,8,7,3,4,1},
{1,2,6,7,3,4,8,5,1},
{1,4,3,2,6,7,8,5,1},
{1,4,3,7,8,5,6,2,1},
{1,4,8,5,6,7,3,2,1},
{1,4,8,7,3,2,6,5,1},
{1,5,6,2,3,7,8,4,1},
{1,5,6,7,8,4,3,2,1},
{1,5,8,4,3,7,6,2,1},
{1,5,8,7,6,2,3,4,1}}


Europeanly yours,


Valeri Astanoff


  • Prev by Date: Re: Bug in Reduce?
  • Next by Date: Re: Strange error when using InequalityPlot3D
  • Previous by thread: Re: Hamiltoncircuits on polyhedra
  • Next by thread: Re: Hamiltoncircuits on polyhedra