@Test public void createCitSMall() throws IOException, ParseException { System.out.println("Loading dates"); Map<String, Date> dates = new HashMap<String, Date>(); BufferedReader reader = new BufferedReader(new FileReader(new File("/Users/Peter/Documents/datasets/graphs/cit/dates-th.txt"))); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String line; do { line = reader.readLine(); if(line == null) continue; if(line.trim().startsWith("#")) continue; if(line.trim().startsWith("%")) continue; String[] split = line.split("\\s"); String id = split[0]; Date date = sdf.parse(split[1]); if((! dates.containsKey(id)) || date.before(dates.get(id))) dates.put(id, date); } while(line != null); System.out.println(dates.size() + " dates read."); System.out.println("Loading graph"); File gFile = new File("/Users/Peter/Documents/datasets/graphs/cit/cit-th.txt"); reader = new BufferedReader(new FileReader(gFile)); DGraph<String> graph = new MapDTGraph<String, String>(); int i = 0; int cutoff = 94; do { line = reader.readLine(); i++; if(line == null) continue; if(line.trim().isEmpty()) continue; if(line.trim().startsWith("#")) continue; if(line.trim().startsWith("%")) continue; String[] split = line.split("\\s"); if(split.length < 2) throw new IllegalArgumentException("Line "+i+" does not split into two elements."); String from, to = null; from = split[0]; to = split[1]; if(! dates.containsKey(from)) continue; if(dates.get(from).getYear() >= cutoff) continue; if(! dates.containsKey(to)) continue; if(dates.get(to).getYear() >= cutoff) continue; DNode<String> nodeFrom, nodeTo; nodeFrom = graph.node(from); if(nodeFrom == null) nodeFrom = graph.add(from); nodeTo = graph.node(to); if(nodeTo == null) nodeTo = graph.add(to); nodeFrom.connect(nodeTo); } while(line != null); System.out.println("Graph size: " + graph.size() + "."); System.out.println("num links: " + graph.numLinks()); System.out.println("Removing..."); List<Node<String>> toRemove = new ArrayList<Node<String>>(graph.size()); for(Node<String> node : graph.nodes()) if (node.degree() == 0) toRemove.add(node); for(Node<String> node : toRemove) node.remove(); System.out.println("Done."); System.out.println("Graph size " + graph.size() + "."); System.out.println("Removing links..."); List<DLink<String>> linksToRemove = new ArrayList<DLink<String>>(); for(DLink<String> link : graph.links()) { Node<String> from = link.from(), to = link.to(); Date dateFrom = dates.get(from.label()), dateTo = dates.get(to.label()); if(dateFrom.before(dateTo)) { linksToRemove.add(link); System.out.println(dateFrom + " " + dateTo); } } System.out.println("Finding LCC."); graph = (DGraph<String>) ConnectionClusterer.largest(graph); System.out.println("Graph size " + graph.size() + "."); System.out.println("num links: " + graph.numLinks()); for(DLink<String> link : linksToRemove) link.remove(); System.out.println("Graph size " + graph.size() + "."); System.out.println("num links: " + graph.numLinks()); Data.writeEdgeList(graph, new File("/Users/Peter/Documents/datasets/graphs/cit/simple2.txt")); }
public static <L> void writeEdgeList(Graph<L> graph, File file) throws IOException { writeEdgeList(graph, file, false); }
Data { public static <L> void writeEdgeList(Graph<L> graph, File file) throws IOException { writeEdgeList(graph, file, false); } }
Data { public static <L> void writeEdgeList(Graph<L> graph, File file) throws IOException { writeEdgeList(graph, file, false); }  }
Data { public static <L> void writeEdgeList(Graph<L> graph, File file) throws IOException { writeEdgeList(graph, file, false); }  static UTGraph<String, String> edgeList(File file); static UTGraph<String, String> edgeList(File file, boolean bipartite); static UTGraph<String, String> edgeList(File file, boolean bipartite, boolean blank); static DTGraph<String, String> edgeListDirected(File file); static DTGraph<String, String> edgeListDirected(File file, boolean blank); static DGraph<String> edgeListDirectedUnlabeled(File file, boolean clean); static DGraph<String> edgeListDirectedUnlabeled(
			File file, boolean clean, File store); static DGraph<String> edgeListDirectedUnlabeledSimple(File file); static UGraph<String> edgeListUndirectedUnlabeled(File file, boolean clean); static void writeEdgeList(Graph<L> graph, File file); static void writeEdgeList(Graph<L> graph, File file, boolean fromOne); }
Data { public static <L> void writeEdgeList(Graph<L> graph, File file) throws IOException { writeEdgeList(graph, file, false); }  static UTGraph<String, String> edgeList(File file); static UTGraph<String, String> edgeList(File file, boolean bipartite); static UTGraph<String, String> edgeList(File file, boolean bipartite, boolean blank); static DTGraph<String, String> edgeListDirected(File file); static DTGraph<String, String> edgeListDirected(File file, boolean blank); static DGraph<String> edgeListDirectedUnlabeled(File file, boolean clean); static DGraph<String> edgeListDirectedUnlabeled(
			File file, boolean clean, File store); static DGraph<String> edgeListDirectedUnlabeledSimple(File file); static UGraph<String> edgeListUndirectedUnlabeled(File file, boolean clean); static void writeEdgeList(Graph<L> graph, File file); static void writeEdgeList(Graph<L> graph, File file, boolean fromOne);  }