Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
let currentlySelected= null;
let vertices= []; // [cx, xy, selected, name]
let edges= []; // ["x1,y1", "x2,y2", forth, weight, v1, v2, passing]

let currentlyLinked= [];
return {
placing,
linking,
Expand All @@ -35,6 +35,7 @@
currentlySelected,
vertices,
edges,
currentlyLinked
}
},
// computed: {
Expand Down Expand Up @@ -86,7 +87,7 @@
},
unfocus() {
// Remove the selection from the current Vertex
if (this.currentlySelected !== null) {
if (this.vertices.length && this.currentlySelected !== null) {
// Take off the currentlySelected one
this.vertices[this.currentlySelected][2]= false;
}
Expand Down Expand Up @@ -149,13 +150,25 @@
// The evaluation
//let output= mooreDijkstra(this.getMatrix(), _from);
// let result= mooreDijkstra(this.getMatrix(), _from)[`to-${_to}`]; // Get the path from _from to _to

// We takeout all focuses
this.placing= false;
this.linking= false;
this.removing= false;
this.unfocus();

let matrix= this.getMatrix();
let result= mooreDijkstra(matrix, _from)[`to-${_to}`];
if (result[1] == Infinity)
alert("No path linking the two vertices");
else
this.shortest= result[1];
// Color the path
if (this.currentlyLinked.includes(`${_from},${_to}`))
// Reevaluate the path if it has already been calculated
this.clearPath();
else
this.currentlyLinked.push(`${_from},${_to}`); // Save the already calculated path
this.drawPath(result[0], color);
},
drawPath(result, color) {
Expand All @@ -179,6 +192,12 @@
});
}
},
clearPath() {
// Reset path colors
this.edges.forEach((edge) => {
edge[6]= false;
});
},
donePlacing() {
this.placing= false;
this.unfocus();
Expand Down
16 changes: 13 additions & 3 deletions src/components/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
let _to= document.getElementById('to');
if (parseInt(_from.value) == parseInt(_to.value))
alert("Please select two different vertices"); // Same vertex
else
this.$emit('evaluate', parseInt(_from.value), parseInt(_to.value), document.getElementById('color').value);
else if (_from.value !== "")
this.$emit('evaluate', parseInt(_from.value), parseInt(_to.value), document.getElementById('color').value);
}
},
}
Expand All @@ -102,6 +102,10 @@
font-weight: 900;
border-radius: 10px;
}
button:hover {
background: #999999;
color: #ffffff;
}
select {
margin: 2px;
cursor: pointer;
Expand All @@ -114,7 +118,7 @@
bottom: 5px;
}
#submit:hover {
background: #4444ff;
background: #3333ff;
}
#submitter {
position: absolute;
Expand All @@ -125,10 +129,16 @@
color: #ffffff;
margin-bottom: 20px;
}
.removal:hover {
background: #ee0000;
}
.active {
background: #00bb00;
color: #ffffff;
}
.active:hover {
background: #009900;
}
#sidebar {
display: block;
position: absolute;
Expand Down