You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using delaunayedges to create a graph from the a random distribution of points, but in cases where voronoi cells only have one neighbouring voronoi cell (for instance 3 points on a line) then the there are no delaunay edges.
Working example
Here is an example where the proper delaunay edges appear:
Not working
In this case each of the three point has zeros delaunay edges where they should have 1 or 2, and delaunayedges(tess) is an empty iterator.
This is the code I am using:
function generate_random_delaunay_graph(N::Int64)
graph = SimpleGraph(N)
tess = DelaunayTessellation()
width = VoronoiDelaunay.max_coord - VoronoiDelaunay.min_coord
a = Point2D[Point(VoronoiDelaunay.min_coord + rand() * width,
VoronoiDelaunay.min_coord + rand() * width) for i in 1:N]
push!(tess, a)
plt = plot()
x, y = getplotxy(voronoiedges(tess))
plot!(plt, x, y, c=:red, lab="voronoi edges")
x, y = getplotxy(delaunayedges(tess))
plot!(plt, x, y, c=:blue, lab="delaunayedges")
display(plt)
point_lookup = Dict(a[i] => i for i in 1:N)
for edge in delaunayedges(tess)
i = point_lookup[geta(edge)]
j = point_lookup[getb(edge)]
add_edge!(graph, i, j)
end
return graph, tess
end
The text was updated successfully, but these errors were encountered:
I am using
delaunayedges
to create a graph from the a random distribution of points, but in cases where voronoi cells only have one neighbouring voronoi cell (for instance 3 points on a line) then the there are no delaunay edges.Working example
Here is an example where the proper delaunay edges appear:
Not working
In this case each of the three point has zeros delaunay edges where they should have 1 or 2, and
delaunayedges(tess)
is an empty iterator.This is the code I am using:
The text was updated successfully, but these errors were encountered: