@Test public void testEquals() { DGraph<String> g1 = new LightDGraph<String>(); 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 LightDGraph<String>(); 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<L> 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<L> 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; }
LightDGraph implements DGraph<L>, FastWalkable<L, DNode<L>> { 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<L> 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<L> 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; } }
LightDGraph implements DGraph<L>, FastWalkable<L, DNode<L>> { 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<L> 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<L> 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; } LightDGraph();  LightDGraph(int capacity); }
LightDGraph implements DGraph<L>, FastWalkable<L, DNode<L>> { 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<L> 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<L> 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; } LightDGraph();  LightDGraph(int capacity); @Override int size(); @Override long numLinks(); @Override DNode<L> node(L label); @Override Collection<? extends DNode<L>> nodes(L label); @Override List<? extends DNode<L>> nodes(); @Override Iterable<? extends DLink<L>> links(); @Override DNode<L> add(L label); @Override Set<L> labels(); @Override boolean connected(L from, L to); @Override long state(); String toString(); void compact(int margin); void sort(); static LightDGraph<L> copy(Graph<L> graph); @Override int hashCode(); boolean equals(Object other); @Override DNode<L> get(int i); @SuppressWarnings("unchecked") @Override Class<? extends DGraph<L>> level(); @Override List<DNode<L>> neighborsFast(Node<L> node); }
LightDGraph implements DGraph<L>, FastWalkable<L, DNode<L>> { 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<L> 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<L> 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; } LightDGraph();  LightDGraph(int capacity); @Override int size(); @Override long numLinks(); @Override DNode<L> node(L label); @Override Collection<? extends DNode<L>> nodes(L label); @Override List<? extends DNode<L>> nodes(); @Override Iterable<? extends DLink<L>> links(); @Override DNode<L> add(L label); @Override Set<L> labels(); @Override boolean connected(L from, L to); @Override long state(); String toString(); void compact(int margin); void sort(); static LightDGraph<L> copy(Graph<L> graph); @Override int hashCode(); boolean equals(Object other); @Override DNode<L> get(int i); @SuppressWarnings("unchecked") @Override Class<? extends DGraph<L>> level(); @Override List<DNode<L>> neighborsFast(Node<L> node); static final int NEIGHBOR_CAPACITY; }