Skip to content

Complexity of lines 301 and 304 are superlinear? #1

@davidglavas

Description

@davidglavas

https://github.com/UCL-PPLV/geometry-testing/blob/8111c50763579811d9f8b8d3bc3caa1b693d1123/src/main/scala/ucl/scenario/geometry/visibility/VisibilityPolygons.scala#L301

Line 301 iterates through all vertices vs, for each vertex it iterates through all edges es. Assume intersectProper() takes constant time, this results in O(vs*es).

https://github.com/UCL-PPLV/geometry-testing/blob/8111c50763579811d9f8b8d3bc3caa1b693d1123/src/main/scala/ucl/scenario/geometry/visibility/VisibilityPolygons.scala#L304

Line 304 iterates through all visible vertices vis, for each vertex it again iterates through all visible vertices vis. This takes O(vis^2) time, in case that all vertices are visible we have vs==vis which results in O(vs^2) time.

I don't speak Scala, sorry in advance if I missed something obvious.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions