17
$\begingroup$

What are the pros and cons of using built-in Graph/GraphPlot (and related) types vs. types in the Combinatorica package?

$\endgroup$
  • 2
    $\begingroup$ Use built-in whenever you can, because Combinatorica is deprecated. It actually gives you this warning when you load it, and can cause shadowing of some of the built-in functions, causing conflict. $\endgroup$ – rm -rf May 6 '12 at 22:18
  • $\begingroup$ Nice question. I'd like to see a summary of virtues and drawbacks of each. $\endgroup$ – DavidC May 6 '12 at 22:19
  • $\begingroup$ Typically, I found it easier to work with labeling and styling vertices and edges with the Combinatorica graph objects. And unless I'm mistaken, there are still some operations upon graphs that are easier to do with Combinatorica than with the newer System graph objects. But as @R.M. indicates, it's better not to rely upon a deprecated package. $\endgroup$ – murray May 6 '12 at 22:51
  • 1
    $\begingroup$ Graph is a built-in type introduced in version 8. Since it's built-in, it can be quite efficient (at least in theory). It is clearly meant to replace all Combinatorica-related functionality because some of it conflicts with Combinatorica and now there is a warning message when loading Combinatorica. However, not all Combinatorica functions have a built-in equivalent (yet?) and there are still some bugs to be ironed out (I'm really hoping v9 will bring lots of improvement). To sum up: if you don't have the Combinatorica book, use Graph (the future) and fall back to C'ca when needed. $\endgroup$ – Szabolcs May 7 '12 at 13:28
  • 1
    $\begingroup$ Yet another thing: AFAIK Combinatorica has no support for graphs with unconnected vertices (I might be wrong). Graph does. GraphPlot can plot multigraphs, while Graph can't represent them. GraphPlot produces very similar layouts to Graph, but it's not always equivalent, and I still use GraphPlot on occasion. Some people (me included) don't like the Property API introduced with Graph as it's not functional, and you need to keep in mind that Graph is an atomic type that can only be accessed indirectly through this API. (It's not like other Mma expressions.) $\endgroup$ – Szabolcs May 7 '12 at 13:31
5
$\begingroup$

You should always use the built-in Graph unless there is a specific reason to use Combinatorica instead.

Valid reasons to use Combinatorica could be:

  • Working with very old code, originally written for Combinatorica
  • The need for an algorithm that is neither available as a built-in, nor in any supported package. (There are still a few of these, e.g. ListGraphs). Update: The IGraph/M package now provides replacements for many of such Combinatorica functions. As for ListGraphs, I suggest using the geng tool from the Nauty suite. It's output format, Graph6, can be read directly by Mathematica.
  • You are learning about graph theory and combinatorics from the Combinatorica Book

Problems when using Combinatorica:

  • Not supported anymore. There will be inconvenient conflicts with built-in symbols. See here for how to make this less painful. Minor compatibility problems with recent Mathematica versions could happen.
  • The documentation is lacking. The expectation is that you would buy the Combinatorica Book.
  • Performance is not great. All functions are implemented purely in Mathematica. (On the upside: you can read the source code, and the algorithms/implementations are explained in the Combinatorica Book.) Because of this is not suitable for "network science" type applications. It is meant for (mathematical) graph theory.

Here's the guide on replacing Combinatorica with builtin functionality:

The GraphUtilities` package contains the ToCombinatoricaGraph function which can convert a built-in Graph expression to a Combinatorica`Graph, in case you need some algorithms from Combinatorica.


A for GraphPlot, it is purely for visualization, and almost all of its functionality is already built into Graph.

|improve this answer|||||
$\endgroup$
3
$\begingroup$

I guess it also depends on your data. In my work, I do use the Laplacian for my research which can be, in principle, related to the adjacency matrix. In order to "visualize" my network I use the following:

GraphPlot[LaplacianMatrix]

Since I don't want to do an additional transformation Laplacian -> Adjacency Matrix (it takes time), I never use Graph as well as Combinatorica` for such stuff.

|improve this answer|||||
$\endgroup$
  • $\begingroup$ I wouldn't say that GraphPlot supports Laplacian matrices. Instead, it simply ignores signs, self-loops and multi-edges by default. You could do SimpleGraph@AdjacencyGraph@Abs[lm] instead, or define laplacianGraph = SimpleGraph @* AdjacencyGraph @* Abs. $\endgroup$ – Szabolcs May 2 '18 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.