GraphTheory - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Mathematics : Discrete Mathematics : Graph Theory : GraphTheory Package : GraphTheory/GreedyClique

GraphTheory

  

GreedyClique

  

GreedyIndependentSet

 

Calling Sequence

Parameters

Description

Examples

References

Compatibility

Calling Sequence

GreedyClique(G, opts)

GreedyIndependentSet(G, opts)

Parameters

G

-

graph

opts

-

(optional) equation of the form iterations = n or thresholds = t, where n is a positive integer and t is a non-empty list of numerical values in the closed interval 0,1

Description

• 

GreedyClique attempts to find a large clique of the graph G. It returns the set of vertex labels corresponding to the clique it finds.

• 

GreedyIndependentSet attempts to find a large independent set of the graph G. It returns the set of vertex labels corresponding to the independent set it finds. It does this by calling GreedyClique on the complement of G.

• 

The problem of finding a maximum clique for a graph is NP-complete, meaning that no polynomial-time algorithm is presently known that can return a clique of the largest possible size for a given graph. An exhaustive search is implemented in the MaximumClique command, which will take an exponential time on some graphs. By contrast, the algorithm implemented in GreedyClique takes polynomial time, but it may return a clique that is not of maximum size.

• 

The algorithm is a so-called GRASP process, which stands for greedy randomized adaptive search procedure. It consists of an outer loop, of which each iteration tries to find a large clique; the procedure then returns the largest clique found. A single iteration of this outer loop consists of two steps:

– 

In step 1, the procedure finds a clique that is maximal, i.e., a clique that cannot be extended to a larger clique. (This is different from a maximum clique, as discussed in a bullet point above.) This is done in a loop, by starting with the empty set of vertices, and then in each iteration, selecting a vertex to add that is connected to all previously selected vertices. Among all such vertices connected to all previously selected vertices, let d and D be the minimal and maximal degrees; the procedure will select a vertex whose degree is at least d+θDd, where θ is a numerical constant between 0 and 1 that is a parameter for the algorithm. The value of θ can be controlled by the thresholds option: its value is a list of such constants, one for each iteration of the outer loop.

– 

In step 2, the process tries to find a larger clique by finding a vertex it can remove from the clique and replace by two vertices that can be added. It continues doing this (and extending the clique to a maximal clique, if necessary) until no such change can be made anymore.

• 

As explained above, you can increase or decrease the number of iterations of the outer loop by passing the thresholds parameter, specifying the values for the parameter θ in each iteration. If the thresholds parameter is not specified, then the number of iterations of the outer loop is specified by the iterations parameter; the thresholds used are then equally spread out from 0 to 1 - they are the numbers iiterations1, as i ranges from 0 to iterations1. If the iterations parameter is also not specified, its default value is 5, so the thresholds used are by default 0,14,12,34,1. If both the thresholds and iterations parameters are specified, then the iterations parameter is ignored.

Examples

withGraphTheory:

withRandomGraphs:

Here we have a random graph that is quite dense. Each possible edge of this graph with 1000 vertices is included with probability 0.95.

G1RandomGraph1000,0.95:

c1GreedyCliqueG1

c128,35,52,58,59,63,78,81,95,102,105,107,109,132,135,157,180,204,213,216,236,244,251,252,263,297,305,308,319,343,346,364,367,370,381,391,393,410,413,427,431,436,453,460,463,469,470,471,480,509,515,517,519,538,550,551,552,564,570,574,589,620,638,641,654,673,681,702,704,705,717,739,746,763,769,797,815,842,843,851,860,864,865,873,892,895,907,913,919,920,922,945,948,958,963,970,990,994,997,1000

(1)

IsCliqueG1,c1

true

(2)

numelemsc1

100

(3)

Theoretical considerations show that the expected number of cliques of size k in this graph is 1000k0.95k2. This number dips below 1 around k=120, which suggests that the maximum clique should be of size around 120.

We try the same thing with a very sparse graph. We specify that Maple should run 50 iterations instead of the normal 5.

G2RandomGraph3000,0.01:

c2GreedyCliqueG2,iterations=50

c21380,1384,2025,2635

(4)

IsCliqueG2,c2

true

(5)

numelemsc2

4

(6)

The same argument as above, now with the formula 3000k0.01k2, suggests that the maximum clique in this graph should be of size about 4.

Finally, we try a regular graph.

G3RandomRegularGraph100,30

G3Graph 1: an undirected unweighted graph with 100 vertices and 1500 edge(s)

(7)

By setting the infolevel entry for GreedyClique (or for GraphTheory), we can see what happens for each iteration. We specify different thresholds to see if this has any effect: we run twenty iterations with threshold 0 (pick any suitable vertex) and twenty with threshold 1 (pick only vertices with the maximal degree).

infolevelGreedyClique4

