# “Team” based graph with connections between groups

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] /.
Graph[VertexDelete[graph, vertex], VertexCoordinates -> coords]];


Any tips?

• Confusing tipic... – yode Jul 4 '17 at 14:29
• In one sentence I want to find groups of blue/red vertexes that don't intersect cells from the other team – Robert Jul 4 '17 at 14:42

SeedRandom[1]
pts = RandomReal[{0, 10}, {22, 2}];
{team1, team2} = {pts[[;; 11]], pts[[12 ;;]]};


Is this what you after?

teams = GroupBy[Complement[Sort /@ DelaunayMesh[pts]["EdgeCoordinates"],
Sort /@ Tuples[{team1, team2}]],MemberQ[team1, First[#]] &];
VoronoiMesh[pts,Epilog -> {PointSize[.02], Red, Point[team1], Line[teams[True]],
Blue, Point[team2], Line[teams[False]]}]


PS:Note the graph of DelaunayMesh record the relationship about the vertices of VoronoiMesh.

• Thank you for your answer! – Robert Jul 4 '17 at 15:46