Quellcode durchsuchen

Changes inlining behaviour in TrimTree

If we are deleting a node N, if the edge between N and its parent and
the edge between N and its child are both inline, then the resulting
residual edge from N's parent and the child will also be inline.
Wade Simba Khadder vor 8 Jahren
Ursprung
Commit
a6e308c932
1 geänderte Dateien mit 6 neuen und 3 gelöschten Zeilen
  1. 6
    3
      internal/graph/graph.go

+ 6
- 3
internal/graph/graph.go Datei anzeigen

@@ -18,7 +18,6 @@ package graph
18 18
 import (
19 19
 	"fmt"
20 20
 	"math"
21
-	"os"
22 21
 	"path/filepath"
23 22
 	"sort"
24 23
 	"errors"
@@ -370,6 +369,8 @@ func (g *Graph) TrimTree(kept NodeSet) {
370 369
 			parent = edge.Src
371 370
 		}
372 371
 
372
+		parentEdgeInline := parent.Out[cur].Inline
373
+
373 374
 		// Remove the edge from the parent to this node
374 375
 		delete(parent.Out, cur)
375 376
 
@@ -383,8 +384,10 @@ func (g *Graph) TrimTree(kept NodeSet) {
383 384
 
384 385
 			outEdge.Src = parent
385 386
 			outEdge.Residual = true
386
-			// Any reconfigured edge can no longer be Inline.
387
-			outEdge.Inline = false
387
+			// If the edge from the parent to the current node and the edge from the
388
+			// current node to the child are both inline, then this resulting residual
389
+			// edge should also be inline
390
+			outEdge.Inline = parentEdgeInline && outEdge.Inline
388 391
 		}
389 392
 	}
390 393
 	g.RemoveRedundantEdges()