File: hamilton.sci

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (18 lines) | stat: -rw-r--r-- 546 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function [cir]=hamilton(g)
// Copyright INRIA
[lhs,rhs]=argn(0)
if rhs<>1 then error(39), end
// compute lp, la and ls
m=prod(size(g('tail')));
n=g('node_number');
if(g('directed')<>1) then 
  error('The graph must be directed')
end
[lp,la,ls]=adj_lists(1,n,g('tail'),g('head'));
pr=lp-1;np1=n+1;
//
nc=1;nb=-1;
//nc = number of circuits to be found (nc=-1 means all)
//nb = number of backtracking to be performed (nb=-1 means exact procedure)
[s]=m6hamil(n,m,np1,pr,ls,nc,nb); s=[s s(1)];
if(s <> []) then cir=nodes_2_path(s,g);else cir=[];end;