Skip to content

Commit 73d05f5

Browse files
fixed issue with missing edges between cycles
1 parent b108b6f commit 73d05f5

File tree

1 file changed

+41
-40
lines changed

1 file changed

+41
-40
lines changed

src/views/Graph.vue

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ fragment FamilyProxyData on FamilyProxy {
189189
isRunahead
190190
isQueued
191191
name
192-
ancestors {
193-
name
194-
}
192+
ancestors {
193+
name
194+
}
195195
childTasks {
196196
id
197197
}
@@ -449,11 +449,7 @@ export default {
449449
* @returns {String[]} array containing nested structure of families
450450
*/
451451
treeDropDownCycle () {
452-
return this.cycleArrayStore.map((name, id) => ({
453-
id,
454-
name,
455-
disabled: false
456-
}))
452+
return this.cycleArrayStore.map((name) => ({ name }))
457453
},
458454
/**
459455
* Object for looking up family ancestors
@@ -1297,9 +1293,10 @@ export default {
12971293
// ...now we have a node - we have to understand all its relations in the graph...
12981294
if (indexSearch) {
12991295
// ---------------REMOVE NODES BASED ON FAMILY------------
1300-
// ṃust do this before removing nodes and edges based on cycle as
1296+
// must do this before removing nodes and edges based on cycle as
13011297
// cycle collapsing takes priority of families
1302-
// ...this node is collapsed so need to remove any of its children (nodes and edges) from the graph if it has any...
1298+
// ...this node is collapsed so need to remove any of its children
1299+
// (nodes and edges) from the graph if it has any...
13031300
for (const config of this.allChildrenLookUp[indexSearch.id]) {
13041301
if (config.name !== indexSearch.name) {
13051302
// REMOVE NODES
@@ -1450,26 +1447,28 @@ export default {
14501447
const edgeCheckSource = this.checkForEdgeBySource(config.name, cycle, removedEdges)
14511448
if (edgeCheckSource) {
14521449
for (const edge of edgeCheckSource) {
1450+
const sourceCycle = this.cylcTree.$index[edge.node.source].tokens.cycle
14531451
const targetName = this.cylcTree.$index[edge.node.target].name
14541452
const targetCycle = this.cylcTree.$index[edge.node.target].tokens.cycle
1455-
// only want one edge that goes to a different cycle point
1456-
if (targetCycle !== cycle) {
1457-
if (this.collapseCycle.includes(targetCycle)) {
1458-
// this collapsed cycle => next collapsed cycle
1459-
this.edgeTemplate = this.createEdge('collapsedSourceAndTarget', cycle, targetCycle, cycle, targetCycle)
1460-
edges.push(this.edgeTemplate)
1461-
} else {
1462-
const firstParent = this.cylcTree.$index[edge.node.target].node.firstParent
1463-
const isFirstParentCollapsed = this.collapseFamily.includes(firstParent.name)
1464-
const isAncestorCollapsed = this.allParentLookUp[firstParent.name].some(element => {
1465-
return this.collapseFamily.includes(element)
1466-
})
1467-
if (!isAncestorCollapsed && !isFirstParentCollapsed) {
1468-
// this collapsed cycle => next cycle
1469-
this.edgeTemplate = this.createEdge('collapsedSource', cycle, targetName, cycle, targetCycle)
1453+
const targetFamilyName = this.cylcTree.$index[edge.node.target].node.firstParent.name
1454+
1455+
if (targetCycle !== sourceCycle) {
1456+
// edge has collapsed source cycle only
1457+
if (!this.collapseCycle.includes(targetCycle) && this.collapseCycle.includes(sourceCycle)) {
1458+
if (this.isNodeCollapsedByFamily(targetFamilyName)) {
1459+
this.edgeTemplate = this.createEdge('collapsedSource', sourceCycle, this.isNodeCollapsedByFamily(targetFamilyName), sourceCycle, targetCycle)
1460+
edges.push(this.edgeTemplate)
1461+
} else {
1462+
this.edgeTemplate = this.createEdge('collapsedSource', sourceCycle, targetName, sourceCycle, targetCycle)
14701463
edges.push(this.edgeTemplate)
14711464
}
14721465
}
1466+
1467+
// edge has collapsed target and source cycle
1468+
if (this.collapseCycle.includes(targetCycle) && this.collapseCycle.includes(sourceCycle)) {
1469+
this.edgeTemplate = this.createEdge('collapsedSourceAndTarget', sourceCycle, targetCycle, sourceCycle, targetCycle)
1470+
edges.push(this.edgeTemplate)
1471+
}
14731472
}
14741473
}
14751474
}
@@ -1478,24 +1477,26 @@ export default {
14781477
for (const edge of edgeCheckTarget) {
14791478
const sourceName = this.cylcTree.$index[edge.node.source].name
14801479
const sourceCycle = this.cylcTree.$index[edge.node.source].tokens.cycle
1481-
// only want one edge that goes to a different cycle point
1482-
if (sourceCycle !== cycle) {
1483-
if (this.collapseCycle.includes(sourceCycle)) {
1484-
// previous collapsed cycle => this collapsed cycle
1485-
this.edgeTemplate = this.createEdge('collapsedSourceAndTarget', sourceCycle, cycle, sourceCycle, cycle)
1486-
edges.push(this.edgeTemplate)
1487-
} else {
1488-
const firstParent = this.cylcTree.$index[edge.node.source].node.firstParent
1489-
const isFirstParentCollapsed = this.collapseFamily.includes(firstParent.name)
1490-
const isAncestorCollapsed = this.allParentLookUp[firstParent.name].some(element => {
1491-
return this.collapseFamily.includes(element)
1492-
})
1493-
if (!isAncestorCollapsed && !isFirstParentCollapsed) {
1494-
// previous cycle => this collapsed cycle
1495-
this.edgeTemplate = this.createEdge('collapsedTarget', sourceName, cycle, sourceCycle, cycle)
1480+
const targetCycle = this.cylcTree.$index[edge.node.target].tokens.cycle
1481+
const sourceFamilyName = this.cylcTree.$index[edge.node.source].node.firstParent.name
1482+
1483+
if (targetCycle !== sourceCycle) {
1484+
// edge has collapsed target cycle only
1485+
if (this.collapseCycle.includes(targetCycle) && !this.collapseCycle.includes(sourceCycle)) {
1486+
if (this.isNodeCollapsedByFamily(sourceFamilyName)) {
1487+
this.edgeTemplate = this.createEdge('collapsedTarget', this.isNodeCollapsedByFamily(sourceFamilyName), targetCycle, sourceCycle, targetCycle)
1488+
edges.push(this.edgeTemplate)
1489+
} else {
1490+
this.edgeTemplate = this.createEdge('collapsedTarget', sourceName, targetCycle, sourceCycle, targetCycle)
14961491
edges.push(this.edgeTemplate)
14971492
}
14981493
}
1494+
1495+
// edge has collapsed target and source cycle
1496+
if (this.collapseCycle.includes(targetCycle) && this.collapseCycle.includes(sourceCycle)) {
1497+
this.edgeTemplate = this.createEdge('collapsedSourceAndTarget', sourceCycle, targetCycle, sourceCycle, targetCycle)
1498+
edges.push(this.edgeTemplate)
1499+
}
14991500
}
15001501
}
15011502
}

0 commit comments

Comments
 (0)