### Question:
MapDTGraph implements DTGraph<L, T>, HasPersistentNodes, HasPersistentLinks { @Override public long numLinks() { return numLinks; } MapDTGraph(); static MapDTGraph<L, T> copy(DTGraph<L, T> graph); static MapDTGraph<L, Object> copy(DGraph<L> graph); @Override DTNode<L, T> node(L label); int size(); @Override Set<? extends DTNode<L, T>> nodes(L label); @Override DTNode<L, T> add(L label); boolean uniqueLabels(); String toString(); @Override boolean connected(L first, L second); @Override Set<L> labels(); @Override long numLinks(); @Override long state(); @Override List<? extends DTNode<L, T>> nodes(); @Override Iterable<MapDTLink> links(); @Override Set<T> tags(); @Override DTNode<L, T> get(int i); @Override int hashCode(); @Override boolean equals(Object other); @Override Class<? extends DTGraph<L, T>> level();  }### Answer:
@Test public void testNumLinks() { DTGraph<String, String> graph = new MapDTGraph<String, String>(); DTNode<String, String> a = graph.add("a"); DTNode<String, String> b = graph.add("b"); DTNode<String, String> c = graph.add("c"); a.connect(a, "self"); b.connect(c, "1"); c.connect(a, "2"); a.connect(c, "2"); a.connect(c, "2"); int numLinks = 0; for(Link<String> link : graph.links()) numLinks++; assertEquals(5, numLinks); assertEquals(graph.numLinks(), numLinks); }