Skip to content

Graph weights are incorrect when points are near two intersecting edges #4

@mattwigway

Description

@mattwigway

Consider a situation like this:

1-----2
| *
|
3

where the numbers are nodes and the * is a destination. We run create_graph_weights, which finds edges near the point, and proportionally assigns the weight to the nodes at the end of those edges. In this case, the nodes-at-end-of-edges array found will be [1, 2, 1, 3]. Note that node 1 is there twice, because it is at the end of both edges. We then update the weights with code that looks like this:

weights[nodes, i] .+= row[weightcol] / length(nodes)

The problem is that when there are duplicates in nodes, this will only update each of them once, e.g.

x = zeros(Float64, 3)
x[[2, 3, 2]] .+= 1 # => [0, 1, 1]

when the answer we want is [0, 2, 1] with one added to index 2 twice. This is easy enough to solve by just looping.

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