CARVIEW |
Select Language
HTTP/2 200
date: Wed, 15 Oct 2025 15:38:49 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=5cf287fbecdf5a6b8ba6afb1a5c0ef730f3b561fd8827fac9fa7caf37742479ca%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%2211IYWfLv8Eox9Mv0vTwNYlQj18IH2mIL%22%3B%7D; HttpOnly; Path=/
cf-ray: 98f067d83afed817-BLR
Dijkstra - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global nodes;
- function printPath(points, i)
- if points(1, i) ~= -1 then
- printPath(points, points(1, i));
- //disp(string(i) + " ");
- mprintf("%d ", i);
- end
- endfunction
- function printSolution(distance, points)
- for i=1:nodes
- //disp(string(i) + " " + string(distance(i)));
- mprintf("Node : %d\n", i);
- mprintf("Distance from start : %d\n", distance(1, i));
- mprintf("Path : ");
- printPath(points, i);
- disp("");
- end
- endfunction
- function result=findMin(distance, visited)
- min = 10000, minIndex = 0;
- for i=1:nodes
- if visited(1, i) == 0 & distance(1, i) <= min then
- minIndex = i;
- min = distance(1, i);
- end
- end
- result = minIndex;
- endfunction
- function dijkstra(graph, start)
- distance = 10000*ones(1, nodes);
- points = zeros(1, nodes);
- visited = zeros(1, nodes);
- distance(1, start) = 0;
- points(1, start) = -1;
- for i=1:nodes-1
- min = findMin(distance, visited);
- visited(1, min) = 1;
- for j=1:nodes
- if visited(1, j) == 0 & graph(min, j) > 0 & distance(1, min) ~= 10000 & distance(1, min)+graph(min, j) < distance(1, j) then
- distance(1, j) = distance(1, min) + graph(min, j);
- points(1, j) = min;
- end
- end
- end
- printSolution(distance, points);
- disp(points);
- endfunction
- function [from, to, weight]=split(data, flag)
- splitted = evstr(strsplit(data, " "));
- from = splitted(1, 1);
- to = splitted(2, 1);
- if flag == 1 then
- weight = 1;
- else
- weight = splitted(3, 1);
- end
- endfunction
- nodes = input("How many nodes ? ");
- graph = zeros(nodes, nodes);
- flag = input("Does all edges have the same weight (1.yes, 2. no)? ");
- edges = input("How many edges ? ");
- if flag == 1 then
- disp("Enter " + string(edges) + " edges (from-to) separated by a white space:");
- else
- disp("Enter " + string(edges) + " edges (from-to-weight) separated by a white space:");
- end
- for i=1:edges
- in = input("", "string");
- [from, to, weight] = split(in, flag);
- graph(from, to) = weight;
- graph(to, from) = weight;
- end
- startNode = input("Enter initial node : ");
- dijkstra(graph, startNode);
Advertisement
Add Comment
Please, Sign In to add comment
-
π‘ Instant BTC Profit Method β
Working
JavaScript | 3 sec ago | 0.24 KB
-
π Swapzone +37% glitch β A
JavaScript | 8 sec ago | 0.25 KB
-
π Swapzone +37% glitch
JavaScript | 14 sec ago | 0.24 KB
-
β
β Make huge profits on trading ββ T
JavaScript | 16 sec ago | 0.25 KB
-
π MAKE $2500 IN 15 MIN β
Working
JavaScript | 23 sec ago | 0.24 KB
-
β
Marketplace Glitch β
Working NEVER SEEN BE...
JavaScript | 25 sec ago | 0.25 KB
-
ββ
Exploit 2500$ in 15 Minutesβββ X
JavaScript | 33 sec ago | 0.25 KB
-
β‘ Crypto Swap Glitch β
Working β‘
JavaScript | 34 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