Tree with combined nodes

Our current tree has the following structure

OA--RB--OC--RD--OE
| |
| |
| --RF--OG
|
--RH-OI--RJ--OE
So the top is Object A, which has 2 children RB and RH ,
RB has 1 child OC that again has two children RD, RF each having 1 child
and RH has 1 child too.
All of them are objects in the same database table, having a unique key.
The ones starting with R actually have a special purpose , they are objects that are used to describe the Relation between 2 objects, so
RB describes the relation between OA and OC for example. This also means that an Oobject can have multiple children where a Robject can only have one. And an Oobject can be in there multiple times but with a different relation object.
In the above example each of them their key is the second character.
The problem:
I can show the tree as above, but that is not what we want,
we want to combine the information of an Object and its parent Robject in a single node:
OA--RBOC--RDOE
| |
| |
| --RFOG
|
--RHOI--RJOE
I cannot use the keys A,B,C etc in this case, as A is linked to B, but B is not linked to D, it's C that is linkde to it. SO is it possible to have some kind of custom link between 2 nodes that :
  • is fixed,
  • is not visible.
Any other ways of accomplishing this?
Thanks
Ben

Well, the easiest thing might be to make those Rx–Oy links not Visible and to make the layer distance be zero or negative.

To make links not Part.Visible you can either iterate over all of the Diagram.Links to set that property. Or maybe you could data-bind the go:Part.Visible property in your link DataTemplate. You might need a custom Converter.

To customize the distance between layers, set TreeLayout.TreeStyle=“Alternating” and AlternateLayerSpacing=“0”. (The other “Alternate…” properties should be set the same as the corresponding regular properties, if you have changed them.)

Thanks, I took a different approach, in my SQL query I am able to get the Relation-Object as a single record instead of two. When adding nodes to the model, I recursively loop through these records based on the parent-child relation and create unique identifiers for each record and use these for the parent-child relation.

And for most of the different trees we have it works, but one of them gives an error and I am unable to determine what the difference is between the not working and the working models. Just examining the node that causes the failure reveals nothing special. The problem occurs when the tree is being drawn and the stack trace is:
Value cannot be null.
Parametername: key
bij System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
bij System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
bij System.Collections.Generic.Dictionary`2.ContainsKey(TKey key)
bij Northwoods.GoXam.HashSet`1.Contains(T x)
bij Northwoods.GoXam.Model.GraphLinksModel`4.GetConnectedNodesForNode(NodeType nodedata, Predicate`1 portpred)
bij Northwoods.GoXam.Model.GraphLinksModel`4.#Om(Object nodedata)
bij Northwoods.GoXam.Node.get_NodesConnected()
bij Northwoods.GoXam.Layout.TreeLayout.AddComments(TreeVertex v)
bij Northwoods.GoXam.Layout.TreeLayout.#Eh()
bij Northwoods.GoXam.Layout.TreeLayout.DoLayout(IEnumerable`1 nodes, IEnumerable`1 links)
bij Northwoods.GoXam.LayoutManager.PerformLayout()
bij Northwoods.GoXam.LayoutManager.#Xf()
What key would this be?
Below some of the nodes used, testing reveals that the error occurs at the 10th node being added, if I stop before that the tree is shown, modelnode[0] is the parent, modelnode[8] is OK, the problem starts with modelnode[9] (and if I skip that one modelnode[10] causes it too, I have no idea where to look for.
?modelNodes[0] {1} base {Northwoods.GoXam.Model.GraphModelNodeData}: {1} Details: "JBF Holding" Entity: {tblObjectTree : {00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000000}} Name: "Parent" ObjectLinkID: "1" Parent: "00000000-0000-0000-0000-000000000000" ParentLinkID: "0" ParentNode: null Spouses: null ?modelNodes[8] {9} base {Northwoods.GoXam.Model.GraphModelNodeData}: {9} Details: "WRAP" Entity: {tblObjectTree : {05d13cf6-9f36-414e-8999-ef4dff4b7b30,2c3c4f90-7c1c-494c-ae8b-321f28737d40}} Name: "Werkmaatschappij" ObjectLinkID: "9" Parent: "05d13cf6-9f36-414e-8999-ef4dff4b7b30" ParentLinkID: "1" ParentNode: {1} Spouses: null ?modelNodes[9] {10} base {Northwoods.GoXam.Model.GraphModelNodeData}: {10} Details: "WRAP" Entity: {tblObjectTree : {05d13cf6-9f36-414e-8999-ef4dff4b7b30,0ebfc110-e6bc-491a-9825-440d737c7db4}} Name: "Werkmaatschappij" ObjectLinkID: "10" Parent: "05d13cf6-9f36-414e-8999-ef4dff4b7b30" ParentLinkID: "1" ParentNode: {1} Spouses: null ?modelNodes[10] {11} base {Northwoods.GoXam.Model.GraphModelNodeData}: {11} Details: "WRAP" Entity: {tblObjectTree : {05d13cf6-9f36-414e-8999-ef4dff4b7b30,55bb295b-a4d7-458f-b781-68e19c830db5}} Name: "Werkmaatschappij" ObjectLinkID: "11" Parent: "05d13cf6-9f36-414e-8999-ef4dff4b7b30" ParentLinkID: "1" ParentNode: {1} Spouses: null

one more thing, If i catch the exception and let the code continue, all the nodes are there and they are correctly linked, but they are all on top of each other, I saw that the links are OK when I drag the nodes to some other place on the layout. Dragging a node causes the exception again btw.

Does it have something to do with the number of nodes maybe, that is drawn at one level?

I vaguely recall a null exception that we fixed a while ago. Precisely which version of which DLL are you using?

You might want to use the latest: latest DLLs.

Upon further inspection, I don’t think it’s something we fixed before. It appears to be a problem with the fact that your “root” node has a link to a GUID that is all zeroes. But there’s no node with that GUID. Did you create a link data for this non-existing “parent” relationship?

One thing that we haven’t done yet is add an option to the models to ignore node references that are the default value for NodeKeys that are value types. That means to ignore 0 when the NodeKey is of type int. And in your case, the all-zero Guid.

We’d have to make that an option, since it could be interpreted as an incompatible change. Although it might be a desired one, given that it might be causing unrealized bugs in programs, including (apparently) in our own code (in this case, TreeLayout).

I am using version 1.1.8.3

And it has something to do with the actual number of nodes, as skipping two records in the beginning, will allow to show the nodes that I thought uased the problem to show correctly, but now nodes alter added are causing a problem...
As I am generating the ID's for linking the nodes myself, The GUID is not very important. However in adding the links I had :
foreach (ObjectNode pn in model.NodesSource) { if (pn.ParentLinkID !=null) familyLinks.Add(new UniversalLinkData() { To = pn.ObjectLinkID, From = pn.ParentLinkID, Category = "Child" }); //if (pn.Spouses != null) // foreach (String str in pn.Spouses) // familyLinks.Add(new UniversalLinkData() { To = pn.Name, From = str, Category = "Marriage" }); }
The problem was that I explicitly set the ParentLinkID to "0" of the root node, and because the test above was for null, the link was therefor indeed incorrectly added.