Skip to content

Commit

Permalink
keep consistency
Browse files Browse the repository at this point in the history
TianxinZu committed Mar 2, 2024
1 parent 8918fb9 commit ee7113c
Showing 1 changed file with 63 additions and 36 deletions.
99 changes: 63 additions & 36 deletions js/app.js
Original file line number Diff line number Diff line change
@@ -754,6 +754,16 @@ $(function () {

$("#auto-complete").on("click", function (event) {
event.preventDefault();

var shown = false;

// check if applied capacity is shown
cy.edges().forEach(function (edge) {
if (edge.css("label").includes("/")) {
shown = true;
}
});

// Call check graph function, update the graph
var expectedGraph = oldFlowNetwork.addFlow(selectedPath, flow, false);

@@ -771,31 +781,44 @@ $(function () {
}
}
}
for (const edge of originalFlowNetwork) {
var backward = cy
.edges("[source='" + edge.target + "'][target='" + edge.source + "']")
.css("label");
if (backward === undefined || backward === null || backward === "")
backward = "0";

addEdge(
cy,
edge.source + "/" + edge.target,
{
"line-color": "LightSkyBlue",
"target-arrow-color": "LightSkyBlue",
label: backward + "/" + edge.capacity,
},
edge.source,
edge.target
);

if (shown) {
for (const edge of originalFlowNetwork) {
var backward = cy
.edges("[source='" + edge.target + "'][target='" + edge.source + "']")
.css("label");
if (backward === undefined || backward === null || backward === "")
backward = "0";

addEdge(
cy,
edge.source + "/" + edge.target,
{
"line-color": "LightSkyBlue",
"target-arrow-color": "LightSkyBlue",
label: backward + "/" + edge.capacity,
},
edge.source,
edge.target
);
}
}

highlightSourceAndSink();
});

$("#undo-updates").on("click", function (event) {
event.preventDefault();

var shown = false;

// check if applied capacity is shown
cy.edges().forEach(function (edge) {
if (edge.css("label").includes("/")) {
shown = true;
}
});

cy.edges().remove();
for (const [_, neighborsMap] of oldFlowNetwork.graph) {
for (const [_, edge] of neighborsMap) {
@@ -810,25 +833,29 @@ $(function () {
}
}
}
for (const edge of originalFlowNetwork) {
var backward = cy
.edges("[source='" + edge.target + "'][target='" + edge.source + "']")
.css("label");
if (backward === undefined || backward === null || backward === "")
backward = "0";

addEdge(
cy,
edge.source + "/" + edge.target,
{
"line-color": "LightSkyBlue",
"target-arrow-color": "LightSkyBlue",
label: backward + "/" + edge.capacity,
},
edge.source,
edge.target
);

if (shown) {
for (const edge of originalFlowNetwork) {
var backward = cy
.edges("[source='" + edge.target + "'][target='" + edge.source + "']")
.css("label");
if (backward === undefined || backward === null || backward === "")
backward = "0";

addEdge(
cy,
edge.source + "/" + edge.target,
{
"line-color": "LightSkyBlue",
"target-arrow-color": "LightSkyBlue",
label: backward + "/" + edge.capacity,
},
edge.source,
edge.target
);
}
}

highlightSourceAndSink();
});

0 comments on commit ee7113c

Please sign in to comment.