func_code_string: #include <bits/stdc++.h>   using namespace std;   class Edge {    public:     int neighbour;     int edge_number;     int weight;     Edge(int neigh, int edge_no, int weig) {       neighbour = neigh;       edge_number = edge_no;       weight = weig;     }   };   int main() {     int n, m;     cin >> n >> m;     vector<vector<Edge> > adj_list(n + 1);     for (int i = 1; i <= m; i++) {       int vertex1, vertex2, weight;       cin >> vertex1 >> vertex2 >> weight;       Edge temp = Edge(vertex2, i, weight);       adj_list[vertex1].push_back(temp);       temp = Edge(vertex1, i, weight);       adj_list[vertex2].push_back(temp);     }     int source;     cin >> source;     vector<bool> check_list(n + 1, false);     priority_queue<pair<long long int, int> > pq;     vector<pair<int, int> > parent(n + 1, make_pair(0, 0));     for (int i = 1; i <= n; i++) {       if (i != source)         pq.push(make_pair(LLONG_MIN, i));       else         pq.push(make_pair(0, i));     }     vector<pair<long long int, int> > dist(n + 1, make_pair(LLONG_MAX, 0));     dist[source].first = 0;     while (!pq.empty()) {       int vertex = pq.top().second;       pq.pop();       if (check_list[vertex] == false) {         check_list[vertex] = true;         for (int i = 0; i < adj_list[vertex].size(); i++) {           if (dist[adj_list[vertex][i].neighbour].first >               dist[vertex].first + adj_list[vertex][i].weight) {             parent[adj_list[vertex][i].neighbour].first =                 adj_list[vertex][i].edge_number;             parent[adj_list[vertex][i].neighbour].second =                 adj_list[vertex][i].weight;             dist[adj_list[vertex][i].neighbour].first =                 dist[vertex].first + adj_list[vertex][i].weight;             dist[adj_list[vertex][i].neighbour].second =                 adj_list[vertex][i].weight;             pq.push(make_pair((-1) * (dist[adj_list[vertex][i].neighbour].first),                               adj_list[vertex][i].neighbour));           } else if (dist[adj_list[vertex][i].neighbour].first ==                      dist[vertex].first + adj_list[vertex][i].weight) {             if (dist[adj_list[vertex][i].neighbour].second >                 adj_list[vertex][i].weight) {               parent[adj_list[vertex][i].neighbour].first =                   adj_list[vertex][i].edge_number;               parent[adj_list[vertex][i].neighbour].second =                   adj_list[vertex][i].weight;               dist[adj_list[vertex][i].neighbour].second =                   adj_list[vertex][i].weight;             }           }         }       }     }     long long int ans = 0;     for (int i = 1; i <= n; i++) {       ans += parent[i].second;     }     cout << ans << endl;     for (int i = 1; i <= n; i++) {       if (source != i) cout << parent[i].first <<    ;     }   }   