### Question:
DiskUGraph implements UGraph<String>, FastWalkable<String, UNode<String>> { public boolean equals(Object other) { if(!(other instanceof UGraph<?>)) return false; UGraph<Object> oth = (UGraph<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(UNode<String> node : nodes()) { UNode<Object> othNode = oth.get(node.index()); if(! Functions.equals(node.label(), othNode.label())) return false; FrequencyModel<Integer> myNeighbors = new FrequencyModel<Integer>(), hisNeighbors = new FrequencyModel<Integer>(); for(UNode<String> myNeighbor : node.neighbors()) myNeighbors.add(myNeighbor.index()); for(UNode<Object> hisNeighbor : othNode.neighbors()) hisNeighbors.add(hisNeighbor.index()); if(! myNeighbors.equals(hisNeighbors)) return false; } return true; } DiskUGraph(File dbFile);  DiskUGraph(File dbFile, boolean nullLabels); @Override int size(); @Override long numLinks(); @Override UNode<String> node(String label); @Override Collection<? extends UNode<String>> nodes(String label); @Override List<? extends UNode<String>> nodes(); @Override Iterable<? extends ULink<String>> links(); @Override UNode<String> add(String label); @Override Set<String> labels(); @Override boolean connected(String from, String to); @Override long state(); String toString(); void sort(); static DiskUGraph copy(Graph<String> graph, File db); @Override int hashCode(); boolean equals(Object other); @Override UNode<String> get(int i); @SuppressWarnings("unchecked") @Override Class<? extends UGraph<String>> level(); @Override List<UNode<String>> neighborsFast(Node<String> node); static DiskUGraph fromDB(File dbFile); static DiskUGraph fromFile(File file, File dir); static DiskUGraph fromFile(File file, File tmpDir, File dbFile); void close(); static final int NEIGHBOR_CAPACITY; }### Answer:
@Test public void testEquals() { Global.randomSeed(); UGraph<String> g1 = new DiskUGraph(r()); g1.add("a"); g1.add("b"); g1.add("c"); g1.node("a").connect(g1.node("b")); g1.node("b").connect(g1.node("c")); UGraph<String> g2 = new DiskUGraph(r()); g2.add("a"); g2.add("b"); g2.add("c"); g2.node("a").connect(g2.node("b")); g2.node("b").connect(g2.node("c")); assertTrue(g1.equals(g2)); g2.node("a").connect(g2.node("c")); assertFalse(g1.equals(g2)); }
@Test public void testNotEquals() { Global.randomSeed(); UGraph<String> g1 = new DiskUGraph(r()); UTGraph<String, String> g2 = new MapUTGraph<String, String>(); assertFalse(g1.equals(g2)); assertFalse(g2.equals(g1)); }