graflow: autoplace uses live links
This commit is contained in:
22
bzGraflow.js
22
bzGraflow.js
@@ -659,17 +659,17 @@ class BZgraflow extends Buildoz{
|
|||||||
// Cleanup placeholders from previous autoPlace() runs.
|
// Cleanup placeholders from previous autoPlace() runs.
|
||||||
// Each run creates new longLinkPlaceHolder_* IDs; without cleanup they accumulate in the DOM.
|
// Each run creates new longLinkPlaceHolder_* IDs; without cleanup they accumulate in the DOM.
|
||||||
this.clearFakeNodes()
|
this.clearFakeNodes()
|
||||||
|
let links = Object.values(this.stagedWires).map(w => w?.link).filter(Boolean)
|
||||||
|
links = links.length ? links : (this.flow?.links || [])
|
||||||
// Loops create infinite recursion in dfs for getting parents & adjacency lists: Remove them !
|
// Loops create infinite recursion in dfs for getting parents & adjacency lists: Remove them !
|
||||||
let linksWithoutBackEdges
|
let linksWithoutBackEdges
|
||||||
if(this.hasAnyLoop(this.flow.nodes, this.flow.links)){
|
if(this.hasAnyLoop(this.flow.nodes, links)){
|
||||||
const backEdges = this.findBackEdges(this.flow.nodes, this.flow.links)
|
const backEdges = this.findBackEdges(this.flow.nodes, links)
|
||||||
linksWithoutBackEdges = this.flow.links.filter((link, idx) => (!backEdges.includes(idx)) && (link.from[0] != link.to[0]))
|
linksWithoutBackEdges = links.filter((link, idx) => (!backEdges.includes(idx)) && (link.from[0] != link.to[0]))
|
||||||
} else {
|
} else {
|
||||||
linksWithoutBackEdges = this.flow.links
|
linksWithoutBackEdges = links
|
||||||
}
|
}
|
||||||
const { parents, adj } = this.buildGraphStructures(this.flow.nodes, linksWithoutBackEdges)
|
const { parents, adj } = this.buildGraphStructures(this.flow.nodes, linksWithoutBackEdges)
|
||||||
console.log('parents', parents)
|
|
||||||
const layers = this.computeLayers(this.flow.nodes, parents)
|
const layers = this.computeLayers(this.flow.nodes, parents)
|
||||||
|
|
||||||
// Layer-0 nodes have no parents, so reorderLayers() (which uses parent ordering) cannot
|
// Layer-0 nodes have no parents, so reorderLayers() (which uses parent ordering) cannot
|
||||||
@@ -721,7 +721,7 @@ console.log('parents', parents)
|
|||||||
|
|
||||||
// If any long-links, create placeholders for skipped layers
|
// If any long-links, create placeholders for skipped layers
|
||||||
this._virtualLinks = new Map()
|
this._virtualLinks = new Map()
|
||||||
this.flow.longLinks = this.findLongLinks(this.flow.links)
|
this.flow.longLinks = this.findLongLinks(links)
|
||||||
for(const llink of this.flow.longLinks){
|
for(const llink of this.flow.longLinks){
|
||||||
let fakeParent = llink.link.from[0]
|
let fakeParent = llink.link.from[0]
|
||||||
for(const layerIdx of llink.skippedLayers){
|
for(const layerIdx of llink.skippedLayers){
|
||||||
@@ -1138,11 +1138,11 @@ console.log('parents', parents)
|
|||||||
|
|
||||||
findLongLinks(links) {
|
findLongLinks(links) {
|
||||||
let linksWithoutBackEdges
|
let linksWithoutBackEdges
|
||||||
if(this.hasAnyLoop(this.flow.nodes, this.flow.links)){
|
if(this.hasAnyLoop(this.flow.nodes, links)){
|
||||||
const backEdges = this.findBackEdges(this.flow.nodes, this.flow.links)
|
const backEdges = this.findBackEdges(this.flow.nodes, links)
|
||||||
linksWithoutBackEdges = this.flow.links.filter((link, idx) => (!backEdges.includes(idx)) && (link.from[0] != link.to[0]))
|
linksWithoutBackEdges = links.filter((link, idx) => (!backEdges.includes(idx)) && (link.from[0] != link.to[0]))
|
||||||
} else {
|
} else {
|
||||||
linksWithoutBackEdges = this.flow.links
|
linksWithoutBackEdges = links
|
||||||
}
|
}
|
||||||
/// Yes that means we ignore long & back links !
|
/// Yes that means we ignore long & back links !
|
||||||
const { parents } = this.buildGraphStructures(this.flow.nodes, linksWithoutBackEdges)
|
const { parents } = this.buildGraphStructures(this.flow.nodes, linksWithoutBackEdges)
|
||||||
|
|||||||
Reference in New Issue
Block a user