Jump to content

MaxCliqueDyn algorithm: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Englaidi (talk | contribs)
No edit summary
Copy edits for phrasing, grammar, and math notation cleanup
Line 20: Line 20:
| data6 = {{URL|http://insilab.org/maxclique/}}
| data6 = {{URL|http://insilab.org/maxclique/}}
}}
}}
{{more footnotes needed|date=October 2023}}

{{multiple issues|{{copy edit|date=October 2023}}{{more footnotes needed|date=October 2023}}}}


The '''MaxCliqueDyn algorithm''' is an [[algorithm]] for finding a maximum [[Clique problem|clique]] in an undirected graph.
The '''MaxCliqueDyn algorithm''' is an [[algorithm]] for finding a maximum [[Clique problem|clique]] in an undirected graph.


It is based on a basic algorithm (MaxClique algorithm) which finds a maximum clique of bounded size. The bound is found using an improved coloring algorithm. The MaxCliqueDyn extends MaxClique algorithm to include dynamically varying bounds. This algorithm was designed by [[Janez Konc]] and the description was published in 2007. In comparison to earlier algorithms described in the published article <ref name="Konc2007">{{cite journal |author1=Janez Konc |author2=Dusanka Janezic |title=An improved branch and bound algorithm for the maximum clique problem |journal=MATCH Communications in Mathematical and in Computer Chemistry |volume=58 |issue=3 |pages=569–590 |year=2007 | url =http://insilab.org/articles/match2007.pdf}} [http://insilab.org/maxclique Source code]</ref> the MaxCliqueDyn algorithm is improved by an improved approximate coloring algorithm ([[ColorSort algorithm]]) and by applying tighter, more computationally expensive upper bounds on a fraction of the search space. Both improvements reduce time to find maximum clique. In addition to reducing time improved coloring algorithm also reduces the number of steps needed to find a maximum clique.
MaxCliqueDyn is based on the MaxClique algorithm, which finds a maximum clique of bounded size. The bound is found using a [[coloring algorithm]]. MaxCliqueDyn extends MaxClique to include dynamically varying bounds.
This algorithm was designed by [[Janez Konc]] and its description was published in 2007.<ref name="Konc2007">{{cite journal |author1=Janez Konc |author2=Dusanka Janezic |title=An improved branch and bound algorithm for the maximum clique problem |journal=MATCH Communications in Mathematical and in Computer Chemistry |volume=58 |issue=3 |pages=569–590 |year=2007 | url =http://insilab.org/articles/match2007.pdf}} [http://insilab.org/maxclique Source code]</ref> In comparison to earlier algorithms, MaxCliqueDyn has an improved coloring algorithm (ColorSort) and applies tighter, more computationally expensive upper bounds on a fraction of the search space.<ref name="Konc2007" /> Both improvements reduce time to find maximum clique. In addition to reducing time, the improved coloring algorithm also reduces the number of steps needed to find a maximum clique.


==MaxClique algorithm==
==MaxClique algorithm==
The MaxClique algorithm <ref name=Tomita2003>{{cite conference |first1=Etsuji |last1=Tomita |first2=Tomokazu |last2=Seki |title=An Efficient Branch-and-Bound Algorithm for Finding a Maximum Clique |year=2003 |editor-first1=C. S. |editor-last1=Calude |editor-first2=M. J. |editor-last2=Dinneen |editor-first3=V. |editor-last3=Vajnovszki |book-title=DMTCS 2003 |series=LNCS |number=2731 |pages=278–289 | url=https://web.archive.org/web/20160911054636/http://www.dcs.gla.ac.uk/~pat/jchoco/clique/indSetMachrahanish/papers/tomita2003.pdf}} See also: {{cite journal |author1=E. Tomita |author2=T. Seki |title=An Efficient Branch-and-Bound Algorithm for Finding a Maximum Clique |journal=J Glob Optim |volume=37 |pages=95–111 |year=2007 |doi=10.1007/s10898-006-9039-7}}</ref> is the basic algorithm of MaxCliqueDyn algorithm. The pseudo code of the algorithm is:
The MaxClique algorithm<ref name=Tomita2003>{{cite conference |first1=Etsuji |last1=Tomita |first2=Tomokazu |last2=Seki |title=An Efficient Branch-and-Bound Algorithm for Finding a Maximum Clique |year=2003 |editor-first1=C. S. |editor-last1=Calude |editor-first2=M. J. |editor-last2=Dinneen |editor-first3=V. |editor-last3=Vajnovszki |book-title=DMTCS 2003 |series=LNCS |number=2731 |pages=278–289 | url=https://web.archive.org/web/20160911054636/http://www.dcs.gla.ac.uk/~pat/jchoco/clique/indSetMachrahanish/papers/tomita2003.pdf}} See also: {{cite journal |author1=E. Tomita |author2=T. Seki |title=An Efficient Branch-and-Bound Algorithm for Finding a Maximum Clique |journal=J Glob Optim |volume=37 |pages=95–111 |year=2007 |doi=10.1007/s10898-006-9039-7}}</ref> is the basic algorithm from which MaxCliqueDyn is extended. The [[pseudocode]] of the algorithm is:


'''procedure''' MaxClique(R, C) '''is'''
'''procedure''' MaxClique(R, C) '''is'''
Line 47: Line 48:
'''end while'''
'''end while'''


where ''Q'' is a set of vertices of the currently growing clique, ''Q''<sub>max</sub> is a set of vertices of the largest clique currently found, R is a set of candidate vertices and C its corresponding set of color classes. The MaxClique algorithm recursively searches for maximum clique by adding and removing vertices to and from&nbsp;''Q''.
where ''Q'' is a set of vertices of the currently growing clique, ''Q''<sub>max</sub> is a set of vertices of the largest clique currently found, ''R'' is a set of candidate vertices, and ''C'' its corresponding set of color classes. The MaxClique algorithm recursively searches for a maximum clique by adding and removing vertices to and from&nbsp;''Q''.

==Coloring algorithms==


==Coloring algorithm (ColorSort)==
=== Approximate coloring algorithm ===
In the MaxClique algorithm the approximate coloring algorithm <ref name=Tomita2003 /> is used to obtain set of color classes&nbsp;''C''. The ColorSort algorithm is an improved algorithm of the approximate coloring algorithm. In the approximate coloring algorithm vertices are colored one by one in the same order as they appear in a set of candidate vertices ''R'' so that if the next vertex ''p'' is non-adjacent to all vertices in the some color class it is added to this class and if ''p'' is adjacent to at least one vertex in every one of existing color classes it is put into a new color class.
MaxClique uses an approximate coloring algorithm<ref name="Tomita2003" /> to obtain set of color classes&nbsp;''C''. In the approximate coloring algorithm, vertices are colored one by one in the same order as they appear in a set of candidate vertices ''R'', so that if the next vertex ''p'' is non-adjacent to all vertices in the same color class, it is added to this class, and if ''p'' is adjacent to at least one vertex in every one of existing color classes, it is put into a new color class.


The MaxClique algorithm returns vertices ''R'' ordered by their colors. By looking at the MaxClique algorithm it is clear that vertices ''v''&nbsp;∈&nbsp;''R'' with colors ''C''(''v'')&nbsp;<&nbsp;|''Q''<sub>max</sub>|&nbsp;−&nbsp;|''Q''|&nbsp;+&nbsp;1 will never be added to the current clique&nbsp;''Q''. Therefore, sorting those vertices by color is of no use to MaxClique algorithm.
The MaxClique algorithm returns vertices ''R'' ordered by their colors. Vertices <math>v \in R</math> with colors <math>C(v)<{|Q_{max}|}-{|Q|}+1</math> are never added to the current clique&nbsp;''Q''. Therefore, sorting those vertices by color is of no use to MaxClique algorithm.


=== ColorSort {{Anchor|Coloring algorithm (ColorSort)}} ===
The improved coloring with ColorSort algorithm takes in consideration the above observation. Each vertex is assigned to a color class C<sub>k</sub>. If ''k''&nbsp;<&nbsp;|''Q''<sub>max</sub>|&nbsp;−&nbsp;|''Q''|&nbsp;+&nbsp;1 the vertex is moved to ''R'' (behind the last vertex in&nbsp;''R''). If ''k''&nbsp;≥&nbsp;|''Q''<sub>max</sub>|&nbsp;−&nbsp;|''Q''|&nbsp;+&nbsp;1 than the vertex stays in the color class ''C''<sub>''k''</sub> and is not copied to the set&nbsp;''R''. At the end all of the vertex in color classes ''C''<sub>''k''</sub> where ''k''&nbsp;≥&nbsp;|''Q''<sub>max</sub>|&nbsp;−&nbsp;|''Q''|&nbsp;+&nbsp;1 are added to the back of set ''R'' as they appear in each color class ''C''<sub>''k''</sub> and in increasing order with respect to index&nbsp;''k''. In Color Sort algorithm only these vertices are assigned colors ''C''(''v'')&nbsp;=&nbsp;''k''.
The ColorSort algorithm improves on the approximate coloring algorithm by taking into consideration the above observation. Each vertex is assigned to a color class <math>C_k</math>. If <math>k < {|Q_{max}|}-{|Q|}+1</math>, the vertex is moved to the set&nbsp;''R'' (behind the last vertex in&nbsp;''R''). If <math>k \geq {|Q_{max}|}-{|Q|}+1</math>, then the vertex stays in <math>C_k</math> and is not moved to&nbsp;''R''. At the end, all of the vertices remaining in <math>C_k</math> (where <math>k \geq {|Q_{max}|}-{|Q|}+1</math>) are added to the back of&nbsp;''R'' as they appear in each <math>C_k</math> and in increasing order with respect to index&nbsp;''<math>k</math>''. In the ColorSort algorithm, only these vertices are assigned colors <math>C(v)=k</math>.


ColorSort algorithm <ref name=Konc2007 />
The pseudocode of the ColorSort algorithm is:<ref name="Konc2007" />


'''procedure''' ColorSort(R, C) '''is'''
'''procedure''' ColorSort(R, C) '''is'''
Line 95: Line 99:
[[File:example_MaxCliqueDyn.png|600px|center]]
[[File:example_MaxCliqueDyn.png|600px|center]]


The graph above can be described as candidate set of vertices ''R''&nbsp;=&nbsp;{7<sup>(5)</sup>, 1<sup>(4)</sup>, 4<sup>(4)</sup>, 2<sup>(3)</sup>, 3<sup>(3)</sup>, 6<sup>(3)</sup>, 5<sup>(2)</sup>, 8<sup>(2)</sup>}. Set of vertices ''R'' can now be used as input for both approximate coloring algorithm and ColorSort algorithm. Using any of the two algorithms a table below is constructed.
The graph above can be described as a candidate set of vertices ''R''&nbsp;=&nbsp;{7<sup>(5)</sup>, 1<sup>(4)</sup>, 4<sup>(4)</sup>, 2<sup>(3)</sup>, 3<sup>(3)</sup>, 6<sup>(3)</sup>, 5<sup>(2)</sup>, 8<sup>(2)</sup>}, and used as input for both the approximate coloring algorithm and the ColorSort algorithm. Either algorithm can be used to construct the following table:


{| class="wikitable"
{| class="wikitable"
Line 107: Line 111:
| 3 || 4<sup>(4)</sup>, 2<sup>(3)</sup>, 3<sup>(3)</sup>
| 3 || 4<sup>(4)</sup>, 2<sup>(3)</sup>, 3<sup>(3)</sup>
|}
|}
The approximate coloring algorithm returns set of vertices R={7<sup>(5)</sup>, 5<sup>(2)</sup>, 1<sup>(4)</sup>, 6<sup>(3)</sup>, 8<sup>(2)</sup>, 4<sup>(4)</sup>, 2<sup>(3)</sup>, 3<sup>(3)</sup>} and its corresponding set of color classes ''C''&nbsp;=&nbsp;{1,1,2,2,2,3,3,3}. The ColorSort algorithm returns set of vertices ''R''&nbsp;=&nbsp;{7<sup>(5)</sup>, 1<sup>(4)</sup>, 6<sup>(3)</sup>, 5<sup>(2)</sup>, 8<sup>(2)</sup>, 4<sup>(4)</sup>, 2<sup>(3)</sup>, 3<sup>(3)</sup>} and its corresponding set of color classes ''C''&nbsp;=&nbsp;{–,–,–,–,–,3,3,3}, where – represents unknown color class with&nbsp;''k''&nbsp;<&nbsp;3.
The approximate coloring algorithm returns set of vertices ''R''&nbsp;=&nbsp;{7<sup>(5)</sup>, 5<sup>(2)</sup>, 1<sup>(4)</sup>, 6<sup>(3)</sup>, 8<sup>(2)</sup>, 4<sup>(4)</sup>, 2<sup>(3)</sup>, 3<sup>(3)</sup>} and its corresponding set of color classes ''C''&nbsp;=&nbsp;{1,1,2,2,2,3,3,3}. The ColorSort algorithm returns set of vertices ''R''&nbsp;=&nbsp;{7<sup>(5)</sup>, 1<sup>(4)</sup>, 6<sup>(3)</sup>, 5<sup>(2)</sup>, 8<sup>(2)</sup>, 4<sup>(4)</sup>, 2<sup>(3)</sup>, 3<sup>(3)</sup>} and its corresponding set of color classes ''C''&nbsp;=&nbsp;{–,–,–,–,–,3,3,3}, where – represents unknown color class with&nbsp;''k''&nbsp;<&nbsp;3.


==MaxCliqueDyn algorithm==
==MaxCliqueDyn algorithm==
The MaxCliqueDyn algorithm is in basic MaxClique algorithm that uses ColorSort algorithm instead approximate coloring algorithm for determining color classes. On each step of MaxClique algorithm the algorithm also recalculates the degrees of vertices in R regarding to the vertex the algorithm is currently in. These vertices are then sorted by decreasing order with respect to their degrees in graph G(R). Then the ColorSort algorithm considers vertices in R sorted by their degrees in the induced graph G(R) rather than in G. By doing so the number of steps required to find the maximum clique is reduced to the minimum. Even so, the overall running time of the MaxClique algorithm is not improved, because computational expense O(|R|<sup>2</sup>) of the determination of the degrees and sorting of vertices in R stays the same.
The MaxCliqueDyn algorithm extends the MaxClique algorithm by using the ColorSort algorithm instead of approximate coloring algorithm for determining color classes. On each step of MaxClique, the MaxCliqueDyn algorithm also recalculates the degrees of vertices in ''R'' regarding the vertex the algorithm is currently on. These vertices are then sorted by decreasing order with respect to their degrees in the graph ''G(R)''. Then the ColorSort algorithm considers vertices in ''R'' sorted by their degrees in the induced graph ''G(R)'' rather than in ''G''. By doing so, the number of steps required to find the maximum clique is reduced to the minimum. Even so, the overall running time of the MaxClique algorithm is not improved, because the computational expense <math>O(|R|^2)</math> of the determination of the degrees and sorting of vertices in ''R'' stays the same.


MaxCliqueDyn algorithm <ref name=Konc2007 />
The pseudocode of the MaxCliqueDyn algorithm is:<ref name=Konc2007 />


'''procedure''' MaxCliqueDyn(R, C, level) '''is'''
'''procedure''' MaxCliqueDyn(R, C, level) '''is'''

Revision as of 19:21, 14 November 2023

Developers:Insilab (National Institute of Chemistry Slovenia)
Development status:Active
Written in:C++
Type:graph theory, maximum clique algorithm, clique problem
License:GNU General Public License
Website:insilab.org/maxclique/

The MaxCliqueDyn algorithm is an algorithm for finding a maximum clique in an undirected graph.

MaxCliqueDyn is based on the MaxClique algorithm, which finds a maximum clique of bounded size. The bound is found using a coloring algorithm. MaxCliqueDyn extends MaxClique to include dynamically varying bounds.

This algorithm was designed by Janez Konc and its description was published in 2007.[1] In comparison to earlier algorithms, MaxCliqueDyn has an improved coloring algorithm (ColorSort) and applies tighter, more computationally expensive upper bounds on a fraction of the search space.[1] Both improvements reduce time to find maximum clique. In addition to reducing time, the improved coloring algorithm also reduces the number of steps needed to find a maximum clique.

MaxClique algorithm

The MaxClique algorithm[2] is the basic algorithm from which MaxCliqueDyn is extended. The pseudocode of the algorithm is:

procedure MaxClique(R, C) is
    Q = Ø, Qmax = Ø

    while R ≠ Ø do
        choose a vertex p with a maximum color C(p) from set R
        R := R\{p}
        if |Q| + C(p)>|Qmax| then
            Q := Q ⋃ {p}
            if R ⋂ Γ(p) ≠ Ø then
                obtain a vertex-coloring C' of G(R ⋂ Γ(p))
                MaxClique(R ⋂ Γ(p), C')
            else if |Q|>|Qmax| then Qmax := Q
            Q := Q\{p}
        else
            return
    end while

where Q is a set of vertices of the currently growing clique, Qmax is a set of vertices of the largest clique currently found, R is a set of candidate vertices, and C its corresponding set of color classes. The MaxClique algorithm recursively searches for a maximum clique by adding and removing vertices to and from Q.

Coloring algorithms

Approximate coloring algorithm

MaxClique uses an approximate coloring algorithm[2] to obtain set of color classes C. In the approximate coloring algorithm, vertices are colored one by one in the same order as they appear in a set of candidate vertices R, so that if the next vertex p is non-adjacent to all vertices in the same color class, it is added to this class, and if p is adjacent to at least one vertex in every one of existing color classes, it is put into a new color class.

The MaxClique algorithm returns vertices R ordered by their colors. Vertices with colors are never added to the current clique Q. Therefore, sorting those vertices by color is of no use to MaxClique algorithm.

ColorSort

The ColorSort algorithm improves on the approximate coloring algorithm by taking into consideration the above observation. Each vertex is assigned to a color class . If , the vertex is moved to the set R (behind the last vertex in R). If , then the vertex stays in and is not moved to R. At the end, all of the vertices remaining in (where ) are added to the back of R as they appear in each and in increasing order with respect to index . In the ColorSort algorithm, only these vertices are assigned colors .

The pseudocode of the ColorSort algorithm is:[1]

procedure ColorSort(R, C) is
    max_no := 1;
    kmin := |Qmax| − |Q| + 1;
    if kmin ≤ 0 then kmin := 1;
    j := 0;
    C1 := Ø; C2 := Ø;

    for i := 0 to |R| − 1 do
        p := R[i]; {the i-th vertex in R}
        k := 1;
        while Ck ⋂ Γ(p) ≠ Ø do
            k := k+1;
        if k > max_no then
            max_no := k;
            Cmax_no+1 := Ø;
        end if
        Ck := Ck ⋃ {p};
        if k < kmin then
            R[j] := R[i];
            j := j+1;
        end if
    end for

    C[j−1] := 0;

    for k := kmin to max_no do
        for i := 1 to |Ck| do
            R[j] := Ck[i];
            C[j] := k;
            j := j+1;
        end for
    end for

Example

The graph above can be described as a candidate set of vertices R = {7(5), 1(4), 4(4), 2(3), 3(3), 6(3), 5(2), 8(2)}, and used as input for both the approximate coloring algorithm and the ColorSort algorithm. Either algorithm can be used to construct the following table:

k Ck
1 7(5), 5(2)
2 1(4), 6(3), 8(2)
3 4(4), 2(3), 3(3)

The approximate coloring algorithm returns set of vertices R = {7(5), 5(2), 1(4), 6(3), 8(2), 4(4), 2(3), 3(3)} and its corresponding set of color classes C = {1,1,2,2,2,3,3,3}. The ColorSort algorithm returns set of vertices R = {7(5), 1(4), 6(3), 5(2), 8(2), 4(4), 2(3), 3(3)} and its corresponding set of color classes C = {–,–,–,–,–,3,3,3}, where – represents unknown color class with k < 3.

MaxCliqueDyn algorithm

The MaxCliqueDyn algorithm extends the MaxClique algorithm by using the ColorSort algorithm instead of approximate coloring algorithm for determining color classes. On each step of MaxClique, the MaxCliqueDyn algorithm also recalculates the degrees of vertices in R regarding the vertex the algorithm is currently on. These vertices are then sorted by decreasing order with respect to their degrees in the graph G(R). Then the ColorSort algorithm considers vertices in R sorted by their degrees in the induced graph G(R) rather than in G. By doing so, the number of steps required to find the maximum clique is reduced to the minimum. Even so, the overall running time of the MaxClique algorithm is not improved, because the computational expense of the determination of the degrees and sorting of vertices in R stays the same.

The pseudocode of the MaxCliqueDyn algorithm is:[1]

procedure MaxCliqueDyn(R, C, level) is
    S[level] := S[level] + S[level−1] − Sold[level];
    Sold[level] := S[level−1];

    while R ≠ Ø do
        choose a vertex p with maximum C(p) (last vertex) from R;
        R := R\{p};
        if |Q| + C[index of p in R] > |Qmax| then
            Q := Q ⋃ {p};
            if R ⋂ Γ(p) ≠ Ø then
                if S[level]/ALL STEPS < Tlimit then
                    calculate the degrees of vertices in G(R ⋂ Γ(p));
                    sort vertices in R ⋂ Γ(p) in a descending order
                    with respect to their degrees;
                end if
                ColorSort(R ⋂ Γ(p), C')
                S[level] := S[level] + 1;
                ALL STEPS := ALL STEPS + 1;
                MaxCliqueDyn(R ⋂ Γ(p), C', level + 1);
            else if |Q| > |Qmax| then Qmax := Q;
            Q := Q\{p};
        else
            return
    end while

Value Tlimit can be determined by experimenting on random graphs. In the original article it was determined that algorithm works best for Tlimit = 0.025.

References

  1. ^ a b c d Janez Konc; Dusanka Janezic (2007). "An improved branch and bound algorithm for the maximum clique problem" (PDF). MATCH Communications in Mathematical and in Computer Chemistry. 58 (3): 569–590. Source code
  2. ^ a b Tomita, Etsuji; Seki, Tomokazu (2003). "An Efficient Branch-and-Bound Algorithm for Finding a Maximum Clique" (PDF). In Calude, C. S.; Dinneen, M. J.; Vajnovszki, V. (eds.). DMTCS 2003. LNCS. pp. 278–289. See also: E. Tomita; T. Seki (2007). "An Efficient Branch-and-Bound Algorithm for Finding a Maximum Clique". J Glob Optim. 37: 95–111. doi:10.1007/s10898-006-9039-7.