@Test public void testCopy() { Global.randomSeed(); DGraph<String> graph = new MapDTGraph<String, String>(); 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); { int numLinks = 0; for(Link<String> link : graph.links()) numLinks++; assertEquals(5, numLinks); assertEquals(graph.numLinks(), numLinks); } graph = DiskDGraph.copy(graph, r()); { int numLinks = 0; for(Link<String> link : graph.links()) numLinks++; assertEquals(5, numLinks); assertEquals(graph.numLinks(), numLinks); } }
public static DiskUGraph copy(Graph<String> graph, File db) { DiskUGraph copy = new DiskUGraph(db); for(Node<String> node : graph.nodes()) copy.add(node.label()); for(Link<String> link : graph.links()) copy.get(link.first().index()).connect(copy.get(link.second().index())); return copy; }
DiskUGraph implements UGraph<String>, FastWalkable<String, UNode<String>> { public static DiskUGraph copy(Graph<String> graph, File db) { DiskUGraph copy = new DiskUGraph(db); for(Node<String> node : graph.nodes()) copy.add(node.label()); for(Link<String> link : graph.links()) copy.get(link.first().index()).connect(copy.get(link.second().index())); return copy; } }
DiskUGraph implements UGraph<String>, FastWalkable<String, UNode<String>> { public static DiskUGraph copy(Graph<String> graph, File db) { DiskUGraph copy = new DiskUGraph(db); for(Node<String> node : graph.nodes()) copy.add(node.label()); for(Link<String> link : graph.links()) copy.get(link.first().index()).connect(copy.get(link.second().index())); return copy; } DiskUGraph(File dbFile);  DiskUGraph(File dbFile, boolean nullLabels); }
DiskUGraph implements UGraph<String>, FastWalkable<String, UNode<String>> { public static DiskUGraph copy(Graph<String> graph, File db) { DiskUGraph copy = new DiskUGraph(db); for(Node<String> node : graph.nodes()) copy.add(node.label()); for(Link<String> link : graph.links()) copy.get(link.first().index()).connect(copy.get(link.second().index())); return copy; } DiskUGraph(File dbFile);  DiskUGraph(File dbFile, boolean nullLabels); @Override int size(); @Override long numLinks(); @Override UNode<String> node(String label); @Override Collection<? extends UNode<String>> nodes(String label); @Override List<? extends UNode<String>> nodes(); @Override Iterable<? extends ULink<String>> links(); @Override UNode<String> add(String label); @Override Set<String> labels(); @Override boolean connected(String from, String to); @Override long state(); String toString(); void sort(); static DiskUGraph copy(Graph<String> graph, File db); @Override int hashCode(); boolean equals(Object other); @Override UNode<String> get(int i); @SuppressWarnings("unchecked") @Override Class<? extends UGraph<String>> level(); @Override List<UNode<String>> neighborsFast(Node<String> node); static DiskUGraph fromDB(File dbFile); static DiskUGraph fromFile(File file, File dir); static DiskUGraph fromFile(File file, File tmpDir, File dbFile); void close(); }
DiskUGraph implements UGraph<String>, FastWalkable<String, UNode<String>> { public static DiskUGraph copy(Graph<String> graph, File db) { DiskUGraph copy = new DiskUGraph(db); for(Node<String> node : graph.nodes()) copy.add(node.label()); for(Link<String> link : graph.links()) copy.get(link.first().index()).connect(copy.get(link.second().index())); return copy; } DiskUGraph(File dbFile);  DiskUGraph(File dbFile, boolean nullLabels); @Override int size(); @Override long numLinks(); @Override UNode<String> node(String label); @Override Collection<? extends UNode<String>> nodes(String label); @Override List<? extends UNode<String>> nodes(); @Override Iterable<? extends ULink<String>> links(); @Override UNode<String> add(String label); @Override Set<String> labels(); @Override boolean connected(String from, String to); @Override long state(); String toString(); void sort(); static DiskUGraph copy(Graph<String> graph, File db); @Override int hashCode(); boolean equals(Object other); @Override UNode<String> get(int i); @SuppressWarnings("unchecked") @Override Class<? extends UGraph<String>> level(); @Override List<UNode<String>> neighborsFast(Node<String> node); static DiskUGraph fromDB(File dbFile); static DiskUGraph fromFile(File file, File dir); static DiskUGraph fromFile(File file, File tmpDir, File dbFile); void close(); static final int NEIGHBOR_CAPACITY; }