mardi 25 mai 2021

Graph - modelling node with two parents

I have a graph with nodes, and I need to follow from leaf to root, and to know the single path - even when there are two parents for some of the nodes. Example - Child is the same concept, that can belong to Parent 1 or Parent 2. Leaf 1 and Leaf 2 are also concepts that belong to Child either through Parent 1 or Parent 2. So it can happen that some nodes under Leaf 1 have parent structure of Parent 1 -> Child -> Leaf 1 -> * or Parent 2 -> Child -> Leaf 1 -> *. If modeled using the following approach, that information is lost:

enter image description here

So far, I have a few approaches to disambiguate this:

First one is duplicating all the nodes - everything is separated (at a cost of duplication).

enter image description here

Second one is using labels on the edges - but still duplicating some of the nodes:

enter image description here

And the third one is also using labels - without duplicating nodes, but labels are further away from parents:

enter image description here

Is there any other solution for this? Are there any best practices in modelling this kind of graph?

Aucun commentaire:

Enregistrer un commentaire