资源简介

社团发现算法实现,包含亚马逊,dolphin,football和polblogs数据集

资源截图

代码片段和文件信息

package cn.cas.cigit.data;

import java.util.Set;

public class CollectionUtil {
public static void showArr(double[][] a){
for(int i=0;i for(int j=0;j System.out.print(a[i][j] +“ “);
}
System.out.println();
}
}

public static void showArr(int[][] a){
for(int i=0;i for(int j=0;j System.out.print(a[i][j] +“ “);
}
System.out.println();
}
}

public static void main(String[] args) throws Exception {
double[][] one = {{111}{222}{333}};
double[][] one1 = {{444}{5555}};
double[][] another = {{11}{22}{33}};
// double[][] arr = horizontalMerge2DArray(oneanother);
double[][] arr = verticalMerge2DArray(one one1);
showArr(arr);
}

/**
 * 水平合并两个二维数组
 * @param oneArray
 * @param anotherArray
 * @return
 * @throws Exception 
 */
public static double[][] horizontalMerge2DArray(double[][] oneArraydouble[][] anotherArray) throws Exception{
if(oneArray.length != anotherArray.length){
throw new Exception(“水平合并两个数组要求行相等!“);
}
int lenofOneArray = oneArray[0].length;
int lenofAnotherArray = anotherArray[0].length;
double[][] res= new double[oneArray.length][lenofOneArray + lenofAnotherArray];
for(int i=0len=oneArray.length;i System.arraycopy(oneArray[i] 0 res[i] 0 lenofOneArray);
System.arraycopy(anotherArray[i] 0 res[i] lenofOneArray lenofAnotherArray);
}
return res;
}

/**
 * 垂直合并两个二维数组
 * @param oneArray
 * @param anotherArray
 * @return
 * @throws Exception 
 */
public static double[][] verticalMerge2DArray(double[][] oneArraydouble[][] anotherArray) throws Exception{
if(oneArray[0].length != anotherArray[0].length){
throw new Exception(“水平合并两个数组要求行相等!“);
}
int lenofOneArray = oneArray.length;
int lenofAnotherArray = anotherArray.length;
double[][] res= new double[lenofOneArray + lenofAnotherArray][oneArray[0].length];
for(int i=0len=lenofOneArray + lenofAnotherArray;i if(i System.arraycopy(oneArray[i] 0 res[i] 0 oneArray[0].length);
}else{
System.arraycopy(anotherArray[i-lenofOneArray] 0 res[i] 0 anotherArray[0].length);
}
}
return res;
}


/**
 * 数组转换为字符
 * @param arr
 * @return
 */
public static String toString(double[] arr){
String res = “[“;
for(Double d:arr){
res += d+““;
}
res = res.substring(0 res.length()-1);
res += “]“;
return res;
}

/**
 * 数组转换为字符
 * @param arr
 * @return
 */
public static String toString(int[] arr){
String res = “[“;
for(int d:arr){
res += d+““;
}
res = res.substring(0 res.length()-1);
res += “]“;
return res;
}

/**
 * 数组转换为字符
 * @param arr
 * @return
 */
public static String toString(Set arr){
String res = “(“;
for(String d:arr){
res += d+““;
}
res.substring(0 res.length

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-09-08 08:12  CommunityDetection-master\
     目录           0  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\
     目录           0  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\data\
     目录           0  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\data\amazon\
     文件      458683  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\data\amazon\com-amazon.top5000.cmty.txt
     文件    12585884  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\data\amazon\com-amazon.ungraph.txt
     文件       52654  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\data\amazon\formal-amazon.top705.cmty.txt
     文件      187320  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\data\amazon\formal-amazon.ungraph.txt
     目录           0  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\data\dolphin\
     文件       11578  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\data\dolphin\dolphins.gml
     文件        1629  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\data\dolphin\dolphins.paj
     文件         774  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\data\dolphin\dolphins2.gml
     目录           0  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\data\football\
     文件       39905  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\data\football\d.txt
     文件       33379  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\data\football\football.gml
     目录           0  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\data\polblogs\
     文件      977839  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\data\polblogs\polblogs.gml
     目录           0  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\lib\
     文件       35981  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\lib\Jama-1.0.3.jar
     目录           0  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\src\
     目录           0  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\src\cn\
     目录           0  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\src\cn\cas\
     目录           0  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\src\cn\cas\cigit\
     目录           0  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\src\cn\cas\cigit\data\
     文件        3946  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\src\cn\cas\cigit\data\CollectionUtil.java
     文件        2739  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\src\cn\cas\cigit\data\DataSource.java
     文件        1824  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\src\cn\cas\cigit\data\DatasetScreen.java
     文件        3468  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\src\cn\cas\cigit\data\FileUtils.java
     目录           0  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\src\cn\cas\cigit\model\
     文件        1202  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\src\cn\cas\cigit\model\Community.java
     文件        2112  2016-09-08 08:12  CommunityDetection-master\CommunityDetection\src\cn\cas\cigit\model\Edge.java
............此处省略20个文件信息

评论

共有 条评论