@Test public void testEquals() { Global.randomSeed(); DGraph<String> g1 = new DiskDGraph(r()); g1.add("a"); g1.add("b"); g1.add("c"); g1.node("a").connect(g1.node("b")); g1.node("b").connect(g1.node("c")); DGraph<String> g2 = new DiskDGraph(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)); }
public boolean equals(Object other) { if(!(other instanceof DGraph<?>)) return false; DGraph<Object> oth = (DGraph<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(DNode<String> node : nodes()) { DNode<Object> othNode = oth.get(node.index()); if(! Functions.equals(node.label(), othNode.label())) return false; FrequencyModel<Integer> outs = new FrequencyModel<Integer>(), othOuts = new FrequencyModel<Integer>(); for(DNode<String> neighbor : node.out()) outs.add(neighbor.index()); for(DNode<Object> othNeighbor : othNode.out()) othOuts.add(othNeighbor.index()); if(! outs.equals(othOuts)) return false; } return true; }
DiskDGraph implements DGraph<String>, FastWalkable<String, DNode<String>> { public boolean equals(Object other) { if(!(other instanceof DGraph<?>)) return false; DGraph<Object> oth = (DGraph<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(DNode<String> node : nodes()) { DNode<Object> othNode = oth.get(node.index()); if(! Functions.equals(node.label(), othNode.label())) return false; FrequencyModel<Integer> outs = new FrequencyModel<Integer>(), othOuts = new FrequencyModel<Integer>(); for(DNode<String> neighbor : node.out()) outs.add(neighbor.index()); for(DNode<Object> othNeighbor : othNode.out()) othOuts.add(othNeighbor.index()); if(! outs.equals(othOuts)) return false; } return true; } }
DiskDGraph implements DGraph<String>, FastWalkable<String, DNode<String>> { public boolean equals(Object other) { if(!(other instanceof DGraph<?>)) return false; DGraph<Object> oth = (DGraph<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(DNode<String> node : nodes()) { DNode<Object> othNode = oth.get(node.index()); if(! Functions.equals(node.label(), othNode.label())) return false; FrequencyModel<Integer> outs = new FrequencyModel<Integer>(), othOuts = new FrequencyModel<Integer>(); for(DNode<String> neighbor : node.out()) outs.add(neighbor.index()); for(DNode<Object> othNeighbor : othNode.out()) othOuts.add(othNeighbor.index()); if(! outs.equals(othOuts)) return false; } return true; } DiskDGraph(File dbFile);  DiskDGraph(File dbFile, boolean nullLabels); }
DiskDGraph implements DGraph<String>, FastWalkable<String, DNode<String>> { public boolean equals(Object other) { if(!(other instanceof DGraph<?>)) return false; DGraph<Object> oth = (DGraph<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(DNode<String> node : nodes()) { DNode<Object> othNode = oth.get(node.index()); if(! Functions.equals(node.label(), othNode.label())) return false; FrequencyModel<Integer> outs = new FrequencyModel<Integer>(), othOuts = new FrequencyModel<Integer>(); for(DNode<String> neighbor : node.out()) outs.add(neighbor.index()); for(DNode<Object> othNeighbor : othNode.out()) othOuts.add(othNeighbor.index()); if(! outs.equals(othOuts)) return false; } return true; } DiskDGraph(File dbFile);  DiskDGraph(File dbFile, boolean nullLabels); @Override int size(); @Override long numLinks(); @Override DNode<String> node(String label); @Override Collection<? extends DNode<String>> nodes(String label); @Override List<? extends DNode<String>> nodes(); @Override Iterable<? extends DLink<String>> links(); @Override DNode<String> add(String label); @Override Set<String> labels(); @Override boolean connected(String from, String to); @Override long state(); String toString(); void sort(); static DiskDGraph copy(Graph<String> graph, File db); @Override int hashCode(); boolean equals(Object other); @Override DNode<String> get(int i); @SuppressWarnings("unchecked") @Override Class<? extends DGraph<String>> level(); @Override List<DNode<String>> neighborsFast(Node<String> node); static DiskDGraph fromDB(File dbFile); static DiskDGraph fromFile(File file, File dir); static DiskDGraph fromFile(File file, File tmpDir, File dbFile); void close(); }
DiskDGraph implements DGraph<String>, FastWalkable<String, DNode<String>> { public boolean equals(Object other) { if(!(other instanceof DGraph<?>)) return false; DGraph<Object> oth = (DGraph<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(DNode<String> node : nodes()) { DNode<Object> othNode = oth.get(node.index()); if(! Functions.equals(node.label(), othNode.label())) return false; FrequencyModel<Integer> outs = new FrequencyModel<Integer>(), othOuts = new FrequencyModel<Integer>(); for(DNode<String> neighbor : node.out()) outs.add(neighbor.index()); for(DNode<Object> othNeighbor : othNode.out()) othOuts.add(othNeighbor.index()); if(! outs.equals(othOuts)) return false; } return true; } DiskDGraph(File dbFile);  DiskDGraph(File dbFile, boolean nullLabels); @Override int size(); @Override long numLinks(); @Override DNode<String> node(String label); @Override Collection<? extends DNode<String>> nodes(String label); @Override List<? extends DNode<String>> nodes(); @Override Iterable<? extends DLink<String>> links(); @Override DNode<String> add(String label); @Override Set<String> labels(); @Override boolean connected(String from, String to); @Override long state(); String toString(); void sort(); static DiskDGraph copy(Graph<String> graph, File db); @Override int hashCode(); boolean equals(Object other); @Override DNode<String> get(int i); @SuppressWarnings("unchecked") @Override Class<? extends DGraph<String>> level(); @Override List<DNode<String>> neighborsFast(Node<String> node); static DiskDGraph fromDB(File dbFile); static DiskDGraph fromFile(File file, File dir); static DiskDGraph fromFile(File file, File tmpDir, File dbFile); void close(); static final int NEIGHBOR_CAPACITY; }