Wolfram Computation Meets Knowledge

The Art of Connecting the Dots with the Wolfram Language

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.


Join the discussion

!Please enter your comment (at least 5 characters).

!Please enter your name.

!Please enter a valid email address.


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

  2. 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.

  3. 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!

  4. Tim, I’d like to suggest that when you design these styles, also consider what graphs look like in small sizes. When the graphs are in a list, they are displayed in smaller size.

    I find PlotTheme -> “Minimal” to produce very readable renderings at small sizes for undirected graphs. But directed graphs are practically unreadable because the arrowheads are too small.

    Here’s an example:

    Table[DirectedGraph[CompleteGraph[5], “Random”,
    PlotTheme -> “Minimal”], {6}]

    It would be useful if the arrowheads did not scale with the rest of the graph. This is already the case with the default style, and should be implementable for Minimal as well.

  5. Szabolcs, thanks for the suggestion. Custom arrows scale with graph size but the size can be set manually using EdgeShapeFunction->GraphElementData[“ShortUnfilledArrow”, “ArrowSize”->.075]. We make design decisions based on a variety of graph sizes and densities but unfortunately not able to cover all cases. Manual adjustment covers these cases.