# Conditions for VertexCoordinateRules in GraphPlot3D

Is there a way to impose various conditions on the positions of the vertices when embedding a graph using GraphPlot3D? More precisely, I have a graph g, which I want to embed using GraphPlot3D in such a way that several vertices have $z$ coordinate with $z=0$ and the other vertices have $z$ coordinate with $z \geq 0$.

In the following example, I get the $z=0$ condition for the first $4$ vertices, but I can't manage to impose the $z \geq 0$ condition for the others.

graph = {1 -> 2, 2 -> 3, 3 -> 4, 4 -> 5, 1 -> 5, 1 -> 3, 1 -> 4, 2 -> 6, 3 -> 6, 1 -> 6, 1 -> 7, 2 -> 7, 6 -> 8, 1 -> 8, 5 -> 9, 1 -> 9, 4 -> 9, 4 -> 10, 5 -> 10, 9 -> 10, 9 -> 11, 4 -> 11, 4 -> 14, 9 -> 14, 9 -> 15, 11 -> 15, 11 -> 14};

rules = Join[Table[i -> {Automatic, Automatic, 0}, {i, 1, 4}], Table[i -> {Automatic, Automatic, Automatic}, {i, 5, 16}]];

GraphPlot3D[graph, VertexCoordinateRules -> rules, Method -> "SpringElectricalEmbedding"]


• Do you want the $z\geq 0$ to be any number, or some in particular? – corey979 Sep 24 '16 at 14:47
• I want the $z \geq 0$ to be any number. – Gagar Sep 24 '16 at 14:50
• Then maybe just rules = Join[Table[i -> {Automatic, Automatic, 0}, {i, 1, 4}], Table[i -> {Automatic, Automatic, RandomReal[1]}, {i, 5, 16}]];? – corey979 Sep 24 '16 at 14:51
• Sorry I wasn't clear enough: I do not want to constrain the $z$ coordinate to be some number, I want it to be determined by the SpringElectricalEmbedding. In other words, I would like to have "Automatic" replaced by "Automatic but nonnegative". – Gagar Sep 24 '16 at 14:53
• Can the negative $z$ from your GraphPlot3D be simply transformed to $|z|$? – corey979 Sep 24 '16 at 15:08

I finally found a way to this by using the Python library igraph with the embedding igraph_layout_fruchterman_reingold_3d (thanks to the $maxz$ and $minz$ options) and by executing a Python script in Mathematica thanks to the first answer of Is there a way to run Python from within Mathematica? !