public double ComputeRWithAddedNode(Node node) { var tempCommunity = new IterativeLocalExpansionCommunity(this); tempCommunity.AddNodeToD(node); return(tempCommunity.ComputeR()); }
private IterativeLocalExpansionCommunity(IterativeLocalExpansionCommunity community) { D = community.D.ToList(); B = community.B.ToList(); C = community.C.ToList(); S = community.S.ToList(); BIn = community.BIn; BOut = community.BOut; }
private static IterativeLocalExpansionCommunity FindLocalCommunityInternal(Network network, Node startNode) { var community = new IterativeLocalExpansionCommunity(startNode); while (AddNodeToCommunity(community)) { ; } return(community); }
private static bool AddNodeToCommunity(IterativeLocalExpansionCommunity community) { Node bestNode = null; double bestR = community.ComputeR(); foreach (var ni in community.S) { double r = community.ComputeRWithAddedNode(ni); if (r > bestR) { bestR = r; bestNode = ni; } } if (bestNode == null) { return(false); } community.AddNodeToD(bestNode); Debug.WriteLine($"Added '{bestNode.Id}'"); return(true); }