I am modeling a power subsystem in Java. A simple SQLite database contains a set of Line Replaceable Units (LRUs) and the connections between them. I am writing a Power Mode
FWIW if someone wants a standard-libraries only solution, A map of sets or a map of other collections might do the job too, although not as well.
For this particular problem. I've decided to use a LinkedListMultimap from Guava.
As you can see if regarding the "related" questions, similar questions were already asked. And no, Java does not have a general-purpose graph/tree/DAG data type (if we don't count Swing's TreeModel).
Make your own one.
Here is an example (readonly) interface:
interface Node<N extends Node<N,E>, E extends Edge<N,E>> {
public Set<E> outgoingEdges();
public Set<E> ingoingEdges();
}
interface Edge<N extends Node<N,E>, E extends Edge<N,E>> {
public E source();
public E sink();
}
You would then have
interface LRU implements Node<LRU, Line> { ... }
interface Line implements Edge<LRU, Line> { ... }
(or classes instead).
I don't know if it can help but take a look at JGraphT.