@Test public void testNeighbors() { Global.randomSeed(); DGraph<String> graph = new DiskDGraph(r()); DNode<String> a = graph.add("a"); DNode<String> b = graph.add("b"); DNode<String> c = graph.add("c"); a.connect(a); b.connect(c); c.connect(a); a.connect(c); a.connect(c); Set<Node<String>> aNbsExpected = new HashSet<Node<String>>(Arrays.asList(a, c)); Set<Node<String>> bNbsExpected = new HashSet<Node<String>>(Arrays.asList(c)); Set<Node<String>> cNbsExpected = new HashSet<Node<String>>(Arrays.asList(b, a)); Set<Node<String>> aNbsActual = new HashSet<Node<String>>(a.neighbors()); Set<Node<String>> bNbsActual = new HashSet<Node<String>>(b.neighbors()); Set<Node<String>> cNbsActual = new HashSet<Node<String>>(c.neighbors()); assertEquals(aNbsExpected, aNbsActual); assertEquals(bNbsExpected, bNbsActual); assertEquals(cNbsExpected, cNbsActual); }
@Override public DNode<String> add(String label) { if(nullLabels && label != null) throw new IllegalArgumentException("Graph is set to null labels only."); if(! nullLabels) labels.add(label); in.add(new ArrayList<Integer>(2)); out.add(new ArrayList<Integer>(2)); sorted = false; return new DiskDNode(in.size() - 1); }
DiskDGraph implements DGraph<String>, FastWalkable<String, DNode<String>> { @Override public DNode<String> add(String label) { if(nullLabels && label != null) throw new IllegalArgumentException("Graph is set to null labels only."); if(! nullLabels) labels.add(label); in.add(new ArrayList<Integer>(2)); out.add(new ArrayList<Integer>(2)); sorted = false; return new DiskDNode(in.size() - 1); } }
DiskDGraph implements DGraph<String>, FastWalkable<String, DNode<String>> { @Override public DNode<String> add(String label) { if(nullLabels && label != null) throw new IllegalArgumentException("Graph is set to null labels only."); if(! nullLabels) labels.add(label); in.add(new ArrayList<Integer>(2)); out.add(new ArrayList<Integer>(2)); sorted = false; return new DiskDNode(in.size() - 1); } DiskDGraph(File dbFile);  DiskDGraph(File dbFile, boolean nullLabels); }
DiskDGraph implements DGraph<String>, FastWalkable<String, DNode<String>> { @Override public DNode<String> add(String label) { if(nullLabels && label != null) throw new IllegalArgumentException("Graph is set to null labels only."); if(! nullLabels) labels.add(label); in.add(new ArrayList<Integer>(2)); out.add(new ArrayList<Integer>(2)); sorted = false; return new DiskDNode(in.size() - 1); } 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>> { @Override public DNode<String> add(String label) { if(nullLabels && label != null) throw new IllegalArgumentException("Graph is set to null labels only."); if(! nullLabels) labels.add(label); in.add(new ArrayList<Integer>(2)); out.add(new ArrayList<Integer>(2)); sorted = false; return new DiskDNode(in.size() - 1); } 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; }