Skip to content

Missing delaunay edges #51

@javieryu

Description

@javieryu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions