Try this instead:
<!DOCTYPE html>
<html>
<head>
<title>Minimal GoJS Sample</title>
<!-- Copyright 1998-2023 by Northwoods Software Corporation. -->
</head>
<body>
<div id="myDiagramDiv" style="border: solid 1px black; width:100%; height:600px"></div>
<textarea id="mySavedModel" style="width:100%;height:250px"></textarea>
<script src="go.js"></script>
<script id="code">
const $ = go.GraphObject.make;
const myDiagram =
new go.Diagram("myDiagramDiv",
{
layout: $(go.TreeLayout,
{ layerSpacing: 80, setsPortSpot: false, setsChildPortSpot: false }),
"undoManager.isEnabled": true,
"ModelChanged": e => { // just for demonstration purposes,
if (e.isTransactionFinished) { // show the model data in the page's TextArea
document.getElementById("mySavedModel").textContent = e.model.toJson();
}
}
});
myDiagram.nodeTemplate =
$(go.Node, "Vertical",
$(go.Shape, "RoundedRectangle",
{ width: 40, height: 40, fill: "white" },
{ portId: "", fromSpot: go.Spot.LeftRightSides, toSpot: go.Spot.LeftRightSides },
new go.Binding("fill", "color")),
$(go.TextBlock,
{ margin: 2 },
new go.Binding("text"))
);
myDiagram.linkTemplate =
$(go.Link,
{ routing: go.Link.Orthogonal, corner: 5 },
$(go.Shape),
$(go.Shape, { toArrow: "OpenTriangle" }),
new go.Binding("isTreeLink", "tl"),
new go.Binding("isLayoutPositioned", "tl"),
);
myDiagram.model = new go.GraphLinksModel(
[
{ key: 1, text: "Alpha", color: "lightblue" },
{ key: 2, text: "Beta", color: "orange" },
{ key: 3, text: "Gamma", color: "lightgreen" },
{ key: 4, text: "Delta", color: "pink" }
],
[
{ from: 1, to: 2 },
{ from: 1, to: 3 },
{ from: 1, to: 4 },
{ from: 2, to: 1, tl: false },
{ from: 3, to: 1, tl: false },
{ from: 4, to: 1, tl: false },
]);
</script>
</body>
</html>
The result:

The only tricky thing is that the "back-"links are marked so that they do not participate in the layout, since apparently that confuses TreeLayout with deciding what the root is. I’m assuming that you want to keep things tree-like, even though the graph really isn’t due to all of the “up” links.