@Test public void testEquals() { UGraph<String> g1 = new LightUGraph<String>(); 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 LightUGraph<String>(); g2.add("a"); g2.add("b"); g2.add("c"); g2.node("b").connect(g2.node("c")); g2.node("a").connect(g2.node("b")); assertTrue(g1.equals(g2)); g2.node("a").connect(g2.node("c")); assertFalse(g1.equals(g2)); }
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<L> 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<L> 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; }
LightUGraph implements UGraph<L>, FastWalkable<L, UNode<L>> { 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<L> 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<L> 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; } }
LightUGraph implements UGraph<L>, FastWalkable<L, UNode<L>> { 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<L> 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<L> 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; } LightUGraph();  LightUGraph(int capacity); }
LightUGraph implements UGraph<L>, FastWalkable<L, UNode<L>> { 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<L> 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<L> 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; } LightUGraph();  LightUGraph(int capacity); @Override int size(); @Override long numLinks(); @Override UNode<L> node(L label); @Override Collection<? extends UNode<L>> nodes(L label); @Override List<? extends UNode<L>> nodes(); @Override Iterable<? extends ULink<L>> links(); @Override UNode<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 LightUGraph<L> copy(Graph<L> graph); @Override int hashCode(); boolean equals(Object other); @Override UNode<L> get(int i); @SuppressWarnings("unchecked") @Override Class<? extends UGraph<L>> level(); @Override List<UNode<L>> neighborsFast(Node<L> node); }
LightUGraph implements UGraph<L>, FastWalkable<L, UNode<L>> { 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<L> 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<L> 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; } LightUGraph();  LightUGraph(int capacity); @Override int size(); @Override long numLinks(); @Override UNode<L> node(L label); @Override Collection<? extends UNode<L>> nodes(L label); @Override List<? extends UNode<L>> nodes(); @Override Iterable<? extends ULink<L>> links(); @Override UNode<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 LightUGraph<L> copy(Graph<L> graph); @Override int hashCode(); boolean equals(Object other); @Override UNode<L> get(int i); @SuppressWarnings("unchecked") @Override Class<? extends UGraph<L>> level(); @Override List<UNode<L>> neighborsFast(Node<L> node); static final int NEIGHBOR_CAPACITY; }