Download presentation
Presentation is loading. Please wait.
1
Michael Codish, Michael Frank, Amit Metodi
Logic Programming with Max-Clique and its Application to Graph Coloring morad muslimany Ben-Gurion University of the Negev Joint work with: Michael Codish, Michael Frank, Amit Metodi
2
Logic Programming with Max-Clique and its Application to Graph Coloring
We will present pl-cliquer, a Prolog interface to the cliquer tool for the maximum clique problem. Agenda: Problem definitions and examples pl-cliquer Usage examples Experiments
3
Cliques, Maximum Cliques
A clique in a graph πΊ=(π,πΈ) is a set πΆβπ of pairwise adjacent vertices (β π£ 1 , π£ 2 βπΆ: π£ 1 , π£ 2 βπΈ) The maximum clique problem is about finding the largest clique in the graph
4
Cliques, Maximum Cliques
A clique in a graph πΊ=(π,πΈ) is a set πΆβπ of pairwise adjacent vertices (β π£ 1 , π£ 2 βπΆ: π£ 1 , π£ 2 βπΈ) The maximum clique problem is about finding the largest clique in the graph
5
Graph Coloring The problem of graph coloring is to find a labeling π:πβπ of the vertices of the graph such that π,π βπΈβπ π β π(π). The minimal graph coloring problem is to color the graph while using as few colors as possible. This number is called the Chromatic Number of the graph.
6
Graph Coloring The problem of graph coloring is to find a labeling π:πβπ of the vertices of the graph such that π,π βπΈβπ π β π(π). The minimal graph coloring problem is to color the graph while using as few colors as possible. This number is called the Chromatic Number of the graph.
7
Cliques and colorings Finding cliques is tremendously useful in the problem of Graph Coloring It is easy to show that the chromatic number of a graph πΊ, π(πΊ), is greater than or equal to the size of the maximum clique, as all clique vertices must get different colors.
8
Hardness of these problems
The clique decision problem (is there a clique of size β€π in a graph) is NP-Complete Subsequently, the problem of finding a maximum clique is also NP-Hard. The graph coloring decision problem is NP- Complete In particular, the minimal graph coloring problem is NP-Hard
9
Hard but solvable in practiceβ¦
Although the problem of maximum-clique is NP-Hard, it is solvable in practice in many graphs by various tools Cliquer is one such tool, which is a set of C routines for finding cliques in a graph
10
Logic Programming with Max-Clique and its Application to Graph Coloring
We will present pl-cliquer, a Prolog interface to the Cliquer tool for the maximum clique problem. Agenda: Problem definitions and examples pl-cliquer Usage examples Experiments
11
pl-cliquer We have written an interface that connects Cliquer with SWI-Prolog, called pl-cliquer Provides five high-level predicates, and we will focus on the following three: graph_read_dimacs_file/5 clique_find_single/4 clique_find_n_sols/6
12
graph_read_dimacs_file(FileName,NVert,Weights,Graph,Options)
Converts a graph in the standard DIMACS format to a Prolog representation as a Boolean adjacency matrix. Running example graph: FileName (content) NVert Weights Graph Options graph_read_dimacs_file(FileName,NVert,Weights,Graph,Options)
13
graph_read_dimacs_file(FileName,NVert,Weights,Graph,Options)
Converts a graph in the standard DIMACS format to a Prolog representation as a Boolean adjacency matrix. Running example graph: 7 FileName (content) NVert Weights Graph Options graph_read_dimacs_file(FileName,NVert,Weights,Graph,Options)
14
clique_find_single(NVert,Graph,Clique,Options)
Provides an interface to the Cliquer routine by the same name. Finds a single clique in the graph. 7 NVert Graph Clique Options clique_find_single(NVert,Graph,Clique,Options)
15
clique_find_single(NVert,Graph,Clique,Options)
Provides an interface to the Cliquer routine by the same name. Finds a single clique in the graph. 7 NVert Graph Clique Options clique_find_single(NVert,Graph,Clique,Options)
16
clique_find_n_sols(MaxSols,NVert,Graph,Sols,Total,Options)
Allows finding several cliques in a graph. min_weight(3) max_weight(4) maximal(false) 10 7 MaxSols NVert Graph Sols Total Options clique_find_n_sols(MaxSols,NVert,Graph,Sols,Total,Options)
17
clique_find_n_sols(MaxSols,NVert,Graph,Sols,Total,Options)
Allows finding several cliques in a graph. min_weight(3) max_weight(4) maximal(false) 10 7 6 MaxSols NVert Graph Sols Total Options clique_find_n_sols(MaxSols,NVert,Graph,Sols,Total,Options)
18
Logic Programming with Max-Clique and its Application to Graph Coloring
We will present pl-cliquer, a Prolog interface to the cliquer tool for the maximum clique problem. Agenda: Problem definitions and examples pl-cliquer Usage examples Experiments
19
Solving the Graph Coloring Problem
We model the problem using a constraint language (BEE) The constraints model is then compiled to SAT using the BEE compiler (written in Prolog) The SAT instance is solved using a SAT solver via the Prolog interface (BEE allows a variety of solvers at its backend) The satisfied SAT instance assignment is decoded back to a graph coloring
20
Main Predicate We model the problem using a constraint language (BEE)
The constraints model is then compiled to SAT using the BEE compiler (written in Prolog) The SAT instance is solved using a SAT solver via the Prolog interface (BEE allows a variety of solvers at its backend) The satisfied SAT instance assignment is decoded back to a graph coloring
21
?- graphColoring(Graph,5,Coloring)
Example Can we solve our running example with 5 colors? ?- graphColoring(Graph,5,Coloring)
22
Example graphColoring(Graph, 5, Coloring)
23
?- graphColoring(Graph,5,Coloring)
Example ?- graphColoring(Graph,5,Coloring)
24
pl-cliquer & graph coloring
As well known, the maximum clique vertices can be preassigned different colors
25
pl-cliquer & graph coloring
As well known, the maximum clique vertices can be preassigned different colors
26
pl-cliquer & graph coloring
27
Example β with pl-cliquer
graphColoring(Graph,5,Coloring)
28
Logic Programming with Max-Clique and its Application to Graph Coloring
We will present pl-cliquer, a Prolog interface to the cliquer tool for the maximum clique problem. Agenda: Problem definitions and examples pl-cliquer Usage examples Experiments
29
DIMACS Benchmarks β Selected Results
With pl-cliquer and clique symmetry breaks Without pl-cliquer Instance Colors Cliquer Time BEE Time Clauses Vars SAT Time queen9_9 10 0.01 0.06 12026 547 6.91/sat myciel5 5 1170 195 0.85/unsat fpsol2.i.1 65 0.02 0/sat(BEE) school1_nsh 13 26.6 0/unsat(cl) BEE Time Clauses Vars SAT Time 0.06 24927 891 14.36/sat 0.01 1697 235 109.24/unsat 2.26 17781 1.87/sat 0.67 216343 4711 793.22/unsat
30
Toronto Benchmarks β Selected Results
With pl-cliquer and clique symmetry breaks Without pl-cliquer Instance Colors Cliquer Time BEE Time Clauses Vars SAT Time pur-s-93 31 0.5 2.85 39613 3.36/sat 30 2.77 37849 1.44/unsat car-s-91 27 0.06 1.93 407155 12672 /sat car-f-92 0.2 1.15 179749 7634 0.73/sat BEE Time Clauses Vars SAT Time 14.43 71911 17.6/sat 7.18 70275 >86400 2.5 19897 2.6 713441 15616 4.35/sat
31
Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.