# Visualizing the output of a Voronoi diagram computation

I need to plot a graph (to be specific: Fortune Algorithm output) with given vertex coordinates and a few unconnected vertices. I am thinking of using Mathematica for that.

GraphPlot does much of the task with VertexCordinateRules option but does not plot unconnected points.

1. So is there any way to do this?
And it would be even nicer if that graph comes with 2-D Axes. I was thinking to use ListLinePlot and Point commands but they give two different graphs as output.

2. Is there any option for combining output from two graphs? (The Show command didn't help.)

• What version do you have? In version 8 you can use Graph instead of GraphPlot. Is your aim to construct an actual graph, or do you merely want to plot the result (and don't want to use it in a graph-context)? Apr 25, 2012 at 13:17
• I do have version 8, but Graph command doesn't seems to plot unconnected vertices. I don't think Computational geometry package will be helpful as I am looking for visualization only. Apr 25, 2012 at 17:11
• Actually, using adjacency matrix and graph plot I am able to plot unconnected vertices but the sense of Voronoi diagram is lost as graph plot does not follow coordinates systems(i.e. no directional or distance correctness). Apr 25, 2012 at 17:42
• @samikaran-theequation Just post a sample input dataset (in the format you have it in in Mathematica) and I'll show you how. Apr 25, 2012 at 18:54
• the option i was looking for is UndirectedEdge[] in graph command. :) Apr 26, 2012 at 0:41

I didn't quite follow the description of your graph, but are you aware of this functionality?:

data = MapIndexed[Flatten[{##}] &, RandomReal[1, {100, 2}]];

ListDensityPlot[
data,
InterpolationOrder -> 0,
ColorFunction -> Hue,
Mesh -> All,
Epilog -> Point@data[[All, {1, 2}]]
]


Specifically note InterpolationOrder -> 0.

• The ComputationalGeometry package has Voronoi diagrams as well. I think he's looking to visualize them only, not to compute them (suppose you'd make your own program for computing them, for whatever reason, then you need to visualize the result quickly) Apr 25, 2012 at 13:16
• You're not very active lately, what happened? I'm hoping for the glorious return of Spartacus! :D Apr 25, 2012 at 13:18
• Yup, I am looking just to plot my result of Voronoi diagram and not to compute them. Lets say; a={1,2};b={4,2};c={3,0};d={3,7}. So is there a way to plot an edge(c,d) and points a and b? Apr 25, 2012 at 17:05
• @Szabolcs other hobbies. :-) Apr 25, 2012 at 17:56
• Do you mean something like this? Graph[{a, b, c, d}, {UndirectedEdge[c,d]}, VertexCoordinates -> {{1, 2}, {4, 2}, {3, 0}, {3, 7}}] Apr 25, 2012 at 22:57

Here is a nice clean way to both compute and plot the Voronoi diagram with some undocumented functions:

GraphicsRegionRegionInit[];


Then:

pts = RandomReal[6, {100, 2}];

Show[GeometryPlot[VoronoiMesh[pts], Mesh -> All,
PlotStyle -> {Opacity[0.3], Yellow},
MeshStyle -> {Darker@Green, Dashed}], Graphics[{Red, Point[pts]}]]


Now in Mathematica 10, VoronoiMesh is a standard built in function.

pts=RandomReal[{-1,1},{25,2}];
Show[VoronoiMesh[pts]
,Graphics[{Red,Point[pts]}]
,Frame-> True
]


• +1. I'm curious as no example was shown in the documentation. Does VoronoiMesh compute 3D Voronoi diagrams? May 18, 2014 at 22:08
• @RunnyKine tks. I see 3D in DelaunayMesh but not for VoronoiMesh. Maybe under implementation. May 18, 2014 at 22:14