Вот код, который отделяет большие ребра от маленьких:
# Computing Delaunay
tri = Delaunay(points)
# Separating small and large edges:
thresh = 1.0 # user defined threshold
small_edges = set()
large_edges = set()
for tr in tri.vertices:
for i in xrange(3):
edge_idx0 = tr[i]
edge_idx1 = tr[(i+1)%3]
if (edge_idx1, edge_idx0) in small_edges:
continue # already visited this edge from other side
if (edge_idx1, edge_idx0) in large_edges:
continue
p0 = points[edge_idx0]
p1 = points[edge_idx1]
if np.linalg.norm(p1 - p0) < thresh:
small_edges.add((edge_idx0, edge_idx1))
else:
large_edges.add((edge_idx0, edge_idx1))
# Plotting the output
figure()
plot(points[:, 0], points[:, 1], '.')
for i, j in small_edges:
plot(points[[i, j], 0], points[[i, j], 1], 'b')
for i, j in large_edges:
plot(points[[i, j], 0], points[[i, j], 1], 'c')
На данных, сгенерированных из следующего кода, я получаю этот рисунок:
# Constructing the input point set
np.random.seed(0)
x = 3.0 * np.random.rand(1000)
y = 2.0 * np.random.rand(1000) - 1.0
inside = ((x ** 2 + y ** 2 > 1.0) & ((x - 3) ** 2 + y ** 2 > 1.0) & ((x-1.5) ** 2 + y ** 2 > 0.09))
points = np.vstack([x[inside], y[inside]]).T