I wonder if the order of the children is causing that. That is, in your scenario, the user selected “Male Child 2” and added a “Twin” which got put at the end of the list of parent links.

I suppose the thing to do would be to customize the order in which **LayoutVertex**es and **LayoutEdge**s are added to the **LayoutNetwork** in GenogramLayout.add.

```
GenogramLayout.prototype.add = function(net, parts, nonmemberonly) {
var coll = new go.Set().addAll(parts);
// consider all Nodes in the given collection
var it = coll.iterator;
while (it.next()) {
var node = it.value;
if (!(node instanceof go.Node)) continue;
if (!node.isLayoutPositioned || !node.isVisible()) continue;
if (nonmemberonly && node.containingGroup !== null) continue;
// if it's an unmarried Node, or if it's a Link Label Node, create a LayoutVertex for it
if (node.isLinkLabel) {
// get marriage Link
var link = node.labeledLink;
var spouseA = link.fromNode;
var spouseB = link.toNode;
// create vertex representing both husband and wife
var vertex = net.addNode(node);
// now define the vertex size to be big enough to hold both spouses
vertex.width = spouseA.actualBounds.width + 30 + spouseB.actualBounds.width;
vertex.height = Math.max(spouseA.actualBounds.height, spouseB.actualBounds.height);
vertex.focus = new go.Point(spouseA.actualBounds.width + 30 / 2, vertex.height / 2);
} else {
// don't add a vertex for any married person!
// instead, code above adds label node for marriage link
// assume a marriage Link has a label Node
if (!node.linksConnected.any(function(l) { return l.isLabeledLink; })) {
var vertex = net.addNode(node);
}
}
}
// now do all Links
it.reset();
while (it.next()) {
var link = it.value;
if (!(link instanceof go.Link)) continue;
if (!link.isLayoutPositioned || !link.isVisible()) continue;
if (nonmemberonly && link.containingGroup !== null) continue;
// if it's a parent-child link, add a LayoutEdge for it
if (!link.isLabeledLink) {
var parent = net.findVertex(link.fromNode); // should be a label node
var child = net.findVertex(link.toNode);
if (child !== null) { // an unmarried child
net.linkVertexes(parent, child, link);
} else { // a married child
link.toNode.linksConnected.each(function(l) {
if (!l.isLabeledLink) return; // if it has no label node, it's a parent-child link
// found the Marriage Link, now get its label Node
var mlab = l.labelNodes.first();
// parent-child link should connect with the label node,
// so the LayoutEdge should connect with the LayoutVertex representing the label node
var mlabvert = net.findVertex(mlab);
if (mlabvert !== null) {
net.linkVertexes(parent, mlabvert, link);
}
});
}
}
}
// sort the children for each marriage vertex
var allv = new go.Set().addAll(net.vertexes);
allv.each(function(mv) {
if (mv.node === null || !mv.node.isLinkLabel) return;
var edgelist = new go.List();
mv.destinationEdges.each(function(e) {
// remember each edge, the child vertex, and all of the edges coming out from the child vertex
edgelist.add([e.toVertex, e, new go.List().addAll(e.toVertex.edges)]);
});
edgelist.each(function(kvp) {
var child = kvp[0];
net.deleteVertex(child); // also deletes edge to child and all edges coming out from child
});
edgelist.sort(function(ea, eb) {
// compare ea[0].node with eb[0].node
return 1 or 0 or -1 //???
});
//// for debugging:
//edgelist.each(function(kvp) {
// var parentstr = mv.node.labeledLink.fromNode.data.n + "&" + mv.node.labeledLink.toNode.data.n;
// var child = kvp[0].node;
// var childstr = child.isLinkLabel ?
// child.labeledLink.fromNode.data.n + "&" + child.labeledLink.toNode.data.n :
// child.data.n;
// console.log(parentstr + ": " + childstr);
//});
edgelist.each(function(kvp) {
var child = kvp[0];
net.addVertex(child);
var parentedge = kvp[1];
net.addEdge(parentedge);
var childedges = kvp[2];
childedges.each(function(e) { net.addEdge(e); });
});
});
};
```

You’ll need to customize the function passed to **sort**. Note that the presence of marriages to either or both of the twins will affect the order of children, in any case.

This is rather tricky, which is why I took the trouble to implement the framework for you. Most of the code is the same as for the regular GenogramLayout.add. But you’ll need to spend a good bit of time learning about and adapting the code.