dijkstra in c++
C++
void dijkstra(int s) {
priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > pq;
for (int i=0; i<N; i++) dist[s] = INF;
dist[s] = 0;
pq.push(make_pair(0, s));
while (!pq.empty()) {
pair<int, int> front = pq.top();
pq.pop();
int w = front.first, u = front.second;
if (w > dist[u]) continue;
for (int i=0; i<adj[u].size(); i++) {
pair<int, int> v = adj[u][i];
if (dist[v.first] > dist[u] + v.second) {
dist[v.first] = dist[u] + v.second;
pq.push(make_pair(dist[v.first], v.first));
}
}
}
}
Also in C++:
- Title
- how to sort an array according to another array c++
- Category
- C++
- Title
- getch c++ library
- Category
- C++
- Title
- c++ unittest in ros
- Category
- C++
- Title
- how to output text in c++
- Category
- C++
- Title
- C++ user input
- Category
- C++
- Title
- c++ char to int
- Category
- C++
- Title
- __builtin_ctz
- Category
- C++
- Title
- differentialble programming
- Category
- C++
- Title
- c++ string to stream
- Category
- C++
- Title
- c++ how to return an empty vector
- Category
- C++
- Title
- mark occurances of elements in array cpp
- Category
- C++
- Title
- what is difference between ciel and floor
- Category
- C++
- Title
- c++ short if
- Category
- C++
- Title
- string to vector c++
- Category
- C++
- Title
- transpose matrix eigen c++
- Category
- C++
- Title
- c++ code to print hello world
- Category
- C++
- Title
- loop through array c++
- Category
- C++
- Title
- cin.fail()
- Category
- C++
- Title
- c++ convert int to cstring
- Category
- C++
- Title
- insert function in c++ vector
- Category
- C++
- Title
- power in c++
- Category
- C++
- Title
- primeros numeros primos
- Category
- C++
- Title
- substitution failure is not an error
- Category
- C++
- Title
- c++ ternary operator
- Category
- C++
- Title
- calling a method on an object c++
- Category
- C++
- Title
- object reference not set to an instance of an object c#
- Category
- C++
- Title
- std::reverse
- Category
- C++
- Title
- c++ string to vector int
- Category
- C++
- Title
- c++ set add element
- Category
- C++
- Title
- what is time complexity of insertion sort
- Category
- C++
- Title
- regexp_like oracle c++
- Category
- C++
- Title
- How to traverse in a tree iterative C++
- Category
- C++
- Title
- arduino delay millis
- Category
- C++
- Title
- c++ wait for user input
- Category
- C++
- Title
- c++ char print width
- Category
- C++
- Title
- struct c++
- Category
- C++
- Title
- UPARAM(ref)
- Category
- C++
- Title
- how long can a c++ string be
- Category
- C++
- Title
- recursion in cpp with reference
- Category
- C++
- Title
- cout console
- Category
- C++
- Title
- C++ string format ctime
- Category
- C++
- Title
- make an x using asterisk c++
- Category
- C++
- Title
- how to delete an element in vector pair in cpp
- Category
- C++
- Title
- function template
- Category
- C++
- Title
- Insert into vector C++
- Category
- C++
- Title
- how to use max_element in c++ with vector
- Category
- C++
- Title
- max heap c++ stl;
- Category
- C++
- Title
- c++ stack
- Category
- C++
- Title
- new in c++
- Category
- C++
- Title
- c++ tutorial
- Category
- C++
- Title
- how to declare a function in c++
- Category
- C++
- Title
- how to inject a dll into a game c++
- Category
- C++
- Title
- passing a vector to a function c++
- Category
- C++
- Title
- how to cout in c++
- Category
- C++
- Title
- c++ how to loop through a vector but not the last element
- Category
- C++
- Title
- check for bst
- Category
- C++
- Title
- how to run a c++ program in the background
- Category
- C++
- Title
- FInd the element which appears more than n/2 times C++
- Category
- C++
- Title
- c++ cli convert string to string^
- Category
- C++
- Title
- self in c++
- Category
- C++
- Title
- c++ uint32_t
- Category
- C++
- Title
- two sum problem in c++
- Category
- C++
- Title
- c++ functions
- Category
- C++
- Title
- error: invalid conversion from 'Node*' to 'int'
- Category
- C++
- Title
- c++ clear console
- Category
- C++
- Title
- for loop
- Category
- C++
- Title
- preorder traversal
- Category
- C++
- Title
- how to get the largest number in a c++ array
- Category
- C++
- Title
- assegnare valori in c++
- Category
- C++
- Title
- pop_back
- Category
- C++
- Title
- c++ argv
- Category
- C++
- Title
- hashset in c++
- Category
- C++
- Title
- binary search in set c++
- Category
- C++
- Title
- C++ Student::Student()
- Category
- C++
- Title
- mysqli connect
- Category
- C++
- Title
- advanced c++ topics
- Category
- C++
- Title
- how to switch to another branch in git
- Category
- C++
- Title
- print matrix c++
- Category
- C++
- Title
- leveling system c++
- Category
- C++
- Title
- namespaces c++
- Category
- C++
- Title
- c++ transform
- Category
- C++
- Title
- ue4 modular character
- Category
- C++
- Title
- phph date
- Category
- C++
- Title
- C++ pointer arithmetic
- Category
- C++
- Title
- program to know if a number is prime
- Category
- C++
- Title
- c++ for loop
- Category
- C++
- Title
- while loops
- Category
- C++
- Title
- passing reference in c++
- Category
- C++
- Title
- nth_element c++
- Category
- C++
- Title
- Html tab
- Category
- C++
- Title
- coronavirus
- Category
- C++
- Title
- c++ vector lower_bound index
- Category
- C++
- Title
- iterate through unordered_map c++ in reverse order
- Category
- C++
- Title
- ue4 c++ overlapping functions cpp setup
- Category
- C++
- Title
- gcd in c++
- Category
- C++
- Title
- c++ code 2d block
- Category
- C++
- Title
- Find the duplicate in an array of N integers.
- Category
- C++
- Title
- c++ excel cell blank cells
- Category
- C++
- Title
- counting valleys hackerrank solution in c++
- Category
- C++
- Title
- pyqt connect
- Category
- C++