infolevelGreedyClique4

(8)

c3GreedyCliqueG3,thresholds=0$20,1$20

GreedyClique: step 1: found clique of size 4 with parameter 0

GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 5 with parameter 0
GreedyClique: step 2: clique grown to size 6
GreedyClique: step 1: found clique of size 4 with parameter 0
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 4 with parameter 0
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 5 with parameter 0
GreedyClique: step 2: clique grown to size 6
GreedyClique: step 1: found clique of size 4 with parameter 0
GreedyClique: step 2: clique grown to size 4
GreedyClique: step 1: found clique of size 5 with parameter 0
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 5 with parameter 0
GreedyClique: step 2: clique grown to size 6
GreedyClique: step 1: found clique of size 4 with parameter 0
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 3 with parameter 0
GreedyClique: step 2: clique grown to size 4
GreedyClique: step 1: found clique of size 4 with parameter 0
GreedyClique: step 2: clique grown to size 4
GreedyClique: step 1: found clique of size 4 with parameter 0
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 5 with parameter 0
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 5 with parameter 0
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 4 with parameter 0
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 4 with parameter 0
GreedyClique: step 2: clique grown to size 4
GreedyClique: step 1: found clique of size 5 with parameter 0
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 3 with parameter 0
GreedyClique: step 2: clique grown to size 4
GreedyClique: step 1: found clique of size 5 with parameter 0
GreedyClique: step 2: clique grown to size 6
GreedyClique: step 1: found clique of size 5 with parameter 0
GreedyClique: step 2: clique grown to size 6
GreedyClique: step 1: found clique of size 5 with parameter 1
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 5 with parameter 1
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 4 with parameter 1
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 6 with parameter 1
GreedyClique: step 2: clique grown to size 6
GreedyClique: step 1: found clique of size 4 with parameter 1
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 5 with parameter 1
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 5 with parameter 1
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 4 with parameter 1
GreedyClique: step 2: clique grown to size 4
GreedyClique: step 1: found clique of size 5 with parameter 1
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 3 with parameter 1
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 5 with parameter 1
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 4 with parameter 1
GreedyClique: step 2: clique grown to size 4
GreedyClique: step 1: found clique of size 4 with parameter 1
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 5 with parameter 1
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 4 with parameter 1
GreedyClique: step 2: clique grown to size 4
GreedyClique: step 1: found clique of size 4 with parameter 1
GreedyClique: step 2: clique grown to size 6
GreedyClique: step 1: found clique of size 4 with parameter 1
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 5 with parameter 1
GreedyClique: step 2: clique grown to size 6
GreedyClique: step 1: found clique of size 4 with parameter 1
GreedyClique: step 2: clique grown to size 5
GreedyClique: step 1: found clique of size 5 with parameter 1
GreedyClique: step 2: clique grown to size 5

c335,36,39,40,58,77

(9)

We can also find an independent set in the same graph.

i3GreedyIndependentSetG3,iterations=8

GreedyClique: step 1: found clique of size 7 with parameter 0

GreedyClique: step 2: clique grown to size 11
GreedyClique: step 1: found clique of size 9 with parameter 1/7
GreedyClique: step 2: clique grown to size 10
GreedyClique: step 1: found clique of size 10 with parameter 2/7
GreedyClique: step 2: clique grown to size 11
GreedyClique: step 1: found clique of size 9 with parameter 3/7
GreedyClique: step 2: clique grown to size 9
GreedyClique: step 1: found clique of size 10 with parameter 4/7
GreedyClique: step 2: clique grown to size 11
GreedyClique: step 1: found clique of size 9 with parameter 5/7
GreedyClique: step 2: clique grown to size 12
GreedyClique: step 1: found clique of size 8 with parameter 6/7
GreedyClique: step 2: clique grown to size 12
GreedyClique: step 1: found clique of size 9 with parameter 1
GreedyClique: step 2: clique grown to size 11

i33,6,11,20,34,36,45,56,59,62,76,84

(10)

We show the resulting clique and independent set.

HighlightSubgraphG3,InducedSubgraphG3,c3,edgestylesheet=color=red,vertexstylesheet=color=red

HighlightSubgraphG3,InducedSubgraphG3,i3,edgestylesheet=color=green,vertexstylesheet=color=green

Warning, {} is not an edge of the graph.

DrawGraphG3,style=spring

References

  

T.A. Feo, M.G.C. Resende, and S.H. Smith. A greedy randomized adaptive search procedure for maximum independent set. Operations Research, 42:860–878, 1994.

Compatibility

• 

The GraphTheory[GreedyClique] and GraphTheory[GreedyIndependentSet] commands were introduced in Maple 2019.

• 

For more information on Maple 2019 changes, see Updates in Maple 2019.

See Also

GreedyColor

IsClique

MaximumClique