public static void optimalDenseSubG() throws IOException { long startTime = System.currentTimeMillis(); String graphPath = "D:\\200\\shard0as-skitter.txt"; PreProcessFile ppf = new PreProcessFile(); HashMap<Integer, HashSet<Integer>> graphMap = ppf.symUndirGraph(graphPath); // 根据输入文件得出图文件,第一行就从边开始 HashMap<Integer, HashSet<Integer>> resultMap = RemainDensestSubgraph.withoutRemainDelete(graphMap); // HashMap<Integer, HashSet<Integer>> resultMap = // RemainDensestSubgraph.secwithoutRemainDelete(graphMap); String resultMapPath = graphPath.substring(0, graphPath.length() - 4) + "result" + ".txt"; System.out.println("write finish!"); printScore(resultMap, resultMapPath); System.out.println(); long endTime = System.currentTimeMillis(); long runTime = endTime - startTime; System.out.println("runTime: " + runTime); }
public static void topKDenseSubG() throws IOException { long startTime = System.currentTimeMillis(); String graphPath = "D:\\densestSubgraph\\论文所用到的数据集\\roadNet\\roadNet.txt"; // String postProfilePath = graphPath.substring(0, graphPath.length() - 4) + "post.txt"; //// //转换文件格式 PreProcessFile ppf = new PreProcessFile(); // ppf.changeFile(graphPath, postProfilePath); // HashMap<Integer,HashSet<Integer>> graphMap = ppf.symUndirGraph(postProfilePath); // //根据输入文件得出图文件 HashMap<Integer, HashSet<Integer>> graphMap = ppf.symUndirGraph(graphPath); // 根据输入文件得出图文件,第一行就从边开始 HashMap<Integer, HashSet<Integer>> copygraphMap = new HashMap<Integer, HashSet<Integer>>(); // 复制图 copyGraph(graphMap, copygraphMap); // 前者是srcMap, 后者是dstMap System.out.println( "graphMap.size: " + graphMap.size() + "\tcopygraphMap.size: " + copygraphMap.size()); // 3.得出与 graphMap 对应的文件的 .net文件 // String writePath = "C:\\Users\\wp\\Desktop\\dense\\as-735.net"; // ppf.writeNetFile(graphMap, writePath); // 4. 对graphMap应用高密度子图算法,得出密度子图 resultMap // HashMap<Integer,HashSet<Integer>> resultMap = // RemainDensestSubgraph.myWithoutRemainDelete(graphMap); // 对应原始方法,如果需要检测,还是使用这个方法 int K = 0; while ((graphMap.size() != 0) && (K < 1)) { K = K + 1; System.out.println("Graph " + K); // HashMap<Integer,HashSet<Integer>> resultMap = // RemainDensestSubgraph.myWithoutRemainDelete(copygraphMap); HashMap<Integer, HashSet<Integer>> resultMap = RemainDensestSubgraph.withoutRemainDelete(copygraphMap); // System.out.println("testing copygraphMap: " + copygraphMap.size()); // 写进文件 String resultMapPath = graphPath.substring(0, graphPath.length() - 4) + "result" + K + ".txt"; System.out.println("write finish!"); printScore(resultMap, resultMapPath); deleteSubmap(graphMap, resultMap); // System.out.println("graphMap.szie:" + graphMap.size()); copyGraph(graphMap, copygraphMap); // System.out.println("graphMap.szie:" + graphMap.size() + "\tcopygraphMap.szie: " + // copygraphMap.size()); System.out.println(); } long endTime = System.currentTimeMillis(); long runTime = endTime - startTime; System.out.println("runTime: " + runTime); }