### Question:
LightDGraph implements DGraph<L>, FastWalkable<L, DNode<L>> { public static <L> LightDGraph<L> copy(Graph<L> graph) { LightDGraph<L> copy = new LightDGraph<L>(graph.size()); for(Node<L> node : graph.nodes()) copy.add(node.label()); for(Link<L> link : graph.links()) copy.get(link.first().index()).connect(copy.get(link.second().index())); copy.compact(0); return copy; } 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; }### Answer:
@Test public void testCopy() { 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 = LightDGraph.copy(graph); { int numLinks = 0; for(Link<String> link : graph.links()) numLinks++; assertEquals(5, numLinks); assertEquals(graph.numLinks(), numLinks); } }