コード例 #1
0
 public void GenerateBAModelWithAging(int n, int m0, int m, double v)
 {
     RunWithProgressBar(() =>
     {
         var network = _networkGenerator.GenerateBarabasiAlbertModelWithAging(n, m0, m, v);
         var wrapper = new NetworkWrapper($"BA_{BACounter++}", network, network.GetIncidenceMatrix());
         Networks.Add(wrapper);
         OnNetworkAdd?.Invoke(wrapper);
     });
 }
コード例 #2
0
        public void LoadNetwork(string path, int rowsToSkip)
        {
            RunWithProgressBar(() =>
            {
                var(network, incidenceMatrix) = _networkFileLoader.LoadNetwork(path, rowsToSkip);
                string fileName = Path.GetFileNameWithoutExtension(path);

                var wrapper = new NetworkWrapper(fileName, network, incidenceMatrix);
                Networks.Add(wrapper);
                OnNetworkAdd?.Invoke(wrapper);
            });
        }
コード例 #3
0
        public void CreateNetworkFromCommunity(string networkName, string communityName)
        {
            var network   = GetNetwork(networkName);
            var community = network.Communities.Single(e => e.Id.ToString() == communityName);

            // cloning because new nodes must be used
            var newNetwork = new Network(community.Nodes).Clone();

            var newNetworkWrapper = new NetworkWrapper($"{networkName} - {communityName}", newNetwork, newNetwork.GetIncidenceMatrix());

            Networks.Add(newNetworkWrapper);
            OnNetworkAdd?.Invoke(newNetworkWrapper);
        }
コード例 #4
0
        private void GetNetworkPlot(NetworkWrapper network)
        {
            string tempFileName = TempFileHelper.CreateTmpFile();
            string script       = RScriptCreator.CreatePlotNetworkScript(tempFileName, network.Network, network.Communities);

            REngineRunner.RunFromCmd(script);

            Bitmap bitmap;

            using (var fs = File.Open(tempFileName, FileMode.Open))
            {
                bitmap = new Bitmap(fs);
            }

            TempFileHelper.DeleteTmpFile(tempFileName);
            network.Plot = bitmap;
            OnNetworkPlotUpdate?.Invoke(network);
        }
コード例 #5
0
        private void InitNetwork(NetworkWrapper network)
        {
            //RunWithProgressBar(() =>
            //{
            //    network.Network.ComputeClusteringCoefficient();
            //    network.Stats.ClusteringCoefficient = network.Network.GetGlobalClusteringCoefficient();

            //    OnNetworkStatsUpdate?.Invoke(network);
            //});

            RunWithProgressBar(() =>
            {
                network.DistanceMatrix            = network.IncidenceMatrix.GetDistanceMatrix();
                network.Stats.MeanDistance        = network.DistanceMatrix.GetMeanDistance();
                network.Stats.ClosenessCentrality = network.DistanceMatrix.GetClosenessCentralityVector().Average;
                network.Stats.Diameter            = network.DistanceMatrix.GetDiameter();

                network.Network.ComputeClusteringCoefficient();
                network.Stats.ClusteringCoefficient = network.Network.GetGlobalClusteringCoefficient();

                OnNetworkStatsUpdate?.Invoke(network);
            });

            RunWithProgressBar(() =>
            {
                network.Stats.DegreeCentrality = network.Network.GetAverageDegree();
                network.Stats.Edges            = network.Network.Edges;
                network.Stats.Nodes            = network.Network.Nodes.Count;
                network.Stats.Components       = network.Network.CountComponents();

                OnNetworkStatsUpdate?.Invoke(network);
            });

            RunWithProgressBar(() =>
            {
                GetNetworkPlot(network);
            });
        }