Finding duplicates in different lines of a text file c++ : I have a simple text file that looks like this:

        1 3 0.5
        1 5 0.5
        3 5 0.5
        2 3 0.5
        2 4 0.5
        3 4 0.5
        3 6 0.5
        3 5 0.5
        6 5 0.5
        7 6 0.5
        7 8 0.5
        6 8 0.5
        4 6 1
        7 5 1
The first number in the line is a node number for a graph, and the second number is the number of the node that is connected to the first. The third number is the weight of the edge. In this case there are two lines that 3 and 5 with a weight of .5 I would like to be able to merge these into just one line that has the connection for 3 and 5 but update the weight to be the sum of their weights (in this case 1).

I have tried reading every line into separate arrays but run into problems when the first and second node are the same, but in different order (3 5 and 5 3 are the same edge and their weights should be added together). I am also using a text file where there are sometimes up to 100 duplicates that all need to be added together and then have the other connections deleted and just have 1 updated one with the total sum.

I am having trouble understanding how to store all of this information, such as which lines to delete, and how to handle the case of the nodes being switched. I still think comparing arrays is the way to go I am just having trouble with it. Thank you for any feedback, and just let me know if I need to post any more information!