@@ -0,0 +1,2235 @@
+package i5.las2peer.services.recommender.communities;%0A%0Aimport i5.las2peer.services.recommender.communities.webocd.Cover;%0Aimport i5.las2peer.services.recommender.communities.webocd.CustomGraph;%0Aimport i5.las2peer.services.recommender.communities.webocd.OcdAlgorithmException;%0Aimport i5.las2peer.services.recommender.communities.webocd.RandomWalkLabelPropagationAlgorithm;%0Aimport librec.data.SparseMatrix;%0A%0Apublic class CommunityDetector %7B%0A%09%0A%09private CommunityDetectionAlgorithm algorithm;%0A%09%0A%09private SparseMatrix graph;%0A%09%0A%09private SparseMatrix membershipsMatrix;%0A%09%0A%09// DMID parameters%0A%09private int dmidLeadershipIterationBound = 1000;%0A%09private double dmidLeadershipPrecisionFactor = 0.001;%0A%09private double dmidProfitabilityDelta = 0.1;%0A%09%0A%09// Walktrap parameters%0A%09private int walktrapSteps = 2;%0A%09%0A%09%0A%09public enum CommunityDetectionAlgorithm%7B%0A%09%09WALKTRAP, DMID%0A%09%7D%0A%09%0A%09%0A%09public void setAlgorithm(CommunityDetectionAlgorithm algorithm)%7B%0A%09%09this.algorithm = algorithm;%0A%09%7D%0A%09%0A%09public void setGraph(SparseMatrix graph)%7B%0A%09%09this.graph = graph;%0A%09%7D%0A%09%0A%09public void setDmidParameters(int iterationBound, double precisionFactor, double profitabilityDelta)%7B%0A%09%09dmidLeadershipIterationBound = iterationBound;%0A%09%09dmidLeadershipPrecisionFactor = precisionFactor;%0A%09%09dmidProfitabilityDelta = profitabilityDelta;%0A%09%7D%0A%09%0A%09public void setWalktrapParameters(int steps)%7B%0A%09%09walktrapSteps = steps;%0A%09%7D%0A%09%0A%09public void detectCommunities()%7B%0A%09%09switch(algorithm)%7B%0A%09%09case WALKTRAP:%0A%09%09%09detectWalktrap();%0A%09%09%09break;%0A%09%09case DMID:%0A%09%09%09detectDmid();%0A%09%09%09break;%0A%09%09default:%0A%09%09%09break;%0A%09%09%7D%0A%09%7D%0A%09%0A%09public SparseMatrix getCommunityStructure()%7B%0A%09%09return membershipsMatrix;%0A%09%7D%0A%09%0A%09%0A%09private void detectDmid() %7B%0A%09%09// TODO %0A%09%09%0A//%09%09RandomWalkLabelPropagationAlgorithm dmidAlgo = new RandomWalkLabelPropagationAlgorithm();%0A//%09%09%0A//%09%09CustomGraph customGraph = getCustomGraph();%0A//%09%09%0A//%09%09try %7B%0A//%09%09%09Cover cover = dmidAlgo.detectOverlappingCommunities(customGraph);%0A//%09%09%7D catch (OcdAlgorithmException e) %7B%0A//%09%09%09e.printStackTrace();%0A//%09%09%7D catch (InterruptedException e) %7B%0A//%09%09%09e.printStackTrace();%0A//%09%09%7D%0A%0A%09%7D%0A%0A%09private void detectWalktrap() %7B%0A%09%09// TODO Auto-generated method stub%0A%09%09%0A%09%7D%0A%09%0A%09private CustomGraph getCustomGraph() %7B%0A%09%09%0A%09%09// TODO Construct CustomGraph from graph%0A%09%09// ...%0A%09%09%0A%09%09return null;%0A%09%7D%0A%0A%7D%0A

Add class for community detection