-
Notifications
You must be signed in to change notification settings - Fork 0
/
input-MST.js
55 lines (49 loc) · 2.85 KB
/
input-MST.js
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
function input_MST(algo){
//to remove loading gif
document.querySelector(".loading-gif").classList.add("remove-loading-gif");
var treeContainerElement=document.getElementById("tree-container");
while(treeContainerElement.hasChildNodes()){
treeContainerElement.removeChild(treeContainerElement.firstChild);
}
console.log(algo);
if(algo=='prims'){
var algo_name_div=document.getElementById("algo-name");
algo_name_div.innerHTML="Prim's algorithm";
input_size=`
<h2><label for="sizeOfMatrix">Enter number of nodes:</label>
<input type="number" id="sizeOfMatrix" name="sizeOfMatrix" min="2" max="7">
<button class="graph_button" type="button" onclick="generateInputMatrix(document.getElementById('sizeOfMatrix').value,'prims')">Submit</button></h2>
<br><br>
<div id="container" style="width:90%;"></div>
<div id="container" style="width:95%;display: flex;overflow:hidden;">
<table>
<tr><td><div id="media" style="width:60%;height:500px;"></div></td></tr>
<tr><td><div style="display:none" id="legend"><img src="legend1.png" alt="legend"></div></td></tr>
</table>
<div id="pseudocode-container" style="width:40%;height:620px;"></div>
</div>
<br><br>
<div id="button-area" style="width:95%;"></div>
`;}
else if(algo=='kruskal'){
var algo_name_div=document.getElementById("algo-name");
algo_name_div.innerHTML="Kruskal's algorithm";
input_size=`
<h2><label for="sizeOfMatrix">Enter number of nodes:</label>
<input type="number" id="sizeOfMatrix" name="sizeOfMatrix" min="2" max="7">
<button class="graph_button" type="button" onclick="generateInputMatrix(document.getElementById('sizeOfMatrix').value,'kruskal')">Submit</button></h2>
<br><br>
<div id="container" style="width:90%;"></div>
<div id="container" style="width:95%;display: flex;overflow:hidden;">
<table>
<tr><td><div id="media" style="width:60%;height:500px;"></div></td></tr>
<tr><td><div style="display:none" id="legend"><img src="legend1.png" alt="legend"></div></td></tr>
</table>
<div id="pseudocode-container" style="width:40%;height:620px;"></div>
</div>
<br><br>
<div id="button-area" style="width:95%;"></div>
`;}
var graph_generator_area=document.getElementById("graph-generator-area");
graph_generator_area.innerHTML=input_size;
}