<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - comments on Post, Hamiltonian Cycles</title>
    <link>http://www.mapleprimes.com/posts/88576-Hamiltonian-Cycles</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Fri, 12 Jun 2026 10:50:22 GMT</lastBuildDate>
    <pubDate>Fri, 12 Jun 2026 10:50:22 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest comments added to the Post, Hamiltonian Cycles</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - comments on Post, Hamiltonian Cycles</title>
      <link>http://www.mapleprimes.com/posts/88576-Hamiltonian-Cycles</link>
    </image>
    <item>
      <title>Many thanks from me to you</title>
      <link>http://www.mapleprimes.com/posts/88576-Hamiltonian-Cycles?ref=Feed:MaplePrimes:Hamiltonian Cycles:Comments#comment88654</link>
      <itunes:summary>&lt;p&gt;Many thanks from me to you for the meaty answer.&lt;/p&gt;
&lt;p&gt;I will try to execute this C program under Unix with Maple 13 under Windows XP.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The execution of MMA code in the case k=n=6&lt;span class="postbody"&gt; took&amp;nbsp; a few hours. I think that the limitations  of my comp were reached. &lt;br /&gt;
&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="postbody"&gt;M. H.&lt;/span&gt;&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, Hamiltonian Cycles</description>
      <guid>88654</guid>
      <pubDate>Sat, 29 May 2010 20:15:19 Z</pubDate>
      <itunes:author>hirnyk</itunes:author>
      <author>hirnyk</author>
    </item>
    <item>
      <title>Working with large output</title>
      <link>http://www.mapleprimes.com/posts/88576-Hamiltonian-Cycles?ref=Feed:MaplePrimes:Hamiltonian Cycles:Comments#comment88656</link>
      <itunes:summary>&lt;p&gt;If the output is large, the ssystem chokes, which results in the situation when the interrupt button is not working, and it may be even not that easy to close Maple.&lt;/p&gt;
