4
$\begingroup$

I am trying to graphically visualize a sort of a transformation network. My program generates a list of vertices and edges and I want to turn that into a visually clear graph fulfilling a few conditions:

  1. it is an undirected graph
  2. it contains loops and double edges
  3. all vertices have 1-3 edges connected to them (loop counts as 1)
  4. there are two classes of edges - paired and unpaired - this I want to represent by having the unpaired vertices on the central line and the paired ones symmetrically on both sides of the central axis.

Here is an example of one such graph (a simple one):

GraphPlot[{1 -> 2, 2 -> 3, 3 -> 2, 3 -> 3, 1 -> 4, 4 -> 1, 4 -> 5, 5 -> 6, 5 -> 7, 6 -> 8, 7 -> 8, 8 -> 9, 9 -> 9, 6 -> 10, 7 -> 11, 10 -> 12, 11 -> 12, 12 -> 12, 10 -> 13, 11 -> 14, 13 -> 15, 14 -> 15, 13 -> 13, 14 -> 14, 15 -> 15}, VertexCoordinateRules -> {1 -> {Automatic, 0}, 2 -> {Automatic, 0}, 3 -> {Automatic, 0}, 4 -> {Automatic, 0}, 5 -> {Automatic, 0}, 8 -> {Automatic, 0}, 9 -> {Automatic, 0}, 12 -> {Automatic, 0}, 15 -> {Automatic, 0}}]

simple graph

This one already contains a problem - in the middle of the picture you can see two edges on top of each other. In this case it can be fixed by fiddling with the "RepulsiveForcePower" or "StepLength" in the Method -> {"SpringElectricalEmbedding"} to produce a correct one:

fixed graph

Unfortunately, this trick does not help with trying to fix bigger, more complicated graphs where there are multiple minima resulting the spring optimization procedure (many of which are not symmetrical). Is there a way I can have better control over the final layout? Can I enforce the symmetry requirement? Can I specify the order of the vertices along the central axis without completely fixing their position? Can I move starting positions of the paired vertices? Is there a way to take a graph, move few vertices around and reoptimize it again? Ideally, can this be done the easy click&drag way? Or is there an alternative to Mathematica, where I could do this?

There are going to be labels on the vertices and the edges as well on top of the graph, so I need to be able to move the vertices in order to avoid overlaping of vertices, edges and labels and have a clear network.

Finally, so you know what I mean, here is a picture of a slightly bigger graph, that is almost ok, but I would need to swap a few vertices and move them a bit to avoid the overlaping:

bigger graph

Thank you in advance for any suggestion.

Lukas

$\endgroup$

Your Answer

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

Browse other questions tagged or ask your own question.