Graphs { public static <V, E> double clusteringCoefficient(Graph<V, E> graph) { long numPaths = 0, numClosed = 0; List<V> path = new ArrayList<V>(2); for(V one : graph.getVertices()) { path.clear(); path.add(null); path.add(null); path.add(null); path.set(0, one); for(V two : graph.getNeighbors(one)) { path.set(1, two); for(V three : graph.getNeighbors(two)) { if(!three.equals(one)) { path.set(2, three); numPaths ++; if(graph.isNeighbor(one, three)) numClosed++; } } } } return numClosed / (double) numPaths; }  static UndirectedGraph<Integer, Integer> singLine(File file); static UndirectedGraph<Vertex<Integer>, Edge<Integer>> intGraphFromTSV(File file); static DirectedGraph<Vertex<Integer>, Edge<Integer>> intDirectedGraphFromTSV(File file); static UndirectedGraph<Vertex<String>, Edge<String>> graphFromTSV(File file); static DirectedGraph<Vertex<String>, Edge<String>> graphFromRDF(File rdfFile); static DirectedGraph<Vertex<String>, Edge<String>> graphFromRDF(File rdfFile, RDFFormat format); static DirectedGraph<Vertex<String>, Edge<String>> graphFromRDF(
			File rdfFile,
			RDFFormat format,
			List<String> vWhiteList,
			List<String> eWhiteList); static BufferedImage image(Graph<V, E> graph, int width, int height); static void removeVerticesAndEdges(DirectedGraph<Vertex<String>, Edge<String>> graph, List<String> vBlackList, List<String> eBlackList); static boolean matches(String string, List<Pattern> patterns); static UndirectedGraph<V, E> undirectedSubgraph(Graph<V, E> sup, Collection<V> nodes); static E getEdge(Graph<V, E> graph, V v1, V v2); static double clusteringCoefficient(Graph<V, E> graph);  }
@Test public void testCC() { Graph<String, String> graph = new UndirectedSparseGraph<String, String>(); graph.addEdge("0", "a", "b"); graph.addEdge("1", "b", "c"); graph.addEdge("2", "c", "d"); graph.addEdge("3", "d", "a"); graph.addEdge("4", "a", "c"); System.out.println(Graphs.clusteringCoefficient(graph)); }