&lt;p&gt;In such cases, one can first write the output on the disk and then read it from there to Maple if necessary, using the following 2 procedures,&lt;/p&gt;
&lt;pre&gt;
HamiltonianCyclesWrite:=proc(g)
    local n,temp,fd,i;
    n:=GraphTheory:-NumberOfVertices(g);
    temp:=&amp;quot;/Users/Alec/AppData/Local/Temp/hctemp&amp;quot;;
    fd:=open(temp,WRITE);
    fprintf(fd, cat(&amp;quot;$\n&amp;amp;Graph\nG\n%d&amp;quot;,
        &amp;quot;\n%{}d&amp;quot;$n-1,&amp;quot;  0\n&amp;quot;), n,  
        seq(&amp;lt;-i,op(select(`&amp;gt;`,op([4,3,i,2],g),i))&amp;gt;,
            i=1..n-1));
    close(fd);
    system[launch](&amp;quot;/cyg/bin/bash&amp;quot;, &amp;quot;--login&amp;quot;, &amp;quot;-c&amp;quot;,  
        cat(&amp;quot;'hamiltonianCycles/hc_list_cycles &amp;quot;,
            &amp;quot;/cygdrive/c&amp;quot;, temp, &amp;quot; &amp;gt; &amp;quot;,
            &amp;quot;/cygdrive/c&amp;quot;, temp, 1, &amp;quot;'&amp;quot;))
end;

HamiltonianCyclesRead:=proc(g)
    local m,n,temp1,fd,M;
    n:=GraphTheory:-NumberOfVertices(g);
    temp1:=&amp;quot;/Users/Alec/AppData/Local/Temp/hctemp1&amp;quot;;
    m:=parse(ssystem(cat(&amp;quot;/cyg/bin/bash --login -c 
        'wc -l /cygdrive/c&amp;quot;, temp1, &amp;quot;'&amp;quot;))[2][1..-52])-1;
    fd:=open(temp1,READ);
    readline(fd);
    M:=fscanf(fd, cat(&amp;quot;%{&amp;quot;,m,&amp;quot;,&amp;quot;,n,&amp;quot;;d(&amp;lt;&amp;gt;)}dm&amp;quot;))[];
    close(fd);
    M
end;
&lt;/pre&gt;
&lt;p&gt;If temp1 is changed, then 52 should be changed accordingly the change of the length of temp1 - if the length, say, get increased by 3 characters, 3 should be added to 52, making it 55. That works as&lt;/p&gt;
&lt;pre&gt;
use GraphTheory in  
    g:=CartesianProduct(CycleGraph(6),PathGraph(6))
end;
HamiltonianCyclesWrite(g);

                                 1436

M:=HamiltonianCyclesRead(g);

                         [ 63674 x 36 Matrix     ]
                    M := [ Data Type: integer[4] ]
                         [ Storage: rectangular  ]
                         [ Order: Fortran_order  ]
&lt;/pre&gt;
&lt;p&gt;The file hctemp1 in this example has size 6.31 MB, so one can estimate the sizes of files in larger examples :)&lt;/p&gt;
&lt;p&gt;Alec&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, Hamiltonian Cycles</description>
      <guid>88656</guid>
      <pubDate>Sun, 30 May 2010 11:54:15 Z</pubDate>
      <itunes:author>Alec Mihailovs</itunes:author>
      <author>Alec Mihailovs</author>
    </item>
    <item>
      <title>HamiltonianCyclesCount</title>
      <link>http://www.mapleprimes.com/posts/88576-Hamiltonian-Cycles?ref=Feed:MaplePrimes:Hamiltonian Cycles:Comments#comment88655</link>
      <itunes:summary>&lt;p&gt;For the cases with many Hamiltonian cycles, the following procedure might be useful,&lt;/p&gt;
&lt;pre&gt;
HamiltonianCyclesCount:=proc(g)
    local n,temp,fd,i;
    n:=GraphTheory:-NumberOfVertices(g);
    temp:=&amp;quot;/Users/Alec/AppData/Local/Temp/hctemp&amp;quot;;
    fd:=open(temp,WRITE);
    fprintf(fd, cat(&amp;quot;$\n&amp;amp;Graph\nG\n%d&amp;quot;,
        &amp;quot;\n%{}d&amp;quot;$n-1,&amp;quot;  0\n&amp;quot;), n,  
        seq(&amp;lt;-i,op(select(`&amp;gt;`,op([4,3,i,2],g),i))&amp;gt;,
            i=1..n-1));
    close(fd);
    parse(ssystem(cat(&amp;quot;/cyg/bin/bash --login -c &amp;quot;,  
        &amp;quot;'hamiltonianCycles/hc_count &amp;quot;,
        &amp;quot;/cygdrive/c&amp;quot;, temp, &amp;quot;'&amp;quot;))[2][7..-22]);
end;
&lt;/pre&gt;
&lt;p&gt;For example,&lt;/p&gt;
&lt;pre&gt;
use GraphTheory in  
    g:=CartesianProduct(CycleGraph(6),PathGraph(6))
end:
HamiltonianCyclesCount(g);

                                63674
use GraphTheory in  
    g:=CartesianProduct(CycleGraph(7),PathGraph(7))
end:
HamiltonianCyclesCount(g);

                               2861964
use GraphTheory in  
    g:=CartesianProduct(CycleGraph(8),PathGraph(8))
end;
HamiltonianCyclesCount(g);

                              1087362018
&lt;/pre&gt;
&lt;p&gt;Also, instead of trying to get the list of cycles into Maple, one could save them in a file, and then read that file from Maple if necessary - that can be done by a slight change in the original procedure - I'll post that later.&lt;/p&gt;
&lt;p&gt;Alec&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, Hamiltonian Cycles</description>
      <guid>88655</guid>
      <pubDate>Sun, 30 May 2010 11:57:39 Z</pubDate>
      <itunes:author>Alec Mihailovs</itunes:author>
      <author>Alec Mihailovs</author>
    </item>
    <item>
      <title>super</title>
      <link>http://www.mapleprimes.com/posts/88576-Hamiltonian-Cycles?ref=Feed:MaplePrimes:Hamiltonian Cycles:Comments#comment88805</link>
      <itunes:summary>&lt;p&gt;This is my favourite kind of post -- putting it altogther to get the desired functional result. I look forward to &amp;quot;modding it up&amp;quot; in the new Primes.&lt;/p&gt;
&lt;p&gt;Use of &lt;b&gt;ssystem&lt;/b&gt; that would work in the Standard GUI, with various quotes in the argument, is an achievement in itself. That function in Standard is quite different from the one in the commandline interface, and some examples of it which work as expected in the latter go wrong in the former.&lt;/p&gt;
&lt;p&gt;acer&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, Hamiltonian Cycles</description>
      <guid>88805</guid>
      <pubDate>Tue, 01 Jun 2010 09:33:06 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
    <item>
      <title>Classic</title>
      <link>http://www.mapleprimes.com/posts/88576-Hamiltonian-Cycles?ref=Feed:MaplePrimes:Hamiltonian Cycles:Comments#comment88806</link>
      <itunes:summary>&lt;p&gt;Thank you!&lt;/p&gt;
&lt;p&gt;Actually, I didn't try it in Standard - just in Classic, which is still pretty good in Windows. It would be nice if that worked in Standard, too.&lt;/p&gt;
&lt;p&gt;Alec&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, Hamiltonian Cycles</description>
      <guid>88806</guid>
      <pubDate>Tue, 01 Jun 2010 10:28:34 Z</pubDate>
      <itunes:author>Alec Mihailovs</itunes:author>
      <author>Alec Mihailovs</author>
    </item>
    <item>
      <title>front page</title>
      <link>http://www.mapleprimes.com/posts/88576-Hamiltonian-Cycles?ref=Feed:MaplePrimes:Hamiltonian Cycles:Comments#comment88852</link>
      <itunes:summary>&lt;p&gt;It is front page material.&lt;/p&gt;
&lt;p&gt;acer&lt;/p&gt;
&lt;p&gt;&amp;quot;When a true genius appears in this world, you may know him by this sign,&lt;br /&gt;
that the dunces are all in confederacy against him.&amp;quot; - Swift&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, Hamiltonian Cycles</description>
      <guid>88852</guid>
      <pubDate>Wed, 02 Jun 2010 05:00:31 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
  </channel>
</rss>