Hashi in a Graph-Theoretic Model

36
Hashi in a Graph- Theoretic Model Ben Warren

description

Hashi in a Graph-Theoretic Model. Ben Warren. What is Hashi?. Single-player puzzle invented in Japan. “Hashi” is short for the Japanese name, “hashiwokakero”, meaning “build bridges”. The player is given a puzzle key, and seeks to construct a unique solution according to certain simple rules. - PowerPoint PPT Presentation

Transcript of Hashi in a Graph-Theoretic Model

Page 1: Hashi in a Graph-Theoretic Model

Hashi in a Graph-Theoretic Model

Ben Warren

Page 2: Hashi in a Graph-Theoretic Model

What is Hashi? Single-player puzzle

invented in Japan. “Hashi” is short for the Japanese name, “hashiwokakero”, meaning “build bridges”.

The player is given a puzzle key, and seeks to construct a unique solution according to certain simple rules.

Page 3: Hashi in a Graph-Theoretic Model

Rules of Hashi Played on an n-by-n grid,

with some spaces containing numbered islands.

The goal is to connect all of the islands with bridges such that:

All bridges run orthogonally between two distinct islands.No two bridges cross.Either 0, 1, or 2 bridges connect any two islands.The number of bridges incident on an island matches that island's number.The final puzzle solution connects all islands into a single group.

Page 4: Hashi in a Graph-Theoretic Model

Example Hashi Solution

Page 5: Hashi in a Graph-Theoretic Model

Example Hashi Solution

Page 6: Hashi in a Graph-Theoretic Model

Example Hashi Solution

Page 7: Hashi in a Graph-Theoretic Model

Example Hashi Solution

Page 8: Hashi in a Graph-Theoretic Model

Example Hashi Solution

Page 9: Hashi in a Graph-Theoretic Model

Example Hashi Solution

Page 10: Hashi in a Graph-Theoretic Model

Connection to Graph Theory

With some restrictions, it seems that hashi keys are vertex sets of an unknown solution graph with a given degree sequence. Hashi solutions seem to behave like connected planar multigraphs.

Page 11: Hashi in a Graph-Theoretic Model

Constructing a Model

In order to construct a model for hashi, we have to consider the following:

The rules of hashi depend on distances being fixed. Our model should not be “stretchable”.

The rules of hashi also demand that lines be strictly orthogonal. Our model should not be “bendable”.

We would like to force planarity for all solutions.

Page 12: Hashi in a Graph-Theoretic Model

Definitions

A unit-distance graph is a graph in which all edges are of unit length

Page 13: Hashi in a Graph-Theoretic Model

Definitions

A grid graph is a unit-distance graph which is the Cartesian product of two unit-distance path graphs.

Page 14: Hashi in a Graph-Theoretic Model

Definitions

A Hanan grid graph of a given set of vertices is the graph obtained from the intersection of all the orthogonal lines through each vertex in the set.

Page 15: Hashi in a Graph-Theoretic Model

Our Model

Page 16: Hashi in a Graph-Theoretic Model

More simply put:

We are given a hashi grid with weighted vertices.

We can construct a Hanan grid graph of all possible connections between the set of weighted vertices, such that the underlying simple graph of the hashi solution is a subgraph of the Hanan graph.

Page 17: Hashi in a Graph-Theoretic Model

Our Model in Practice:

Suppos we're given a 7x7 hashi puzzle key:

Page 18: Hashi in a Graph-Theoretic Model

Our Model in Practice:

We express the puzzle key as a 7x7 weighted unit-distance grid graph, G:

Page 19: Hashi in a Graph-Theoretic Model

Our Model in Practice:

We construct the Hanan grid graph generated by the non-zero weight vertices of G (indicated in blue):

Page 20: Hashi in a Graph-Theoretic Model

Our Model in Practice:

The hashi solution multigraph, H, has an underlying simple graph which is some subgraph of the Hanan graph of G:

Page 21: Hashi in a Graph-Theoretic Model

Our Model in Practice:

So, H can be determined as a multigraph which is a supergraph of some subset of the Hanan graph of G:

Page 22: Hashi in a Graph-Theoretic Model

Why is this model an improvement over the

“common-sense” approach?

Page 23: Hashi in a Graph-Theoretic Model

Why is this model an improvement over the

“common-sense” approach?

Page 24: Hashi in a Graph-Theoretic Model

Why not construct a better model?

It turns out, according to Andersson(2009), solving arbitrarily-sized hashi is an NP-complete problem.

This is bad news for anyone looking for a general solution to hashi.

Page 25: Hashi in a Graph-Theoretic Model

Some notes on P vs. NP In computer science,

there are different “complexity classes” of problems.

Problems in “P” can be solved in polynomial time.

Problems in “NP” can have their solutions verified in polynomial time.

All problems which are “NP-complete” are: In NP And can be reached by reducing any problem in NP.

Page 26: Hashi in a Graph-Theoretic Model

Example problems in P

Calculating greatest common divisors Determining if a given number is prime

Example problems in NPC

“Traveling salesman” problems. Determining graph colorings Sudoku Hashi

Page 27: Hashi in a Graph-Theoretic Model

So, why is hashi interesting?

Besides being fun, hashi is a good “gateway” between computer science and graph theory.

It can be expressed in the language of either, but neither has offered a complete picture.

As hashi keys grow in size, their complexity compounds in a very intuitive way.

Page 28: Hashi in a Graph-Theoretic Model

7x7

Page 29: Hashi in a Graph-Theoretic Model

10x10

Page 30: Hashi in a Graph-Theoretic Model

15x15

Page 31: Hashi in a Graph-Theoretic Model

20x20

Page 32: Hashi in a Graph-Theoretic Model

50X50

Page 33: Hashi in a Graph-Theoretic Model

70x70

Page 34: Hashi in a Graph-Theoretic Model

Questions for future research:

We're given an arbitrarily-sized hashi key whose weighted vertices generate a Hanan graph for which all possible solution subgraphs take the form of a tree graph. Does this restricted case grant us any new conclusions?

Page 35: Hashi in a Graph-Theoretic Model

Questions for future research:

Given some small integer n, can we count all isomorphic hashi keys and solutions which can be generated for an nxn hashi?

Given a vertex-weighted nxn unit distance grid graph, G, can we determine any conditions by which G absolutely is or is not a valid hashi key?

Page 36: Hashi in a Graph-Theoretic Model

Citations

Wikipedia. “Hashiwokakero#Rules.” Accessed April 29, 2011.

Nikoli Co., Ltd. “Puzzle Cyclopedia”, ISBN 4-89072-406-0

Andersson, Daniel, “Hashiwokakero is NP-Complete”

Eppstein. ICS 161: Design and Analysis of Algorithms Lecture notes for March 12, 1996: NP-Completeness. University of California, Irvine, n.d. Web. 1 May 2011.

Special thanks to:

Simon Tatham's Portable Puzzle Collection, http://www.chiark.greenend.org.uk/~sgtatham/, distributed freely under the MIT License