@@ -1033,23 +1033,22 @@ export default {
1033
1033
}
1034
1034
1035
1035
const graphSections = {}
1036
- for (const [cycle , indexSearch ] of Object .entries (cyclesToNodes)) {
1037
- if (indexSearch .length && ! this .collapseCycle .includes (cycle)) {
1038
- for (const task of indexSearch ) {
1036
+ for (const [cycle , nodesInCycle ] of Object .entries (cyclesToNodes)) {
1037
+ if (nodesInCycle .length && ! this .collapseCycle .includes (cycle)) {
1038
+ for (const task of nodesInCycle ) {
1039
1039
const section = graphSections[task .node .firstParent .id ] ?? = []
1040
1040
section .push (` ${ task .name } [title=${ task .name } ]` )
1041
- graphSections[task .node .firstParent .id ] = section
1042
1041
}
1043
1042
if (this .groupCycle ) {
1044
1043
const removedNodes = new Set ()
1045
- for (const node of indexSearch ) {
1044
+ for (const node of nodesInCycle ) {
1046
1045
if (this .collapseFamily .includes (node .name )) {
1047
1046
for (const child of this .allChildrenLookUp [node .id ]) {
1048
1047
removedNodes .add (child .name )
1049
1048
}
1050
1049
}
1051
1050
}
1052
- const nodeFormattedArray = indexSearch .filter ((a ) => (
1051
+ const nodeFormattedArray = nodesInCycle .filter ((a ) => (
1053
1052
// if its not in the list of families (unless its been collapsed)
1054
1053
(! this .allParentLookUp .has (a .name ) || this .collapseFamily .includes (a .name )) &&
1055
1054
// the node has been removed/collapsed
@@ -1158,7 +1157,46 @@ export default {
1158
1157
})
1159
1158
const edges = this .getGraphEdges ()
1160
1159
1161
- // ----------------------------------------
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
+
1162
1200
for (const family of this .collapseFamily ) {
1163
1201
for (const cycle of this .cycles ) {
1164
1202
// ...get the node from the index...
@@ -1168,8 +1206,6 @@ export default {
1168
1206
if (! famNode) continue
1169
1207
// ...now we have a node - we have to understand all its relations in the graph...
1170
1208
// ---------------REMOVE NODES BASED ON FAMILY------------
1171
- // must do this before removing nodes and edges based on cycle as
1172
- // cycle collapsing takes priority of families
1173
1209
// ...this node is collapsed so need to remove any of its children
1174
1210
// (nodes and edges) from the graph if it has any...
1175
1211
for (const { id } of this .allChildrenLookUp [famNode .id ]) {
@@ -1209,46 +1245,6 @@ export default {
1209
1245
}
1210
1246
}
1211
1247
}
1212
- for (const cycle of this .collapseCycle ) {
1213
- const cycleNode = this .cylcTree .$index [
1214
- this .workflows [0 ].tokens .clone ({ cycle }).id
1215
- ]
1216
- if (! cycleNode) continue
1217
- // ---------------REMOVE NODES BASED ON CYCLE POINT------------
1218
- for (const { id } of this .allChildrenLookUp [cycleNode .id ]) {
1219
- if (id !== cycleNode .id ) {
1220
- // REMOVE NODES
1221
- nodes = nodes .filter ((node ) => node .id !== id)
1222
- // REMOVE EDGES
1223
- // if there is an edge with a source or target it needs removing
1224
- for (const edge of this .removeEdges (id, edges)) {
1225
- // ---------------ADD EDGES BASED ON CYCLE POINT------------
1226
- // prevent self-loop edges:
1227
- if (edge .source .cycle === edge .target .cycle ) continue
1228
-
1229
- const sourceName = this .collapseCycle .includes (edge .source .cycle )
1230
- ? edge .source .cycle
1231
- : this .getCollapsedAncestor (edge .source .id ) ?? edge .source .task
1232
- const targetName = this .collapseCycle .includes (edge .target .cycle )
1233
- ? edge .target .cycle
1234
- : this .getCollapsedAncestor (edge .target .id ) ?? edge .target .task
1235
-
1236
- edges .set (
1237
- ... this .createEdge ({
1238
- sourceName,
1239
- sourceCycle: edge .source .cycle ,
1240
- targetName,
1241
- targetCycle: edge .target .cycle ,
1242
- })
1243
- )
1244
- }
1245
- }
1246
- }
1247
- // ---------------ADD NODES BASED ON CYCLE POINT------------
1248
- nodes .push (cycleNode)
1249
- }
1250
-
1251
- // ----------------------------------------
1252
1248
1253
1249
if (! nodes || ! nodes .length ) {
1254
1250
// we can't graph this, reset and wait for something to draw
0 commit comments