Skip to content

Bug in expanding cluster? #52

Description

@carlos-verdes

Hi, in GDBScan, the last line of the expand method says "if new point is a cluster"... but in the "if clause" the point is evaluated with the current neighbourhood... not with the new neighbours.

    neighbours.foldLeft(neighbours) {
      case (neighbourhood, neighbour @ Point(row)) =>
        // if not visited yet, create a new neighbourhood
        val newNeighbours = if (!(visited contains neighbour)) {
          visited add neighbour
          getNeighbours(neighbour, points.filterNot(_.row == neighbour.row))
        } else {
          Seq.empty
        }
        // Add to cluster if neighbour point isn't assigned to a  cluster yet
        if (!(clustered contains neighbour)) {
          cluster add neighbour
          clustered add neighbour
        }
        // if the neighbour point is a cluster, join the neighbourhood
        if (isCorePoint(neighbour, neighbourhood)) neighbourhood ++ newNeighbours else neighbourhood
    }

I think the last line should be:

 // if the neighbour point is a cluster, join the neighbourhood
   if (isCorePoint(neighbour, newNeighbours)) neighbourhood ++ newNeighbours else neighbourhood

If you agree I can do a PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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