1
c partial enumerative algorithm for the maximum clique problem
2
c subroutine clique(n,m,madj,clmax,clnod,bestn)
3
subroutine clique(n,m,mat,maxclique,actnode,best,edge,start,
6
integer mat(n,n),templog
7
c logical*1 mat(n,n),templog
8
integer actnode(n),edge(n),temp,adj(m,n)
9
integer start(n),last(n),d,dtemp,best(n)
10
c maxm greater or equal to the actual size of maxclique
11
c n number of nodes in graph
12
c mat adjacency matrix
13
c actnode actual nodes in original matrix
14
c adj represents nodes found at all depths
15
c maxclique size of largest currently know clique
16
c best nodes in largest currently know clique
17
c d current depth of traversal
18
c start node currently being expanded at depth d
19
c last last node to (possibly) be expanded at depth d
21
c -- maintain pointers to original matrix
30
if (mat(row,col).eq.1) edge(row) = edge(row)+1
36
if (edge(row).lt.min) then
41
edge(minnode) = edge(node)
42
if (node.ne.minnode) then
44
actnode(node) = actnode(minnode)
45
actnode(minnode) = temp
47
templog = mat(row,node)
48
mat(row,node) = mat(row,minnode)
49
mat(row,minnode) = templog
52
templog = mat(node,col)
53
mat(node,col) = mat(minnode,col)
54
mat(minnode,col) = templog
58
if (mat(node,col).eq.1) edge(col) = edge(col) - 1
71
70 start(d) = start(d) + 1
72
if ((d+last(d)-start(d)).gt.maxclique) then
77
c -- determine node for next depth
78
do 75 col = (start(dtemp)+1),last(dtemp)
79
if (mat(adj(dtemp,start(dtemp)),adj(dtemp,col)).eq.1) then
81
adj(d,last(d)) = adj(dtemp,col)
84
c -- if the next depth doesn't contain any nodes, see if a new
85
c -- maxclique has been found and return to previous depth
86
if (last(d).eq.0.) then
88
if (d.gt.maxclique) then
91
best(col) = adj(col,start(col))
96
c -- prune, further expansion would not find a better incumbent
99
c -- continue traversal until a depth of zero is reached