-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Description
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?
Metadata
Metadata
Assignees
Labels
No labels