Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Removing an edge just sets the edge weight to 0 #43

@evanfields

Description

@evanfields
julia> g = SimpleWeightedGraph(2); add_edge!(g, 1, 2); collect(edges(g))
1-element Array{SimpleWeightedEdge{Int64,Float64},1}:
 Edge 1 => 2 with weight 1.0

julia> rem_edge!(g, 1, 2); collect(edges(g))
1-element Array{SimpleWeightedEdge{Int64,Float64},1}:
 Edge 1 => 2 with weight 0.0

Brief Slack discussion suggests this behavior arises from performance considerations around using sparse matrices; changing a value in a sparse matrix is much faster than changing the sparsity structure. For some use cases, this is totally okay. For example, if edges are "pipes" and edge weights are capacities, then a 0-weight edge and an absent edge are no different.

On the other hand, if edges represent possible movements between locations and edge weights are distances or costs, then a 0-weight edge means something very different than the absence of an edge.

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