Example #1
0
        public AnalysisResult Analyze(Network network, Dictionary <string, string> parameters)
        {
            var errors = ValidateParameters(network, parameters);

            if (errors.Count > 0)
            {
                // TODO: custom exception
                throw new ArgumentException(string.Join('\n', errors));
            }

            var treshold    = int.Parse(parameters["treshold"]);
            var algorithm   = ParseAlgorithm(parameters);
            var communities = Algorithm.Apply(network, algorithm, treshold);

            return(new AnalysisResult
            {
                ActorToCommunity = AnalysisHelper.ActorToCommunity(network.Actors, communities),
                AnalyzedNetworkEdgeList = AnalysisHelper.EdgeList(network),
                CommunityList = AnalysisHelper.CommunityList(network.Actors, communities),
                Exclusivities = AnalysisHelper.Exclusivities(network, communities),
                Homogenities = AnalysisHelper.Homogenities(network, communities),
                Varieties = AnalysisHelper.Varieties(network, communities),
                Performances = AnalysisHelper.Performances(network, communities),
                Coverages = AnalysisHelper.Coverages(network, communities),
                Modularities = AnalysisHelper.Modularities(network, communities)
            });
        }