Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April...
Transcript of Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April...
![Page 1: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/1.jpg)
SolvingSolvingSolvingSolvingGraph Problems with Graph Problems with pp
Boolean MethodsBoolean Methods
Randal E. BryantCarnegie Mellon UniversityCarnegie Mellon University
http://www.cs.cmu.edu/~bryant
![Page 2: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/2.jpg)
The Graph Coloring ProblemThe Graph Coloring ProblemColor the regions of a planar graphColor the regions of a planar graph
Use only 4 colors Use only 4 colors No two adjacent regions can have the same color
Example: Color the states of a U.S. map Example: Color the states of a U.S. map
![Page 3: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/3.jpg)
The MacGregor GraphThe MacGregor GraphScientific American, Scientific American,
April 1975April 1975April 1975April 1975 Said to be proof that
some planar graphssome planar graphs could not be colored with just 4 colors
An April-fool’s joke, but still difficult to solve by handhand
![Page 4: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/4.jpg)
Boolean SAT SolversBoolean SAT SolversWhat They DoWhat They Do
Express problem as a set of constraints Search for solution that satisfies all constraints
Encoding Graph Coloring with SATEncoding Graph Coloring with SAT Encode each region with two 0/1-valued variables:
00 Bl 00 Blue 01 Green 10 Red 11 Yellow
For each adjacent region, require at least one of the corresponding variables to have oppositethe corresponding variables to have opposite values
![Page 5: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/5.jpg)
Encoding Coloring ConstraintsEncoding Coloring Constraints
ai, bi aj, bj
Encode region i with variables ai, bi
For adjacent regions i and j, want:ai ≠ aj bi ≠ bj
Clausal form (and of or’s):
(c ai aj) (c ai aj) (c bi bj) (c bi bj)
c = 0 ai ≠ aj
c = 1 bi ≠ bj
![Page 6: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/6.jpg)
The ZChaff SAT SolverThe ZChaff SAT Solver From Princeton University
Al ith b D i P t L & L l d Algorithm by Davis Putnam Logemann & Loveland With many refinements
Based on backtracking searchBased on backtracking search Try assigning values to variables When hit contradiction
Create new constraint encoding conflict Backtrack by undoing some of the most recent assignments Resume search with new variable assignments
![Page 7: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/7.jpg)
Visualizing the Search ProcessVisualizing the Search Process
Black: Neither variable assigned valueSi l l B th i bl i d i i Single color: Both variables assigned, giving unique color.
Blended colors: One variable assigned, the otherBlended colors: One variable assigned, the other unassigned, indicating two possible colors
YouTube: http://www.youtube.com/watch?v=0gt503wK7AI
![Page 8: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/8.jpg)
![Page 9: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/9.jpg)
The Final ResultThe Final Result
![Page 10: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/10.jpg)
Another SolutionAnother Solution
Minimum use of greeen Minimum use of greeen(7 times)
![Page 11: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/11.jpg)
Try It YourselfTry It Yourself
Color the rest of the map using 3 colors
![Page 12: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/12.jpg)
Minimum Colorings of US MapMinimum Colorings of US Map
Only need to use green twice
![Page 13: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/13.jpg)
Odd CyclesOdd Cycles
C thi b l d ithCan this be colored with just 3 colors?
![Page 14: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/14.jpg)
Odd Cycles in US MapOdd Cycles in US Map
![Page 15: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/15.jpg)
Overlapping Odd CyclesOverlapping Odd Cycles
![Page 16: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/16.jpg)
Breaking Odd CyclesBreaking Odd Cycles
![Page 17: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/17.jpg)
Viewing Maps as GraphsViewing Maps as Graphs
48 nodes105 edges
![Page 18: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/18.jpg)
Coloring a GraphColoring a Graph
![Page 19: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/19.jpg)
The Macgregor GraphThe Macgregor Graph
110 nodes324 edges
![Page 20: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/20.jpg)
The Four Color TheoremThe Four Color Theorem Can color any planar graph with just 4 colors.
HistoryHistory Conjectured in 1852 1890: it was shown that 5 colors would suffice 1976: Appel & Haken claimed they had proof
![Page 21: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/21.jpg)
Proof of Four Color TheoremProof of Four Color Theorem
Proof MethodProof MethodAppel & Haaken showed there were 1,936
graphs that covered all possibitiesWrote computer program to check all of themWrote computer program to check all of them
ReactionReactionMany mathematicians didn’t like this kind of
proofP h b itt d h k d Program has been rewritten and rechecked multiple times, and so the proof is generally accepted.p
![Page 22: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/22.jpg)
Coloring Other Graph TypesColoring Other Graph TypesSphere: same as planeSphere: same as plane
Plane sphere Reduce exterior edges to points Reduce exterior edges to points
Sphere planeSphere plane Cut hole and stretch out flat
![Page 23: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/23.jpg)
Coloring A TorusColoring A TorusTorusTorus
7 colors necessary 7 regions, each with g ,
6 neighbors
Also sufficient
![Page 24: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/24.jpg)
Torus: An Infinite Wallpaper PatternTorus: An Infinite Wallpaper PatternPatternPattern
![Page 25: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/25.jpg)
Sudoku as a Graph Coloring ProblemSudoku as a Graph Coloring ProblemProblemProblem
3 9 6 7 4 1 2 5 8 3 9 6 7 4 1 2 5 88 5 7 2 3 9 1 4 61 2 4 5 8 6 7 9 35 7 1 6 2 3 9 8 4
9 88 5 7 2 3 9 1 4 61 2 4 5 8 6 7 9 35 7 1 6 2 3 9 8 45 7 1 6 2 3 9 8 4
6 8 3 4 9 7 5 1 29 4 2 1 5 8 3 6 7
5 7 1 6 2 3 9 8 46 8 3 4 9 7 5 1 29 4 2 1 5 8 3 6 7
2 3 9 8 1 4 6 7 54 6 5 9 7 2 8 3 17 1 8 3 6 5 4 2 9
2 3 9 8 1 4 6 7 54 6 5 9 7 2 8 3 17 1 8 3 6 5 4 2 9
![Page 26: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/26.jpg)
Adding ColorsAdding Colors
1 3 9 6 7 4 1 2 5 823
8 5 7 2 3 9 1 4 61 2 4 5 8 6 7 9 3
45
5 7 1 6 2 3 9 8 46 8 3 4 9 7 5 1 29 4 2 1 5 8 3 6 76
7
9 4 2 1 5 8 3 6 72 3 9 8 1 4 6 7 54 6 5 9 7 2 8 3 18
9
4 6 5 9 7 2 8 3 17 1 8 3 6 5 4 2 9
![Page 27: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/27.jpg)
Taking Away NumbersTaking Away Numbers3 9 6 7 4 1 2 5 88 5 7 2 3 9 1 4 68 5 7 2 3 9 1 4 61 2 4 5 8 6 7 9 35 7 1 6 2 3 9 8 45 7 1 6 2 3 9 8 46 8 3 4 9 7 5 1 29 4 2 1 5 8 3 6 72 3 9 8 1 4 6 7 54 6 5 9 7 2 8 3 17 1 8 3 6 5 4 2 9
![Page 28: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/28.jpg)
Graph Structure of SudokuGraph Structure of Sudoku
1 3 4 21 3 4 2
4 2 1 34 2 1 3
2 4 3 12 4 3 1
3 1 2 43 1 2 44 X 4 Sudoku Column constraints
![Page 29: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/29.jpg)
Graph Structure of SudokuGraph Structure of Sudoku
1 3 4 21 3 4 2
4 2 1 34 2 1 3
2 4 3 12 4 3 1
3 1 2 43 1 2 44 X 4 Sudoku Row constraints
![Page 30: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/30.jpg)
Graph Structure of SudokuGraph Structure of Sudoku
1 3 4 21 3 4 2
4 2 1 34 2 1 3
2 4 3 12 4 3 1
3 1 2 43 1 2 44 X 4 Sudoku Block constraints
![Page 31: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/31.jpg)
Graph Structure of SudokuGraph Structure of Sudoku
1 3 4 21 3 4 2
4 2 1 34 2 1 3
2 4 3 12 4 3 1
3 1 2 43 1 2 44 X 4 Sudoku
16 nodesAll constraints
56 edges16 nodes 56 edges
9 x 9 Sudoku: 81 nodes, 810 edges
![Page 32: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/32.jpg)
Visualizing Solution ProcessVisualizing Solution Process
![Page 33: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/33.jpg)
Visualizing Solution ProcessVisualizing Solution Process
![Page 34: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/34.jpg)
Solving A Sudoku PuzzleSolving A Sudoku Puzzle
![Page 35: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/35.jpg)
Touring the USTouring the US
![Page 36: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/36.jpg)
Touring the USTouring the US
![Page 37: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/37.jpg)
Weighted US GraphWeighted US Graph
Shortest driving distances between capitol cities Staying within source and destination states Staying within source and destination states Computed by Don Knuth using Mapquest
![Page 38: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/38.jpg)
A Capitol TourA Capitol TourA Hamiltonian Path
15 136 il (24 359 k ) t t l15,136 miles (24,359 km) total68,656,026 possible tours
![Page 39: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/39.jpg)
Limiting Node DegreeLimiting Node Degree
![Page 40: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/40.jpg)
A Spanning TreeA Spanning Tree
![Page 41: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/41.jpg)
The Shortest Capitol TourThe Shortest Capitol Tour
11,698 miles (18,826 km) total
A Traveling Salesman Path
![Page 42: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/42.jpg)
The Longest Capitol TourThe Longest Capitol Tour
18,040 miles (29,033 km) total
![Page 43: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/43.jpg)
Two Interesting Capitol ToursTwo Interesting Capitol Tours
![Page 44: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/44.jpg)
Two Interesting Capitol ToursTwo Interesting Capitol Tours
3 time changes 19 time changes
![Page 45: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/45.jpg)
Touring MacGregorTouring MacGregorA Hamiltonian Cycle
![Page 46: Solving Graph Problems with Boolean Methods...The MacGregor Graph Scientific American, April 1975April 1975 Said to be proof that some planar graphssome planar graphs could not be](https://reader035.fdocuments.us/reader035/viewer/2022070920/5fb9313157c51809df7452d2/html5/thumbnails/46.jpg)
Lessons LearnedLessons LearnedGraph ColoringGraph Coloring
Maps are a kind of graph Sudoku is a graph coloring problem
Hamiltonian PathsHamiltonian Paths Find a path in graph that goes through every node
once Considered a difficult problem
Boolean MethodsBoolean Methods Can encode wide variety of graph problems Can find solution using SAT solver In worst case, has exponential performance
But gets solution for many interesting problems