I'm trying to simulate to teams, so that I can see the grouping of players on one team. Here is what I have in mind:
I have tried making a nearest neighbor graph between all players then deleting the vertices of one team, but the connections pass through red "cells" (eg 16 to 20).
Also, a nearest neighbor graph of one team does not always connect adjacent cells (eg 19 to 16) and passes through red cells (eg 14 to 18).
Here is the full code with everything I have above:
ptt = RandomReal[{0, 10}, {22, 2}];
ntt = NearestNeighborGraph[ptt[[11 ;; 22]], 1,
VertexLabels -> Table[ptt[[i]] -> i, {i, 11, 22}]];
(* ntt = vertexDeleteKeepEmbedding[ntt,Table[VertexList[ntt][[n]],{n,\
1,11}]] *)
Show[Show[VoronoiMesh[ptt], ntt],
Graphics[{PointSize@Medium, Red, Point[ptt[[1 ;; 11]]], Blue,
Point[ptt[[12 ;; 22]]]}]]
vertexDeleteKeepEmbedding[graph_, vertex_] :=
Module[{coords, vertices = VertexList[graph]},
coords =
DeleteCases[vertices, vertex] /.
Thread[vertices -> GraphEmbedding[graph]];
Graph[VertexDelete[graph, vertex], VertexCoordinates -> coords]];
Any tips?