@Test public void testNeighborsFast() { Global.randomSeed(); DGraph<String> graph = Examples.physicians(); graph = DiskDGraph.copy(graph, r()); assertTrue(graph instanceof FastWalkable); for(Node<String> node : graph.nodes()) { Collection<? extends Node<String>> nbs = node.neighbors(); Collection<? extends Node<String>> col = ((FastWalkable<String,? extends Node<String>>)graph).neighborsFast(node); Set<Node<String>> nbsFast = new HashSet<Node<String>>(col); assertTrue(col instanceof List<?>); List<Integer> nbsList = new ArrayList<Integer>(); for(Node<String> nod : nbs) nbsList.add(nod.index()); List<Integer> nbsFastList = new ArrayList<Integer>(); for(Node<String> nod : nbsFast) nbsFastList.add(nod.index()); Collections.sort(nbsList); Collections.sort(nbsFastList); assertEquals(nbsList, nbsFastList); } }
@Override public List<DNode<String>> neighborsFast(Node<String> node) { if(node.graph() != this) throw new IllegalArgumentException("Cannot call with node from another graph."); int index = node.index(); List<Integer> indices = concat(in.get(index), out.get(index)); return new NodeList(indices); }
DiskDGraph implements DGraph<String>, FastWalkable<String, DNode<String>> { @Override public List<DNode<String>> neighborsFast(Node<String> node) { if(node.graph() != this) throw new IllegalArgumentException("Cannot call with node from another graph."); int index = node.index(); List<Integer> indices = concat(in.get(index), out.get(index)); return new NodeList(indices); } }
DiskDGraph implements DGraph<String>, FastWalkable<String, DNode<String>> { @Override public List<DNode<String>> neighborsFast(Node<String> node) { if(node.graph() != this) throw new IllegalArgumentException("Cannot call with node from another graph."); int index = node.index(); List<Integer> indices = concat(in.get(index), out.get(index)); return new NodeList(indices); } DiskDGraph(File dbFile);  DiskDGraph(File dbFile, boolean nullLabels); }
DiskDGraph implements DGraph<String>, FastWalkable<String, DNode<String>> { @Override public List<DNode<String>> neighborsFast(Node<String> node) { if(node.graph() != this) throw new IllegalArgumentException("Cannot call with node from another graph."); int index = node.index(); List<Integer> indices = concat(in.get(index), out.get(index)); return new NodeList(indices); } 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 List<DNode<String>> neighborsFast(Node<String> node) { if(node.graph() != this) throw new IllegalArgumentException("Cannot call with node from another graph."); int index = node.index(); List<Integer> indices = concat(in.get(index), out.get(index)); return new NodeList(indices); } 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; }