# Generating a (random) 2-dimensional cellular network

I want to generate a network of random cells like the following picture:

The general idea is to generate some random points (x,y) as coordinate of a vertex and then randomly choose some of these points to connect them to achieve (almost) a random cellular network since there are two constraints:

1. The length of edges is constant.
2. Degree of each vertex is 3.

Thanks,

Update

By starting from a perfect honeycomb, we perform a series of random "neighbor switching" process:

By performing successive neighbor switching, we are able to build cells with different size.

-
What have you tried? Post at least some code showing attempts: In general, this site is not intended as a "will work for free and rep. points" kind of place... – ciao Feb 25 '14 at 4:11
If you really want all edge lengths to be the same, I think you end up seeing only the three regular tilings of a plane; not very random. – kirma Feb 25 '14 at 6:41
@kirma: Only if you also constrain angles to force the polygons to be regular. Otherwise I think there is quite a bit of freedom. – Rahul Feb 25 '14 at 6:57
@rasher: I have tried to generate some vortices (x,y) by "RandomReal" function. Then I tried to choose randomly a vertex and connect that to three other vortex since degree of each vertex should be 3. I should choose those three points from neighbors which I can do that by defining a upper limit on the distance. The main problem is to keep the length of edge the same and the degree 3. – Mahdi Feb 25 '14 at 14:24
Run this then ListDensityPlot[ ArrayFlatten[{{pts, RandomReal[1, {Length[pts], 1}]}}], InterpolationOrder -> 0, Mesh -> All]. Is this what you're looking for? – Szabolcs Feb 25 '14 at 15:05

Fixing the edge length makes the problem harder. Otherwise, maybe this here gives an idea

<< ComputationalGeometry
data = .9 Flatten[
Table[{x, y} + .07 RandomReal[{-1, 1}, {2}], {x, -1,
1, .2}, {y, -1, 1, .2}], 1];
delval = DelaunayTriangulation[data];
convexHull = ConvexHull[data];
gr = DiagramPlot[data, ##, LabelPoints -> False] & @@
BoundedDiagram[{{-1, -1}, {1, -1}, {1, 1}, {-1, 1}}, data, delval,
convexHull]


and further

gr /. {Point[___] :> Sequence[],
Line[pts_] :> ({EdgeForm[{Thick, Black}],
ColorData["Rainbow", RandomReal[]], Polygon[pts]})}
`

-
Might generate the random points like this: mathematica.stackexchange.com/q/2594/12 – Szabolcs Feb 25 '14 at 12:11
Thank you so much. I got the idea. Maybe 'DelaunayTriangulation' is not the choice here and I have to have a specific code for this part. – Mahdi Feb 25 '14 at 14:32