I am modeling a strong subsystem in Java. A simple SQLite database contains a set of replaceable rows (LRUs) and the connections between them. I am writing a Power Model API to simplify data warehouse queries using DDD templates and repositories.
I am looking for a suitable Java collection for modeling query results. There are some special cases in the LRU connection stream that need to be modeled:
- Initially, there is a Power Distribution Unit (PDU) with multiple ports (<= 16) that supplies power to the downstream LRUs.
- Typical connections in a power stream include one LRU source where power is supplied, and one Sink LRU where power is low.
- However, in the downstream, there may be one LRU source connected to multiple LRUs.
- There are no cycles in the power stream.
Inclusion # 3 above led me to think of returning the results of an API request as a tree. But the only tree I found in java.util is the TreeMap key value, a paired red-black tree that doesn't seem (or I can't come up with an appropriate abstraction to model power flows with it.) I also consider LinkedHashSet , but I not sure if this is appropriate. I donโt understand how the node in this structure will point to the nodes downstream.
At the moment, I'm not interested in efficiency in time or space. My API just needs to work by delivering network connectivity information to external clients (i.e. the presentation layer of a Java-based monitoring and power management application). There are also no restrictions on the use of open source types / libraries.
In the common language of computer science, what I'm really looking for is Directed-Acyclic-Graph (DAG).
Is there an implementation for Java? Am I assuming DAG is suitable for my scenario?
source share