/** * generate a dot-graph and exports it to the given file * * @param graph * @param filepath */ public static void generateDigraphHITSAndPageRank(HashSet<Node> graph, String filepath) { System.out.println("generate digraph HITS and PageRank"); StringBuilder sb = new StringBuilder(); sb.append("digraph wikigraph {"); sb.append(System.getProperty("line.separator")); ArrayList<Node> list = new ArrayList<Node>(graph); /** generate links */ for (Node n : list) { sb.append(n.getDOTHITSAndPageRank()); } sb.append("}"); /** write file */ try { FileWriter.writeFile(filepath + "_hits_and_pagerank.dot", sb.toString()); } catch (IOException e) { e.printStackTrace(); } }
/** * generate a dot-graph and exports it to the given file * * @param graph * @param filepath */ public static void generateDigraph(HashMap<String, Node> graph, String filepath) { System.out.println("generate digraph"); StringBuilder sb = new StringBuilder(); sb.append("digraph wikigraph {"); sb.append(System.getProperty("line.separator")); ArrayList<Node> list = new ArrayList<Node>(graph.values()); /** generate nodes and links */ for (Node n : list) { sb.append(n.getDOT()); } sb.append("}"); /** write file */ try { FileWriter.writeFile(filepath + ".dot", sb.toString()); } catch (IOException e) { e.printStackTrace(); } }