Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing delaunay edges #51

Open
javieryu opened this issue Jan 10, 2020 · 0 comments
Open

Missing delaunay edges #51

javieryu opened this issue Jan 10, 2020 · 0 comments

Comments

@javieryu
Copy link

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:
Selection_054

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.

Selection_053

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant