Skip to content

Comparison of WeightedEdge should take into consideration whether the edges are directed #82

Description

@tbbruno

Let's say I have two weighted and not directed edges, connecting the same vertices, as follows:

let edgeA = WeightedEdge<Int> = WeightedEdge(u: 0, v: 1, directed: false, weight: 10)
let edgeB = WeightedEdge<Int> = WeightedEdge(u: 1, v: 0, directed: false, weight: 10)

Currently we have so that edgeA == edgeB returns false.

Shouldn't the ==(_:_:) operator take into consideration whether they're directed? Or am I missing something?
So in this particular scenario I would expect edgeA == edgeB to return true, as they are not directed.


In summary we would have:

let directedEdgeA = WeightedEdge<Int> = WeightedEdge(u: 0, v: 1, directed: false, weight: 10)
let directedEdgeB = WeightedEdge<Int> = WeightedEdge(u: 1, v: 0, directed: false, weight: 10)
directedEdgeA == directedEdgeB // returns `true`


let undirectedEdgeC = WeightedEdge<Int> = WeightedEdge(u: 0, v: 1, directed: true, weight: 10)
let undirectedEdgeD = WeightedEdge<Int> = WeightedEdge(u: 1, v: 0, directed: true, weight: 10)
undirectedEdgeC == undirectedEdgeD // returns `false`

If there are any worries about how changing the ==(_:_:) implementation would affect other features, should we have a separate method to compare two edges?
Any thoughts on this?

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions