Skip to content

Commit da0808d

Browse files
committed
Fix missing edge between collapsed cycles that contain collapsed families
1 parent 4acb828 commit da0808d

File tree

1 file changed

+40
-43
lines changed

1 file changed

+40
-43
lines changed

src/views/Graph.vue

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,46 @@ export default {
11571157
})
11581158
const edges = this.getGraphEdges()
11591159
1160-
// ----------------------------------------
1160+
for (const cycle of this.collapseCycle) {
1161+
const cycleNode = this.cylcTree.$index[
1162+
this.workflows[0].tokens.clone({ cycle }).id
1163+
]
1164+
if (!cycleNode) continue
1165+
// ---------------REMOVE NODES BASED ON CYCLE POINT------------
1166+
// must do this before removing nodes/edges based on family as cycle collapsing takes priority over families
1167+
for (const { id } of this.allChildrenLookUp[cycleNode.id]) {
1168+
if (id !== cycleNode.id) {
1169+
// REMOVE NODES
1170+
nodes = nodes.filter((node) => node.id !== id)
1171+
// REMOVE EDGES
1172+
// if there is an edge with a source or target it needs removing
1173+
for (const edge of this.removeEdges(id, edges)) {
1174+
// ---------------ADD EDGES BASED ON CYCLE POINT------------
1175+
// prevent self-loop edges:
1176+
if (edge.source.cycle === edge.target.cycle) continue
1177+
1178+
const sourceName = this.collapseCycle.includes(edge.source.cycle)
1179+
? edge.source.cycle
1180+
: this.getCollapsedAncestor(edge.source.id) ?? edge.source.task
1181+
const targetName = this.collapseCycle.includes(edge.target.cycle)
1182+
? edge.target.cycle
1183+
: this.getCollapsedAncestor(edge.target.id) ?? edge.target.task
1184+
1185+
edges.set(
1186+
...this.createEdge({
1187+
sourceName,
1188+
sourceCycle: edge.source.cycle,
1189+
targetName,
1190+
targetCycle: edge.target.cycle,
1191+
})
1192+
)
1193+
}
1194+
}
1195+
}
1196+
// ---------------ADD NODES BASED ON CYCLE POINT------------
1197+
nodes.push(cycleNode)
1198+
}
1199+
11611200
for (const family of this.collapseFamily) {
11621201
for (const cycle of this.cycles) {
11631202
// ...get the node from the index...
@@ -1167,8 +1206,6 @@ export default {
11671206
if (!famNode) continue
11681207
// ...now we have a node - we have to understand all its relations in the graph...
11691208
// ---------------REMOVE NODES BASED ON FAMILY------------
1170-
// must do this before removing nodes and edges based on cycle as
1171-
// cycle collapsing takes priority of families
11721209
// ...this node is collapsed so need to remove any of its children
11731210
// (nodes and edges) from the graph if it has any...
11741211
for (const { id } of this.allChildrenLookUp[famNode.id]) {
@@ -1208,46 +1245,6 @@ export default {
12081245
}
12091246
}
12101247
}
1211-
for (const cycle of this.collapseCycle) {
1212-
const cycleNode = this.cylcTree.$index[
1213-
this.workflows[0].tokens.clone({ cycle }).id
1214-
]
1215-
if (!cycleNode) continue
1216-
// ---------------REMOVE NODES BASED ON CYCLE POINT------------
1217-
for (const { id } of this.allChildrenLookUp[cycleNode.id]) {
1218-
if (id !== cycleNode.id) {
1219-
// REMOVE NODES
1220-
nodes = nodes.filter((node) => node.id !== id)
1221-
// REMOVE EDGES
1222-
// if there is an edge with a source or target it needs removing
1223-
for (const edge of this.removeEdges(id, edges)) {
1224-
// ---------------ADD EDGES BASED ON CYCLE POINT------------
1225-
// prevent self-loop edges:
1226-
if (edge.source.cycle === edge.target.cycle) continue
1227-
1228-
const sourceName = this.collapseCycle.includes(edge.source.cycle)
1229-
? edge.source.cycle
1230-
: this.getCollapsedAncestor(edge.source.id) ?? edge.source.task
1231-
const targetName = this.collapseCycle.includes(edge.target.cycle)
1232-
? edge.target.cycle
1233-
: this.getCollapsedAncestor(edge.target.id) ?? edge.target.task
1234-
1235-
edges.set(
1236-
...this.createEdge({
1237-
sourceName,
1238-
sourceCycle: edge.source.cycle,
1239-
targetName,
1240-
targetCycle: edge.target.cycle,
1241-
})
1242-
)
1243-
}
1244-
}
1245-
}
1246-
// ---------------ADD NODES BASED ON CYCLE POINT------------
1247-
nodes.push(cycleNode)
1248-
}
1249-
1250-
// ----------------------------------------
12511248
12521249
if (!nodes || !nodes.length) {
12531250
// we can't graph this, reset and wait for something to draw

0 commit comments

Comments
 (0)