# Version 9 - delete edge from Delaunay Graph

I have a problem with subgraph in Mathematica 9. In Ver10 the below code works :

(****************************************************)
dist = 1.1;(*when the distance is grather then dist edge is deleted*)
a = {0, 1, 2 I};
coordReal = {Re@#, Im@#} & /@ a;
N=Length[a];
Do[
Do[If ABS{[a[[j]]-a[[i]]] > dist,
planar[[j, i]] = 0],
{i,1,N}],
{j,1,N}];
GraphPlot[planar, VertexLabeling -> False,   VertexCoordinateRules -> coord]
(**************************************************)


Is a way to use this method in Mathematica Ver9?

It helps to use proper syntax. For example, N is a built-in symbol and cannot be overwritten. Moreover, it is Abs not ABS and all kinds of bracketing have to match. The following seems to work.

dist = 1.1;
a = {0, 1, 2 I};
coordReal = {Re@#, Im@#} & /@ a;
n = Length[a];
Do[
If[Abs[a[[j]] - a[[i]]] > dist, planar[[j, i]] = 0],
{i, 1, n}, {j, 1, n}];
GraphPlot[planar, VertexLabeling -> False, VertexCoordinateRules -> coordReal]


# Edit

In version 9, the issue is that MeshRegion and DelaunayMesh are absent because they were only introduced in version 10.0. The now superseded package "ComputationalGeometry" provides a functionDelaunayTriangulation that returns the vertex adjacency list of the Delaunay triangulation. From this, the adjacency matrix can be built as follows.

Needs["ComputationalGeometry"];
planar = SparseArray[Join @@ Thread /@ DelaunayTriangulation[coordReal] -> 1];


The rest should work. Notice however that GraphPlot has also been updated with version 10; since I am running version 11.3, I cannot test it.

• Thank you for quick answer!
– Olaf
Jan 11, 2019 at 9:58
• You're welcome. Jan 11, 2019 at 10:00
• Did you use Normal for output ony or did it make any deeper sense?. Without it works good too. Regards, Olaf.
– Olaf
Jan 11, 2019 at 10:24
• No special purpose. I was expecting that you are more familiar with conventional matrices than with SparseArrays. Whenever you have a graph with $n$ vertices and $m$ edges with $m \ll n^2$, then using a SparseArray for the adjacency matrix is actually preferable because it uses only $n + 2 m$ instead of $n^2$ memory. Jan 11, 2019 at 10:32