Wolfram Blog
Tim Shedelbower

The Art of Connecting the Dots with the Wolfram Language

April 26, 2019 — Tim Shedelbower, Visualization Developer, Algorithms R&D

Connect the dots. It was exciting to draw from number to number until the sudden discovery of a hidden cartoon. That was my inadvertent introduction to graph theory very early in school. Little did I know adults used the same concept to discover hidden patterns to solve problems, such as proving that a single crossing of seven Königsberg bridges to four land masses is not possible, but coloring a map distinctly with four colors is. These problems inspired the methods we know today as graph theory. And in honor of the work of late mathematician and connect-the-dot author Elwyn Berlekamp, we see how sophisticated this “child’s play” can be by examining the different styles and themes we can apply to graphs.

Connect the dots with Graph and PlotTheme

Graph theory has a history dating back to 1735, when the Königsberg bridge problem was proved to be not possible by Swiss mathematician Leonhard Euler. Today it touches us in many ways, from discovering the shortest route while on vacation to returning relevant links with a web search. Smooth traffic flow, efficient package delivery and reliable power grids utilize graph theory and affect our daily lives.

The Wolfram Language provides an extensive set of tools to reveal the underlying structures of a particular graph. Styling plays a significant role in the ability to analyze these graph structures easily. The PlotTheme family of themes, already used by the Wolfram Language’s visualizations and gauges, has found its way to the graph functions and provides a simple way to apply various styles.

As with any family, each member has its own unique personality. The personality of each theme was designed to help with the visual challenges that surface during graph analysis. Some themes work well locating paths in a complex graph, while others add visual excitement to an otherwise mundane graph.

How Does PlotTheme Work?

PlotTheme sets a theme for Wolfram Language visualizations. A theme is a list of option values called by a single string name.


CompleteGraph[5, PlotTheme -> "Web"]

Included are the eight original base themes plus three feature themes found only in Graph: "LargeGraph", "ClassicLabeled" and "IndexLabeled".

Graph themes

Each theme automatically handles its own highlighting style.

Highlighting themes

Which PlotTheme Should I Use?

PlotTheme does not overwhelm with an unlimited number of themes. Instead, each theme includes specific useful features.

For example, these features can help locate a path in a complex network:

Complex network

Spice up a graph with different colors and shapes.

Color and shape themes

Locate a specific vertex with labels.

Vertex labels

Produce artwork suitable for one-color printing.

Monochrome theme

Gratify an artistic side with color variety.

Color themes

And of course, for the sentimental, the original styles remain available.

Classic themes

A PlotTheme combined with GraphHighlightStyle eases the task of finding that perfect style. As illustrated here, it helps the "LargeGraph" theme reveal a path in a complex graph:

LargeGraph theme

Literally Connect the Dots with Graph and PlotTheme

This section is for those who came to this blog expecting a function to connect the dots. The function utilizes Graph and PlotTheme and is included with the downloadable notebook of this blog.

connectTheDots Minimal

 PlotTheme -> "Minimal"]

Set the "ShowSolution" option to True to see the result.

connectTheDots ShowSolution

 "ShowSolution" -> True]

Other themes provide unique styling.

connectTheDots Marketing theme

 PlotTheme -> "Marketing"]

Visually simplifying a problem with graph theory is a necessity in our world of growing complexity. Explore examples in the Wolfram Demonstrations Project to see what others have discovered. Visit the Graph Visualization and PlotTheme documentation pages to learn more.

Leave a Comment


Szabolcs Horvát

Hello Tim,

I use both Graph and HighlightGraph a lot, and it’s great to see that so much attention is given to making the styles look nice. I do love to use them. May I make a small suggestion? I would love to see GraphHighlightStyle -> “Thick” work better with all the plot themes. I use this highlight style the most, followed by DehighlightFade/DehighlightGray, which you showcase here. Speaking of that, it would be great to see DehighlightFade/DehighlightGray in the default auto-completion list for GraphHighlightStyle. After all, it seems these are the highlight styles you worked on the most!

I do love the styles you presented here, and I used many of them in the documentation of my IGraph/M package: http://szhorvat.net/mathematica/IGraphM Check out the PDF preview linked from that page.

Speaking of connecting dots, could we do it automatically? The concept of the relative neighbourhood graph was invented for this:


IGraph/M implements it, as well its generalization, beta skeletons.

Try this:

dots = GraphEmbedding@connectTheDots[pandaImage];

Then this:

IGLuneBetaSkeleton[dots, beta, PlotTheme -> "Web"],
{{beta, 1.5}, 1, 2}

Finally, while you didn’t show it here, there are a number of other very useful Graph-specific plot themes: the older GraphStyle settings. I use PlotTheme -> “ThickEdge” the most, especially when I need to colour the edges individually, and make their colours distinguishable. Colours are not easy to see on thin lines.

Posted by Szabolcs Horvát    April 26, 2019 at 10:14 am
    Szabolcs Horvát

    I forgot to include some code under the “Try this:” line, before the Manipulate.

    IGRelativeNeighborhoodGraph[dots, PlotTheme -> "ThickEdge"]

    Posted by Szabolcs Horvát    April 26, 2019 at 10:16 am
Tim Shedelbower

Szabolcs, thanks for the suggestions. We will take them into consideration.

Posted by Tim Shedelbower    April 26, 2019 at 10:53 am
Nicholas Brunk

I used the Wolfram Language to study percolation theory and the disassembly of biological virus shells. We were able to successfully predict in vitro experimental results on the disassembly of Hepatitis B Virus shells in the following (2) papers:



So Mathematica graph theory functionality may be used to study percolation theory.

An efficient function to determine the percolation thresholds of graphs would be a useful feature in future releases!

Posted by Nicholas Brunk    April 26, 2019 at 3:57 pm

Leave a comment