@Test public void testGetRoots() { DAG<Integer> dag = DAG.of(1, 2, 3); Collection<Node<Integer>> roots = dag.getRoots(); assertEquals(3, roots.size()); assertTrue(roots.contains(new Node<>(1))); assertTrue(roots.contains(new Node<>(2))); assertTrue(roots.contains(new Node<>(3))); }
public Collection<Node<T>> getRoots() { return roots; }
DAG { public Collection<Node<T>> getRoots() { return roots; } }
DAG { public Collection<Node<T>> getRoots() { return roots; } private  DAG(); }
DAG { public Collection<Node<T>> getRoots() { return roots; } private  DAG(); static DAG<T> empty(); @SuppressWarnings("unchecked") static DAG<T> of(T ...rootElements); static DAG<T> of(Iterable<T> rootElements); @SafeVarargs final DAG<T> add(T elem, T... parents); DAG<T> add(T elem, List<T> parents); Node<T> getNode(T elem); Collection<Node<T>> getRoots(); Collection<Node<T>> getLeafs(); DAG<T> parentSubGraph(T elem); int size(); Stream<T> nodes(); Stream<Node<T>> traverse(); @Override String toString(); }
DAG { public Collection<Node<T>> getRoots() { return roots; } private  DAG(); static DAG<T> empty(); @SuppressWarnings("unchecked") static DAG<T> of(T ...rootElements); static DAG<T> of(Iterable<T> rootElements); @SafeVarargs final DAG<T> add(T elem, T... parents); DAG<T> add(T elem, List<T> parents); Node<T> getNode(T elem); Collection<Node<T>> getRoots(); Collection<Node<T>> getLeafs(); DAG<T> parentSubGraph(T elem); int size(); Stream<T> nodes(); Stream<Node<T>> traverse(); @Override String toString();  }