### Question:
LightDTGraph implements DTGraph<L, T> { public boolean equals(Object other) { if(!(other instanceof DTGraph<?,?>)) return false; DTGraph<Object,Object> oth = (DTGraph<Object,Object>) other; if(! oth.level().equals(level())) return false; if(size() != oth.size()) return false; if(numLinks() != oth.numLinks()) return false; if(labels().size() != oth.labels().size()) return false; for(DTNode<L,T> node : nodes()) { DTNode<Object,Object> othNode = oth.get(node.index()); if(! Functions.equals(node.label(), othNode.label())) return false; if (node.tags().size() != othNode.tags().size()) return false; for (T tag : node.tags()) { FrequencyModel<Integer> outs = new FrequencyModel<Integer>(), othOuts = new FrequencyModel<Integer>(); for(DTNode<L,T> neighbor : node.toTag(tag)) outs.add(neighbor.index()); for(DTNode<Object,Object> othNeighbor : othNode.toTag(tag)) othOuts.add(othNeighbor.index()); if(! outs.equals(othOuts)) return false; } } return true; } LightDTGraph();  LightDTGraph(int capacity); @Override Set<T> tags(); @Override int size(); @Override DTNode<L, T> node(L label); @Override Collection<? extends DTNode<L, T>> nodes(L label); @Override List<? extends DTNode<L, T>> nodes(); @Override DTNode<L, T> get(int i); @Override Iterable<? extends DTLink<L, T>> links(); @Override DTNode<L, T> add(L label); @Override long numLinks(); @Override Set<L> labels(); @Override boolean connected(L from, L to); @Override long state(); @SuppressWarnings("unchecked") @Override Class<? extends DTGraph<L, T>> level(); boolean equals(Object other); String toString(); static final int NEIGHBOR_CAPACITY; }### Answer:
@Test public void testEquals() { DTGraph<String,String> g1 = new LightDTGraph<String,String>(); g1.add("a"); g1.add("b"); g1.add("c"); g1.node("a").connect(g1.node("b"), "1"); g1.node("b").connect(g1.node("c"), "2"); DTGraph<String,String> g2 = new LightDTGraph<String,String>(); g2.add("a"); g2.add("b"); g2.add("c"); g2.node("a").connect(g2.node("b"), "1"); g2.node("b").connect(g2.node("c"), "2"); assertTrue(g1.equals(g2)); g2.node("a").connect(g2.node("c")); assertFalse(g1.equals(g2)); }
@Test public void testNotEquals() { DGraph<String> g1 = new LightDGraph<String>(); DTGraph<String, String> g2 = new LightDTGraph<String, String>(); assertFalse(g1.equals(g2)); assertFalse(g2.equals(g1)); }