CARVIEW |
Select Language
HTTP/2 200
date: Sun, 12 Oct 2025 23:34:04 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=eb63c1da77e17fc9451839b52f89993569893c364640c0c3b7e6ebec2655e525a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22W7sIExy9z0hUyV6mHFGbt2KnvArbq2S0%22%3B%7D; HttpOnly; Path=/
cf-ray: 98da67e52d0cc464-BLR
dijkstra - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Dijkstra's Algorithm in C
- #include <stdio.h>
- #define INFINITY 9999
- #define MAX 10
- void Dijkstra(int Graph[MAX][MAX], int n, int start);
- void Dijkstra(int Graph[MAX][MAX], int n, int start) {
- int cost[MAX][MAX], distance[MAX], pred[MAX];
- int visited[MAX], count, mindistance, nextnode, i, j;
- // Creating cost matrix
- for (i = 0; i < n; i++)
- for (j = 0; j < n; j++)
- if (Graph[i][j] == 0)
- cost[i][j] = INFINITY;
- else
- cost[i][j] = Graph[i][j];
- for (i = 0; i < n; i++) {
- distance[i] = cost[start][i];
- pred[i] = start;
- visited[i] = 0;
- }
- distance[start] = 0;
- visited[start] = 1;
- count = 1;
- while (count < n - 1) {
- mindistance = INFINITY;
- for (i = 0; i < n; i++)
- if (distance[i] < mindistance && !visited[i]) {
- mindistance = distance[i];
- nextnode = i;
- }
- visited[nextnode] = 1;
- for (i = 0; i < n; i++)
- if (!visited[i])
- if (mindistance + cost[nextnode][i] < distance[i]) {
- distance[i] = mindistance + cost[nextnode][i];
- pred[i] = nextnode;
- }
- count++;
- }
- // Printing the distance
- for (i = 0; i < n; i++)
- if (i != start) {
- printf("\nDistance from source to %d: %d", i, distance[i]);
- }
- }
- int main() {
- int Graph[MAX][MAX], i, j, n, u;
- n = 7;
- Graph[0][0] = 0;
- Graph[0][1] = 0;
- Graph[0][2] = 1;
- Graph[0][3] = 2;
- Graph[0][4] = 0;
- Graph[0][5] = 0;
- Graph[0][6] = 0;
- Graph[1][0] = 0;
- Graph[1][1] = 0;
- Graph[1][2] = 2;
- Graph[1][3] = 0;
- Graph[1][4] = 0;
- Graph[1][5] = 3;
- Graph[1][6] = 0;
- Graph[2][0] = 1;
- Graph[2][1] = 2;
- Graph[2][2] = 0;
- Graph[2][3] = 1;
- Graph[2][4] = 3;
- Graph[2][5] = 0;
- Graph[2][6] = 0;
- Graph[3][0] = 2;
- Graph[3][1] = 0;
- Graph[3][2] = 1;
- Graph[3][3] = 0;
- Graph[3][4] = 0;
- Graph[3][5] = 0;
- Graph[3][6] = 1;
- Graph[4][0] = 0;
- Graph[4][1] = 0;
- Graph[4][2] = 3;
- Graph[4][3] = 0;
- Graph[4][4] = 0;
- Graph[4][5] = 2;
- Graph[4][6] = 0;
- Graph[5][0] = 0;
- Graph[5][1] = 3;
- Graph[5][2] = 0;
- Graph[5][3] = 0;
- Graph[5][4] = 2;
- Graph[5][5] = 0;
- Graph[5][6] = 1;
- Graph[6][0] = 0;
- Graph[6][1] = 0;
- Graph[6][2] = 0;
- Graph[6][3] = 1;
- Graph[6][4] = 0;
- Graph[6][5] = 1;
- Graph[6][6] = 0;
- u = 0;
- Dijkstra(Graph, n, u);
- return 0;
- }
Add Comment
Please, Sign In to add comment
-
🔥 Exchange profit method
JavaScript | 3 sec ago | 0.24 KB
-
📝 MAKE $2500 IN 15 MIN ✅ Working
JavaScript | 13 sec ago | 0.24 KB
-
📌 Swapzone +37% glitch ⭐ J
JavaScript | 15 sec ago | 0.25 KB
-
⭐⭐⭐Exchange Exploit⭐⭐
Java | 19 sec ago | 0.15 KB
-
⚡ Crypto Swap Glitch ✅ Working ⚡
JavaScript | 22 sec ago | 0.24 KB
-
✅⭐ Make huge profits on trading ⭐⭐ 5
JavaScript | 24 sec ago | 0.25 KB
-
⭐⭐⭐Free Giftcards Method⭐⭐
Java | 30 sec ago | 0.15 KB
-
💡 Instant BTC Profit Method ✅ Working
JavaScript | 31 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand