Hello!
Suppose I have a list of tuples given as:
ps
17-element Vector{Tuple{Int64, Int64, Float64}}:
(6, 1, 0.1943167542320367)
(6, 7, 0.3711794598818039)
(6, 3, 0.24015959913323964)
(3, 1, 0.10660277812749026)
(3, 7, 0.15676846198395794)
(3, 6, 0.24015959913323964)
(1, 7, 0.18199430878135997)
(1, 6, 0.1943167542320367)
(7, 6, 0.3711794598818039)
(1, 3, 0.10660277812749026)
(7, 3, 0.15676846198395794)
(4, 8, 0.18129600615558053)
(8, 4, 0.18129600615558053)
(8, 9, 0.12927343763884552)
(9, 8, 0.12927343763884552)
(9, 5, 0.17768623230197966)
(5, 9, 0.17768623230197966)
Each element consists of (i,j,d), where i and j are indices and d is the distance between them. How would I then go about removing ârepeat entriesâ, which is for example at the bottom:
(9, 5, 0.17768623230197966)
(5, 9, 0.17768623230197966)
Where I have i = j, j = i.
So basically my question is, how do I filter this list of tuples to remove cases in which i and j are âflippedâ?
What I should end up with is:
ps
X-element Vector{Tuple{Int64, Int64, Float64}}:
(6, 1, 0.1943167542320367) #or (1, 6, 0.1943167542320367)
(6, 7, 0.3711794598818039) #or (7, 6, 0.3711794598818039)
(6, 3, 0.24015959913323964) #or (3, 6, 0.24015959913323964)
(3, 1, 0.10660277812749026) #or (1, 3, 0.10660277812749026)
(3, 7, 0.15676846198395794) #or (7, 3, 0.15676846198395794)
(1, 7, 0.18199430878135997)
(4, 8, 0.18129600615558053) #or (8, 4, 0.18129600615558053)
(8, 9, 0.12927343763884552) #or (9, 8, 0.12927343763884552)
(9, 5, 0.17768623230197966) #or (5, 9, 0.17768623230197966)
Kind regards