Structure to model multiple hierarchies on the same entities

27 Views Asked by At

Say I have a set of entities and multiple hierarchies based on them, each hierarchy modeling a different type of relationship. What would be a useful structure to model this scenario?

For instance, imagine this scenario:

  • Entities are software modules

  • There are two hierarchies in our mental model of the situation (I'm ignoring how we'd actually represent this on the filesystem for this question):

    1. "Technologically related" with edges from JSON to AccountJSON and BlogpostJSON, etc
    2. "Feature related" with edges from Account to AccountJSON and AccountUI, etc

One possibility is a labeled directed multigraph where the edges are labeled either tech or feature, but this misses at least one constraint: that if we look only at edges of one type they form a tree[1].

Another possibility is a multitree, but that disallows diamonds, and we can have diamonds when using edges of both labels.

Suggestions from outside of graph theory are also welcome. The fact that we're starting with trees/forests makes me think of graph theory, but maybe there's a better way to describe what happens when they're combined.

[1] Or a forest if the entities in a particular hierarchy aren't necessarily connected.