CARVIEW |
Select Language
HTTP/2 200
date: Tue, 14 Oct 2025 08:19:03 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=57501e3f8da4829c4f18d3035c6df94d961634fb6ba25edb4aa416bd46426fdca%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22PpA9Yn-DUbwNCNp5uINvF_Zrs9eDoXLt%22%3B%7D; HttpOnly; Path=/
cf-ray: 98e5a6459852c1b5-BLR
BFS V1.1 - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global nodes;
- function backtrack(parent, start, target)
- path = list();
- path($+1) = target;
- while parent(1, path($)) ~= -1
- path($+1) = parent(1, path($));
- end
- for i=size(path):-1:1
- mprintf("%d ", path(i));
- end
- endfunction
- function BFS(graph, start, target, parent)
- visited = zeros(1, nodes);
- queue = list();
- queue($+1) = start;
- visited(1, start) = 1;
- while(size(queue) ~= 0)
- node = queue(1);
- if node == target
- disp("Path found!")
- backtrack(parent, node, target);
- return;
- end
- //mprintf("%d ", node);
- queue(1) = null();
- for i=1:nodes
- if graph(node, i) == 1 & visited(1, i) == 0 then
- parent(1, i) = node;
- queue($+1) = i;
- visited(1, i) = 1;
- end
- end
- end
- endfunction
- function [from, to]=split(data)
- splitted = evstr(strsplit(data, " "));
- from = splitted(1, 1);
- to = splitted(2, 1);
- endfunction
- nodes = input("How many nodes ? ");
- graph = zeros(nodes, nodes);
- edges = input("How many edges ? ");
- disp("Enter " + string(edges) + " edges (from-to) separated by a white space:");
- for i=1:edges
- in = input("", "string");
- [from, to] = split(in);
- graph(from, to) = 1;
- graph(to, from) = 1;
- end
- startNode = input("Enter initial node : ");
- targetNode = input("Enter target node : ");
- parent = zeros(1, nodes);
- parent(1, startNode) = -1;
- BFS(graph, startNode, targetNode, parent);
Advertisement
Add Comment
Please, Sign In to add comment
-
📌 Swapzone +37% glitch ⭐ 5
JavaScript | 2 sec ago | 0.25 KB
-
⭐⭐⭐Instant Profit Method⭐⭐
Java | 6 sec ago | 0.15 KB
-
⭐⭐⭐Exploit 500$ in 15 Minutes⭐⭐
Java | 9 sec ago | 0.15 KB
-
✅⭐ Make huge profits on trading ⭐⭐ T
JavaScript | 10 sec ago | 0.25 KB
-
⭐⭐⭐Profit Method⭐⭐
Java | 11 sec ago | 0.15 KB
-
⭐⭐⭐MAKE $9OO INSTANTLY D M⭐⭐
Java | 11 sec ago | 0.15 KB
-
⭐⭐⭐Make $1500 in 20 minutes⭐⭐
Java | 12 sec ago | 0.15 KB
-
⭐⭐⭐MAKE $9OO INSTANTLY D M⭐⭐
Java | 17 sec ago | 0.15 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