Here’s what I just tried. This includes overrides of makeNetwork and commitLayout. I cannot reproduce the odd behavior that you reported.
function ArrangingLDLayout() {
go.LayeredDigraphLayout.call(this);
this._singletons = null;
}
go.Diagram.inherit(ArrangingLDLayout, go.LayeredDigraphLayout);
ArrangingLDLayout.prototype.makeNetwork = function(coll) {
var net = go.LayeredDigraphLayout.prototype.makeNetwork.call(this, coll);
// delete all vertexes that have no edges
var singletons = new go.Set();
net.vertexes.each(function(v) {
if (v.edgesCount === 0 && v.node !== null) singletons.add(v.node);
});
singletons.each(function(n) {
net.deleteNode(n);
});
this._singletons = singletons; // remember for commitLayout
return net;
};
ArrangingLDLayout.prototype.commitLayout = function() {
go.LayeredDigraphLayout.prototype.commitLayout.call(this);
var p = this.arrangementOrigin.copy();
p.x += this.columnSpacing/2; // horizontal indent
this.network.vertexes.each(function(v) {
var n = v.node;
if (n === null) return;
p.y = Math.max(p.y, n.actualBounds.bottom);
});
p.y += 50; // vertical spacing
var hspace = this.columnSpacing;
this._singletons.each(function(n) {
n.move(p);
p.x += n.actualBounds.width + 50; // horizontal spacing
});
};
function init() {
var $ = go.GraphObject.make;
myDiagram =
$(go.Diagram, "myDiagramDiv",
{
initialContentAlignment: go.Spot.Center,
layout: $(ArrangingLDLayout, //go.LayeredDigraphLayout,
{ direction: 90, setsPortSpots: false })
});
myDiagram.nodeTemplate =
$(go.Node, "Auto",
{ fromSpot: go.Spot.TopBottomSides, toSpot: go.Spot.TopBottomSides },
$(go.Shape, { fill: "whitesmoke", stroke: "lightgray" }),
$(go.TextBlock, { margin: new go.Margin(10, 30) },
new go.Binding("text", "key"))
);
myDiagram.model = new go.GraphLinksModel([
{ key: "R" },
{ key: "S" },
{ key: "T" },
{ key: "U" },
{ key: "X" },
{ key: "X2" },
{ key: "X3" },
{ key: "Y" },
{ key: "Z" },
{ key: "A" },
{ key: "B" },
], [
{ from: "R", to: "T" },
{ from: "R", to: "U" },
{ from: "S", to: "X" },
//{ from: "S", to: "X2" },
//{ from: "S", to: "X3" },
{ from: "U", to: "Y" },
{ from: "U", to: "Z" }
]);
}