});
Iterator edges=inputNetwork.getEdgeList().iterator();
while(edges.hasNext()&&!cancelled){ //for each edge, cal the weight
weight=0.0;
int common=0;
CyEdge e=(CyEdge)edges.next();
Long nFrom=e.getSource().getSUID();
Long nTo=e.getTarget().getSUID();
//cal the edge weght
List<CyNode> listneighbors1 = inputNetwork.getNeighborList(inputNetwork.getNode(nFrom), CyEdge.Type.ANY);
List<CyNode> listneighbors2 = inputNetwork.getNeighborList(inputNetwork.getNode(nTo), CyEdge.Type.ANY);
// Get neighborhood of this node (including the node)
/*
if (listneighbors1.size() < 2) {
// If there are no neighbors or just one neighbor, nodeInfo calculation is trivial
NodeInfo nodeInfo = new NodeInfo();
if (listneighbors1.size() == 1) {
nodeInfo.coreLevel = 1;
nodeInfo.coreDensity = 1.0;
nodeInfo.density = 1.0;
}
return nodeInfo;
}*/
Long[] neighbors1 = new Long[listneighbors1.size()];
int i = 0;
for (CyNode n : listneighbors1) {
neighbors1[i++] = n.getSUID();
}
// Add original node to extract complete neighborhood
Arrays.sort(neighbors1);
// Long[] neighbors1=getNeighborArray(inputNetwork,nFrom);
// Long[] neighbors2=getNeighborArray(inputNetwork,nTo);
Arrays.sort(neighbors1);
for(int j=0;j<listneighbors2.size();j++){
Long key=listneighbors2.get(j).getSUID();
if(Arrays.binarySearch(neighbors1, key)>=0)//exist a common neighbor of both nodes
common++;
}
common++;
degree1 = inputNetwork.getAdjacentEdgeList(e.getSource(), CyEdge.Type.ANY).size();
degree2 = inputNetwork.getAdjacentEdgeList(e.getTarget(), CyEdge.Type.ANY).size();
// degree1=super.getNodeDegree(inputNetwork,e.getSource().getSUID());
// degree2=getNodeDegree(inputNetwork,e.getTarget().getSUID());
/* degree1=inputNetwork.getDegree(e.getSource());
degree2=inputNetwork.getDegree(e.getTarget());*/
min=degree1<degree2 ? degree1:degree2;
weight=(double)(common)/(double)min;
//add to the edge weights map
if(edgeWeightsMap.containsKey(new Double(weight))) {
al=(ArrayList)edgeWeightsMap.get(new Double(weight));
al.add(e.getSUID());
}else{
al=new ArrayList();
al.add(e.getSUID());
edgeWeightsMap.put(new Double(weight), al);
}
}
curEdgeWeights=edgeWeightsMap;
edgeWeightNetworkMap.put(networkID, edgeWeightsMap);