Jaap's Puzzle Page

Lights Out on a Graph

Written by Jaap Scherphuis © 2004-2012.

The program may be freely used or adapted for use on any other website provided that its copyright message remains intact and a link is given to this page, or to Jaap's Puzzle Page. The program may not be sold.

If the applet doesn't work, it may be that you need to install a more recent version of Java. You can go to www.java.com to get it.

   Executable jar file
   source files

Send any comments or suggestions to .

Launch the Lights Out on a Graph Applet

The game of Lights Out consists of a set of buttons that have lights in them. Each time you press a button, not only does its own light switch on or off, so do the lights in all the neighbouring buttons. Traditionally the game is played on a square grid of buttons, usually 5×5, but other shapes are possible too. This Java applet allows you to design, analyse, and play any variation you like.

With this applet you can play Lights Out on any graph. The nodes of the graph represent buttons/lights, and the edges join any two buttons that are considered neighbours.

How to use the applet:

The program has three tabs named Edit, Analyse, and Play, as well as a File menu.


Here you can design the graph which you want to analyse or play the game.

Add a button/light:Hold down the Ctrl key and click on where you want the button to be.
Add an edge:Hold down the Shift key and then click and drag from one button/light to another.
Remove a button/light:Hold down the Alt key and then click on the button/light to remove.
Remove an edge:Hold down the Alt key and then click on the edge to remove.
Rearrange buttons:Drag a button/light to where you want it.
Move graph:Drag the background to slide the graph around the screen.
Zoom In/Out:Click the + or - buttons at the top right.
Hide arrows:Select this if you want the edges to not have arrow heads on them.
Hide loops:Select this if you want the reflexive buttons to not show edge loops going from/to themselves.
Snap to grid:Select this if you want new or moved buttons to be located on the grid intersections.
Reflexive:Select this if newly created buttons should be reflexive by default.
Symmetric:Select this if newly created edges should be symmetric by default.
Centralise view:Shifts the graph to the centre of the screen and zooms out to show the whole graph.
Clear:Deletes the whole graph.
Add shortest edge:Adds the shortest possible missing edge to the graph.
Remove longest edge:Removes the longest edge from the graph.
Make all (un)reflexive:Makes all nodes reflexive, and if clicked again it makes all nodes unreflexive.
Number of colours:Number of colours that the lights cycle through. Default is 2 (lights are on/off).
Description:A textual description can be entered into the text field above the graph.


On this screen the program shows some analysis of the lights out game on your graph. If there are any 'quiet patterns' a.k.a. null-space elements, then you can view them by moving the slider bar.


Change a light:Click any node in the graph to press its button.
Reset:Switches all the lights off.
Mix:Produces a random solvable pattern of lights.
Solve:Creates an optimal solution to the current light pattern and shows it.
Edit/Play:Click Edit for edit mode where clicking a node changes only its own light. Click Play for play mode, where button clicks affect all their neighbours.
Hide solution:Click this to show/hide a solution to the current position. This may not remain optimal as the game progresses.

File menu

The File menu has the following options:
New:Creates a new empty graph.
Upload:Uploads your graph to the server, sharing it with all other users of this program. A password can be provided so that no one else can edit it.
Download:Downloads any of the available graphs files from the server.
Remove:Removes any of the graphs files from the server.

Note that the password protection is rather trivial, so do not use a password that you use anywhere else. Note also that the server file name must consist only of letters, numbers and underscores.

If you run this program as an applet within your browser, then it has limited permissions to change things on your computer. The File menu will then have only the options above. If you run the program from the executable jar file outside your browser as a stand-alone application, then the File menu will have the following additional options:

Open:Opens a previously saved graph file.
Save:Saves any changes you have made in the current graph.
Save As:Saves the current graph to a file, with a file name of your choice.
Exit:Exits the program.

Possible future enhancements:


Send any comments or suggestions to .