Shifting the origin of a large list of coordinates Problem and goal

Given a large edge list file (such as 2 million nodes, 30 million edges) containing source and destination coordinates, I want to 'convert' them in such a way so that the coordinates start at 0. Hopefully the example will clear this up. My goal is to increase the performance (speed) of my current code.

Example

input_file.txt

54    414
12    54
414   87
20    54
12    3


Output

0    1
2    0
1    3
4    0
2    5


Notice how 54 becomes 0, 414 becomes 1, 12 becomes 2, 87 becomes 3 etc. In other words: if a vertex is re-used like 54, the same coordinate will be used.

My solution

While my solution works fine, it is slow for a large edge list such as: this edge list (or this small one for testing purposes), and I was wondering whether there are areas to improve my code.

Essentially, I am using a dictionary (map) that keeps track of each vertex and its coordinate respectfully. If a vertex is not present in the dictionary, it uses the current coordinate and increments it for any possible new vertex.

Code

#pragma warning (disable : 4996)
#include &lt;iostream&gt;
#include &lt;unordered_map&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;
#include "conio.h"
#include &lt;sstream&gt;
#include &lt;fstream&gt;

using namespace std;

void load_graph_from_edge_list_file_to_coo(vector&lt;int&gt;&amp; , vector&lt;int&gt;&amp;, string);
int add_vertex_as_coordinate(vector&lt;int&gt;&amp;, unordered_map&lt;int, int&gt;&amp;, int, int);

int main() {
    vector&lt;int&gt; source_vertices;
    vector&lt;int&gt; destination_vertices;
    string input_file_path = "C:\\Users\\User\\Desktop\\input_file.txt";
    load_graph_from_edge_list_file_to_coo(source_vertices, destination_vertices, input_file_path);

    return 0;
}

void load_graph_from_edge_list_file_to_coo(vector&lt;int&gt;&amp; source_vertices, vector&lt;int&gt;&amp; destination_vertices, string file_path) {
    unordered_map&lt;int, int&gt; map_from_edge_to_coordinate;
    int current_coordinate = 0;

    std::ifstream infile(file_path);
    string line;
    while (getline(infile, line))
    {
        std::istringstream iss(line);
        int vertex_source, vertex_destination;
        if (!(iss &gt;&gt; vertex_source &gt;&gt; vertex_destination)) { 
            continue; 
        } else {
            current_coordinate = add_vertex_as_coordinate(source_vertices, map_from_edge_to_coordinate, vertex_source, current_coordinate);
            current_coordinate = add_vertex_as_coordinate(destination_vertices, map_from_edge_to_coordinate, vertex_destination, current_coordinate);
        }
    }
    infile.close();

    printf("\nTotal amount of vertices: %d", map_from_edge_to_coordinate.size());
    printf("\nTotal amount of edges: %d", source_vertices.size());
}

int add_vertex_as_coordinate(vector&lt;int&gt;&amp; vertices_type, unordered_map&lt;int, int&gt;&amp; map_from_edge_to_coordinate, int vertex, int coordinate) {
    if (map_from_edge_to_coordinate.count(vertex)) {
        vertices_type.push_back(map_from_edge_to_coordinate.at(vertex));

        return coordinate;
    }
    else {
        map_from_edge_to_coordinate[vertex] = coordinate;
        vertices_type.push_back(coordinate);
        coordinate++;

        return coordinate;
    }
}


Any tips to increase the performance would be greatly appreciated.
The only thing I can see that will speed stuff up is this part:

string line;
while (getline(infile, line))
{
    std::istringstream iss(line);
    int vertex_source, vertex_destination;
    if (!(iss &gt;&gt; vertex_source &gt;&gt; vertex_destination)) { 


There is a lot of copying from line to iss. This provides some good error checking and correction ability. But does slow the code down.

Replacing the above with

while (iss &gt;&gt; vertex_source &gt;&gt; vertex_destination)
{


results in a 10% speed improvement in my code (though I took out the vectors; I did not need them).