File: max_clique.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 (37 lines) | stat: -rw-r--r-- 880 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function [nsize,nodes]=max_clique(g,ind)
// Copyright INRIA
[lhs,rhs]=argn(0)
if rhs>2|rhs<1 then 
  error(39)
elseif rhs==1 then
  ind=0
end;
// check g
check_graph(g)
// check ind
if (ind<>0&ind<>1) then
  error('The second argument must be 0 or 1')
end
m=prod(size(g('tail')))
n=g('node_number')
head=g('head'); tail=g('tail');
if (ind==1) then
  tta=[tail head];hhe=[head tail];
  xm=sparse([tta' hhe'],ones(tta)',[n,n]);
  [ij,v,mn]=spget(xm);
  [lp,la,ls]=adj_lists(1,n,ij(:,1)',ij(:,2)');
  m2=2*m;np1=n+1;nwk=10*m;
  [wcl]=m6clique1(n,m,m2,np1,nwk,lp,ls);
  ii=find(wcl == 0);
  if (ii<>[]) then wcl(ii)=[]; end;
  nodes=wcl;nsize=size(wcl,2);
else
  xm=sparse([tail' head'],ones(tail'),[n,n]);
  xadj=full(xm+xm');
  mn=m*n;
  [clmax,clnod,bestn]=m6clique(n,m,mn,xadj);
  nsize=clmax;
  ii=find(bestn==0);
  if (ii<>[]) then bestn(ii)=[]; end;
  nodes=clnod(bestn);
end;