-
Notifications
You must be signed in to change notification settings - Fork 0
/
bfsbonita.html
71 lines (68 loc) · 1.52 KB
/
bfsbonita.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BFS</title>
<link rel="stylesheet" href="bfs.css">
<script src="https://d3js.org/d3.v7.min.js"></script>
<script defer src="funcionabfs.js"></script>
</head>
<body>
<div class="controls">
<h1>Visualização de BFS</h1>
<div class="control-group">
<label for="start-node">Vértice inicial:</label>
<input type="text" id="start-node" value="0">
</div>
<div class="control-group">
<label for="vertex-count">Quantidade de Vértices:</label>
<input type="number" id="vertex-count" value="10">
<textarea id="edges-input" rows="10" cols="20">0 1
0 3
1 3
3 2
2 4
4 1
3 4
4 0
0 2
2 1
7 2
5 0
8 3
6 1
9 4
5 8
8 6
6 9
9 7
7 5</textarea>
<button onclick="runBFS()">Executar BFS</button>
</div>
</div>
<div id="graph-container">
<svg width="800" height="600"></svg>
</div>
<div id="result"></div>
<div id="code">
<code id="java-code">
private void bfs(Graph G, int s) {
Queue<Integer> queue = new LinkedList<>();
marked[s] = true;
queue.add(s);
while (!queue.isEmpty()) {
int v = queue.poll();
for (int w : G.adj(v)) {
if (!marked[w]) {
marked[w] = true;
edgeTo[w] = v;
queue.add(w);
}
}
}
}
</code>
</div>
</body>
</html>