コード例 #1
0
        public double ComputeRWithAddedNode(Node node)
        {
            var tempCommunity = new IterativeLocalExpansionCommunity(this);

            tempCommunity.AddNodeToD(node);
            return(tempCommunity.ComputeR());
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        private static IterativeLocalExpansionCommunity FindLocalCommunityInternal(Network network, Node startNode)
        {
            var community = new IterativeLocalExpansionCommunity(startNode);

            while (AddNodeToCommunity(community))
            {
                ;
            }

            return(community);
        }
コード例 #4
0
        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);
        }