1
$\begingroup$

I would like to begin by congratulating IGraphM on the release of its current update (M 0.6.1). This package makes graph calculations on Mathematica much smoother.

The specifics are available at the following web address:

As the author szhorvat says,

The IGraph/M package provides a Wolfram Language interface to the popular igraph network analysis and graph theory library, as well as many other useful functions for working with graphs in Mathematica.

igraph is known to be a C++ library. It offers numerous functions related to the calculation of graph parameters. However, its graph layout functions are currently limited.

I've seen that ogdf, (also a c++ library), has more advantages in the drawing and layout domains of network.

I have not had a positive experience with ogdf due to my lack of familiarity with c++ (though I plan to learn c++ in the future). Python has an interface of ogdf, but installing ogdf requires more than a single click (this requires a local build of the ogdf and it beat me). Below is an example of Python utilising odgf (https://pypi.org/project/ogdf-python/).

# uncomment if you didn't set this globally:
# %env OGDF_BUILD_DIR=~/ogdf/build-debug
from ogdf_python import ogdf, cppinclude
cppinclude("ogdf/basic/graph_generators/randomized.h")
cppinclude("ogdf/layered/SugiyamaLayout.h")

G = ogdf.Graph()
ogdf.setSeed(1)
ogdf.randomPlanarTriconnectedGraph(G, 20, 40)
GA = ogdf.GraphAttributes(G, ogdf.GraphAttributes.all)

for n in G.nodes:
    GA.label[n] = "N%s" % n.index()

SL = ogdf.SugiyamaLayout()
SL.call(GA)
ogdf.GraphIO.drawSVG(GA, "sugiyama-simple.svg")
GA

enter image description here

odgf is not only good at laying out graphs, but it also has many functions related to geometric graph theory. For example, it can calculate the crossing number of a given graph and figure out whether or not it is 1-planar. So it would be very exciting if ogdf has an interface to Mathematica like igraph in the future.

$\endgroup$
9
  • 11
    $\begingroup$ Yes, of course it can be done, but it is a lot of work, and someone has to take the time. Specifically regarding graph drawing: One problem with integrating non-trivial layout algorithms into Mathematica is that there is no way to route edges. Mathematica's own built-in layout functions can set not only vertex coordinates, but also a specific path for each edge, as a list of point. This list of points is then passed to the EdgeShapeFunction to render the edge. However, this functionality cannot be access by users. I have requested it to be publicly exposed several times ... $\endgroup$
    – Szabolcs
    Commented Jul 18, 2022 at 10:49
  • 5
    $\begingroup$ ... years ago, but I never received any feedback about this from Wolfram. This is why IGraph/M does not expose igraph's Sugiyama layout. $\endgroup$
    – Szabolcs
    Commented Jul 18, 2022 at 10:50
  • 6
    $\begingroup$ BTW Mathematica does include the Sugiyama layout as LayeredDigraphEmbedding: Graph[{1 -> 2, 1 -> 3, 2 -> 3}, GraphLayout -> "LayeredDigraphEmbedding"]. Notice that this produces curved edges that avoid collisions with vertices. It is this type of layout that is impossible to set on a Graph expression manually. You can also contact Wolfram and request that they finally add this feature. If they suggest using a custom EdgeShapeFunction, tell them that this comes with severe drawbacks: we won't be able to customize other aspect of edge shapes! $\endgroup$
    – Szabolcs
    Commented Jul 18, 2022 at 10:53
  • 6
    $\begingroup$ The edge route and the the edge rendering should be separated. The former is not user-accessible, the latter can be done with EdgeShapeFunction. $\endgroup$
    – Szabolcs
    Commented Jul 18, 2022 at 10:53
  • 1
    $\begingroup$ Yes, the prebuilt binary is Linux-only at the moment. There is currently a bug in the Python-C++ interface library I'm using, which prevents usage of ogdf-python on Windows as a whole. As soon as that bug is resolved, I'll push binaries for all OSes. $\endgroup$
    – NCode
    Commented Oct 17, 2022 at 16:09

0