The Art of Connecting the Dots with the Wolfram Language
This post written by Tim Shedelbower was originally published on the Wolfram Blog. The full post can be viewed here.
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.
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.
Included are the eight original base themes plus three feature themes found only in Graph: “LargeGraph”, “ClassicLabeled” and “IndexLabeled”.
Each theme automatically handles its own highlighting style.
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:
Spice up a graph with different colors and shapes.
Locate a specific vertex with labels.
Produce artwork suitable for one-color printing.
Gratify an artistic side with color variety.
And of course, for the sentimental, the original styles remain available.
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:
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.
Set the “ShowSolution” option to True to see the result.
Other themes provide unique styling.
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.