Exemplo n.º 1
0
 public CliqueOptionForm()
 {
     InitializeComponent();
     m = 1;
     k = 1;
     net = null;
 }
Exemplo n.º 2
0
        public OptionsForm()
        {
            InitializeComponent();
            EnableButton();
            filenamelabel.Text = "";
            d = 1.0;
            v = 1.0;
            r = 0;
            m = 1;
            k = 1;
            a = 0.0;
            net = null;

            UpdateCheckBoxes();
        }
Exemplo n.º 3
0
        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            if (loadFrom == "")
                return;
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                int startYear, endYear;
                YearRangeForm range = new YearRangeForm();
                range.from = currentYear;
                range.to = currentYear;
                range.ShowDialog();
                startYear = range.from;
                endYear = range.to;

                ProgressForm progress = new ProgressForm();
                progress.endYear = endYear;
                progress.startYear = startYear;
                progress.curYear = 0;
                progress.Show();

                int previousYear = -1;
                for (int year = startYear; year <= endYear; ++year)
                {
                    if (loadFrom == "Matrix")
                    {
                        year = net.LoadFromMatrixFile(openFileDialog.FileName, year);
                    }
                    else if (loadFrom == "Dyadic")
                    {
                        year = net.LoadFromDyadicFile(openFileDialog.FileName, year);
                    }
                    else if (loadFrom == "Random")
                    {
                        net.LoadRandom(_randomForm.N, "Data", _randomSymmetric, _randomForm.ProbRange, _randomForm.MinProb, _randomForm.MaxProb, _randomForm.RandomN, _randomForm.RandomMinN, _randomForm.RandomMaxN, _randomForm.RandomIntN);
                    }
                    else if (loadFrom == "ValuedRandom")
                    {
                        net.LoadValuedRandom(_vrandomForm.N, "Data", _randomSymmetric, _vrandomForm.vmin, _vrandomForm.vmax, _vrandomForm.datatype, _vrandomForm.zerodiagonalized, _vrandomForm.ProbRange, _vrandomForm.MinProb, _vrandomForm.MaxProb, _vrandomForm.RandomN, _vrandomForm.RandomMinN, _vrandomForm.RandomMaxN, _vrandomForm.RandomIntN);
                    }
                    if (year != previousYear && year <= endYear)
                    {
                        net.FindCliques(_optionsForm.Cutoff[currentYear], _optionsForm.InputType != "None", _optionsForm.Density, currentYear, _optionsForm.CMinMembers, false, _optionsForm.KCliqueValue, _optionsForm.KCliqueDiag);
                        net.LoadViableCoalitions(_optionsForm.ViableCoalitionCutoff, currentYear, _optionsForm.svcCoalitionFile);

                        Network.NetworkGUI viableNet = new Network.NetworkGUI(net);
                        viableNet.LoadCounterIntoDataGridView(dataGrid, currentYear, _optionsForm.Cutoff[currentYear], _optionsForm.Density,
                            _optionsForm.InputType, _optionsForm.FileName, _optionsForm.svcFile, _optionsForm.useCohesion,
                            _optionsForm.transitivityType, _optionsForm.counterOptions, _optionsForm.reachSum, _optionsForm.reachZero, _optionsForm.ReachNumMatrices, _optionsForm.ERPOLType, _optionsForm.Alpha, _optionsForm.KCliqueValue, _optionsForm.KCliqueDiag, _optionsForm.SelectionMethod, net._minCliqueSize);

                        switch (_optionsForm.SelectionMethod)
                        {
                            case "Cliq":
                                bool temp = false;
                                if (_optionsForm.counterOptions[10] || _optionsForm.counterOptions[11] || _optionsForm.counterOptions[14] || _optionsForm.counterOptions[18] || _optionsForm.counterOptions[24])
                                    temp = true;
                                net.FindCliques(_optionsForm.Cutoff[currentYear], _optionsForm.InputType == "StructEquiv",
                                    _optionsForm.Density, currentYear, net._minCliqueSize, temp, _optionsForm.KCliqueValue,
                                    _optionsForm.KCliqueDiag);
                                net.LoadCounterIntoDataGridView(dataGrid, currentYear, _optionsForm.Cutoff[currentYear], _optionsForm.Density,
                                                                _optionsForm.InputType, _optionsForm.FileName, _optionsForm.svcFile, _optionsForm.useCohesion,
                                                                _optionsForm.transitivityType, _optionsForm.counterOptions, _optionsForm.reachSum, _optionsForm.reachZero,
                                                                _optionsForm.ReachNumMatrices, _optionsForm.ERPOLType, _optionsForm.Alpha, _optionsForm.KCliqueValue,
                                                                _optionsForm.KCliqueDiag, _optionsForm.SelectionMethod, net._minCliqueSize);
                                break;
                            case "Bloc":
                                _blocForm2.ShowDialog();
                                net.CONCOR(_blocForm2.pos, openFileDialog.Multiselect, GetCONCORConvergenceFunction(), _blocForm2.MaxNoSteps);
                                net.LoadBlockMatrices(_optionsForm.Density, currentYear);
                                net.LoadCounterIntoDataGridView(dataGrid, currentYear, _blocForm2.pos, _optionsForm.Density,
                                                                _optionsForm.InputType, _optionsForm.FileName, _optionsForm.svcFile, _optionsForm.useCohesion,
                                                                _optionsForm.transitivityType, _optionsForm.counterOptions, _optionsForm.reachSum, _optionsForm.reachZero,
                                                                _optionsForm.ReachNumMatrices, _optionsForm.ERPOLType, _optionsForm.Alpha, _optionsForm.KCliqueValue,
                                                                _optionsForm.KCliqueDiag, _optionsForm.SelectionMethod, _blocForm2.MaxNoSteps);
                                break;
                            case "Clus":
                                _clusterForm.ShowDialog();
                                net.LoadClustering(_clusterForm.ClusteringMethod, _clusterForm.MaxNoClusters, currentYear, _optionsForm.Density);
                                net.LoadBlockMatrices(_optionsForm.Density, currentYear);
                                net.LoadCounterIntoDataGridView(dataGrid, currentYear, _optionsForm.Cutoff[currentYear], _optionsForm.Density,
                                                                 _optionsForm.InputType, _optionsForm.FileName, _optionsForm.svcFile, _optionsForm.useCohesion,
                                                                 _optionsForm.transitivityType, _optionsForm.counterOptions, _optionsForm.reachSum, _optionsForm.reachZero,
                                                                 _optionsForm.ReachNumMatrices, _optionsForm.ERPOLType, _optionsForm.Alpha, _optionsForm.KCliqueValue,
                                                                 _optionsForm.KCliqueDiag, _optionsForm.SelectionMethod, net._minCliqueSize);
                                break;
                            case "Comm":
                                net.calculateCommunities(dataGrid, CommunityType.Affil, currentYear, _comForm.SVC, _comForm.DVC, _comForm.attrMatrix, _optionsForm.getCutOff(currentYear), _optionsForm.Density);
                                net.LoadCounterIntoDataGridView(dataGrid, currentYear, _optionsForm.Cutoff[currentYear], _optionsForm.Density,
                                                                _optionsForm.InputType, _optionsForm.FileName, _optionsForm.svcFile, _optionsForm.useCohesion,
                                                                _optionsForm.transitivityType, _optionsForm.counterOptions, _optionsForm.reachSum, _optionsForm.reachZero,
                                                                _optionsForm.ReachNumMatrices, _optionsForm.ERPOLType, _optionsForm.Alpha, _optionsForm.KCliqueValue,
                                                                _optionsForm.KCliqueDiag, _optionsForm.SelectionMethod, net._minCliqueSize);
                                break;
                            default:
                                break;
                        }
                        viableNet.SaveCounterToFile(saveFileDialog.FileName, year, year == startYear, ",", _optionsForm.Cutoff[year], _optionsForm.Density,
                            _optionsForm.InputType, _optionsForm.FileName, _optionsForm.svcFile, _optionsForm.useCohesion, _optionsForm.transitivityType,
                            _optionsForm.counterOptions, _optionsForm.SaveOverwrite && year == startYear, _optionsForm.reachZero, _optionsForm.reachSum, _optionsForm.ReachNumMatrices,
                            _optionsForm.ERPOLType, _optionsForm.Alpha, _optionsForm.KCliqueValue, _optionsForm.KCliqueDiag, _optionsForm.SelectionMethod);
                    }
                    progress.curYear = year;
                    Application.DoEvents();
                    previousYear = year;
                }

                if (currentYear == endYear)
                    return;

                if (loadFrom == "Matrix")
                {
                    net.LoadFromMatrixFile(openFileDialog.FileName, currentYear);
                }
                else if (loadFrom == "Dyadic")
                {
                    net.LoadFromDyadicFile(openFileDialog.FileName, currentYear);
                }
            }
        }
Exemplo n.º 4
0
        private void resetToolStripMenuItem_Click(object sender, EventArgs e)
        {
            net = new Network.NetworkGUI();
            startYear = -1;
            currentYear = -1;
            loadFrom = "";
            displayMatrix = "Data";
            SetChecked();
            _centralityForm = new CentralityForm();
            _cliqueForm = new CliqueForm();
            _optionsForm.ReachNumMatrices = -1;
            _optionsForm.CMinMembers = 1;
            _optionsForm.Alpha = 0.0;
            _randomForm = new RandomForm();
            _vrandomForm = new ValuedRandomForm();
            _optionsForm = new OptionsForm();
            _randomForm.N = 3;
            _vrandomForm.N = 3;
            _blocForm = new BlocForm();

            useMultipleFiles = false;
            multipleMatrixFilesToolStripMenuItem.Enabled = true;
            _multiplicationForm = new MultiplicationForm();
            dataGrid.Columns.Clear();
             _nfsForm = new NetworkFormationSimulationForm(this);

            BufferedFileTable.Clear();
        }
Exemplo n.º 5
0
        private void LoadData()
        {
            net.ClearPreviousData(displayMatrix, loadFrom);
            // Load matrix into GUI
            DoStandardize();
            // Thread t = new Thread(delegate() { DoLoadCorrect(currentYear);  });
            // t.Start();
            //while (!t.IsAlive) ;
            // Thread.Sleep(100);
            // t.Join();
            DoLoadCorrect(currentYear);
            switch (displayMatrix)
            {
                case "Affiliation":
                    if (_optionsForm.DisplayCliqueOption == "Save")
                        SaveAffiliationWithoutDisplay();
                    else
                        net.LoadAffiliationIntoDataGridView(dataGrid, _optionsForm.Cutoff[currentYear], _optionsForm.InputType == "StructEquiv",
                                                            _optionsForm.FileName, _optionsForm.InputType == "Dyadic", currentYear, _optionsForm.Density, _optionsForm.InputType != "None",
                                                            _optionsForm.SumMean, _optionsForm.SumMeanFilename, _optionsForm.svcFile, _optionsForm.DisplayCliqueOption,
                                                            cliqueSizeToolStripMenuItem1.Checked, cliqueCohesionToolStripMenuItem1.Checked, estebanRayIndexToolStripMenuItem1.Checked, _optionsForm.KCliqueValue, _optionsForm.KCliqueDiag);
                    break;
                case "ViableCounter":
                    net.FindCliques(_optionsForm.Cutoff[currentYear], _optionsForm.InputType != "None", _optionsForm.Density, currentYear, _optionsForm.CMinMembers, false, _optionsForm.KCliqueValue, _optionsForm.KCliqueDiag);
                    net.LoadViableCoalitions(_optionsForm.ViableCoalitionCutoff, currentYear, _optionsForm.svcCoalitionFile);

                    Network.NetworkGUI viableNet = new Network.NetworkGUI(net);
                    viableNet.LoadCounterIntoDataGridView(dataGrid, currentYear, _optionsForm.Cutoff[currentYear], _optionsForm.Density,
                        _optionsForm.InputType, _optionsForm.FileName, _optionsForm.svcFile, _optionsForm.useCohesion,
                        _optionsForm.transitivityType, _optionsForm.counterOptions, _optionsForm.reachSum, _optionsForm.reachZero, _optionsForm.ReachNumMatrices, _optionsForm.ERPOLType, _optionsForm.Alpha, _optionsForm.KCliqueValue, _optionsForm.KCliqueDiag, _optionsForm.SelectionMethod,net._minCliqueSize);
                    break;
                case "CONCOR":
                    net.LoadBlocAffiliationIntoDataGridView(dataGrid, false);
                    break;
                case "Clustering":
                    net.LoadBlocAffiliationIntoDataGridView(dataGrid, true);
                    break;
                case "NatDep":
                    net.LoadNationalDependencyIntoDataGridView(_optionsForm.ReachNumMatrices, _optionsForm.Density, 
                                                                currentYear, _optionsForm.reachZero, _optionsForm.reachSum);
                    net.LoadMatrixIntoDataGridView(dataGrid, displayMatrix);
                    break;
                case "CBCO":
                    if (_optionsForm.DisplayCliqueOption == "Save")
                        SaveAffiliationWithoutDisplay();
                    else
                    {
                   //     Thread v = new Thread(delegate() { net.LoadCBCOverlapIntoDataGridView(dataGrid, _optionsForm.DisplayCliqueOption); });
                    //    v.Start();
                     //   while (!v.IsAlive) ;
                    //       Thread.Sleep(100);
                     //   v.Join();
                        net.LoadCBCOverlapIntoDataGridView(dataGrid, _optionsForm.DisplayCliqueOption);
                    }
                    break;
                case "CBCODiag":
                    if (_optionsForm.DisplayCliqueOption == "Save")
                        SaveAffiliationWithoutDisplay();
                    else
                        net.LoadCBCOverlapIntoDataGridView(dataGrid, true, _optionsForm.DisplayCliqueOption);
                    break;
                case "Centrality":
                    net.LoadCentralityIntoDataGridView(dataGrid, _centralityForm.Avg);
                    break;
                case "Components":
                    net.LoadComponentsIntoDataGridView(dataGrid, _optionsForm.Cutoff[currentYear], _optionsForm.InputType == "StructEquiv",
                                                        _optionsForm.FileName, _optionsForm.InputType == "Dyadic", currentYear, _optionsForm.Density, _optionsForm.InputType != "None",
                                                        _optionsForm.SumMean, _optionsForm.SumMeanFilename, _optionsForm.svcFile,
                                                        cliqueSizeToolStripMenuItem1.Checked, cliqueCohesionToolStripMenuItem1.Checked, estebanRayIndexToolStripMenuItem1.Checked, _optionsForm.KCliqueValue, _optionsForm.KCliqueDiag);
                    break;
                case "Counter":
                    break;
                case "Community":
                    break;
                // new code for local Transitivity
                case "LocalTransitivity":
                    break;
                case "LocalBalance":
                    break;

                case "SignedNetwork":
                    //net.LoadSignedNetworkCharacteristics(dataGrid, _optionsForm.ReachNumMatrices, _optionsForm.reachSum, _optionsForm.reachZero, prevDisplayMatrix, currentYear, reachBinary);
                    break;

                case "SingleNetworkExpectations":
                    break;
                case "NetworkSpilloverStatistics":
                    break;

                

                default:
                    net.LoadMatrixIntoDataGridView(dataGrid, displayMatrix);
                    break;
            }
            //net.ClearPreviousData(displayMatrix);

        }
Exemplo n.º 6
0
        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            if (loadFrom == "")
                return;
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                int startYear, endYear;
                YearRangeForm range = new YearRangeForm();
                range.from = currentYear;
                range.to = currentYear;
                range.ShowDialog();
                startYear = range.from;
                endYear = range.to;

                ProgressForm progress = new ProgressForm();
                progress.endYear = endYear;
                progress.startYear = startYear;
                progress.curYear = 0;
                progress.Show();

                int previousYear = -1;
                for (int year = startYear; year <= endYear; ++year)
                {
                    if (loadFrom == "Matrix")
                    {
                        year = net.LoadFromMatrixFile(openFileDialog.FileName, year);
                    }
                    else if (loadFrom == "Dyadic")
                    {
                        year = net.LoadFromDyadicFile(openFileDialog.FileName, year);
                    }
                    else if (loadFrom == "Random")
                    {
                        net.LoadRandom(_randomForm.N, "Data", _randomSymmetric, _randomForm.ProbRange, _randomForm.MinProb, _randomForm.MaxProb, _randomForm.RandomN, _randomForm.RandomMinN, _randomForm.RandomMaxN, _randomForm.RandomIntN);
                    }
                    else if (loadFrom == "ValuedRandom")
                    {
                        net.LoadValuedRandom(_vrandomForm.N, "Data", _randomSymmetric, _vrandomForm.vmin, _vrandomForm.vmax, _vrandomForm.datatype, _vrandomForm.zerodiagonalized, _vrandomForm.ProbRange, _vrandomForm.MinProb, _vrandomForm.MaxProb, _vrandomForm.RandomN, _vrandomForm.RandomMinN, _vrandomForm.RandomMaxN, _vrandomForm.RandomIntN);
                    }
                    if (year != previousYear && year <= endYear)
                    {
                        net.FindCliques(_optionsForm.Cutoff[currentYear], _optionsForm.InputType != "None", _optionsForm.Density, currentYear, _optionsForm.CMinMembers, false, _optionsForm.KCliqueValue, _optionsForm.KCliqueDiag);
                        net.LoadViableCoalitions(_optionsForm.ViableCoalitionCutoff, currentYear, _optionsForm.svcCoalitionFile);

                        Network.NetworkGUI viableNet = new Network.NetworkGUI(net);
                        viableNet.LoadCounterIntoDataGridView(dataGrid, currentYear, _optionsForm.Cutoff[currentYear], _optionsForm.Density,
                            _optionsForm.InputType, _optionsForm.FileName, _optionsForm.svcFile, _optionsForm.useCohesion,
                            _optionsForm.transitivityType, _optionsForm.counterOptions, _optionsForm.reachSum, _optionsForm.reachZero, _optionsForm.ReachNumMatrices, _optionsForm.ERPOLType, _optionsForm.Alpha, _optionsForm.KCliqueValue, _optionsForm.KCliqueDiag);

                        viableNet.SaveCounterToFile(saveFileDialog.FileName, year, year == startYear, ",", _optionsForm.Cutoff[year], _optionsForm.Density,
                            _optionsForm.InputType, _optionsForm.FileName, _optionsForm.svcFile, _optionsForm.useCohesion, _optionsForm.transitivityType,
                            _optionsForm.counterOptions, _optionsForm.SaveOverwrite && year == startYear, _optionsForm.reachZero, _optionsForm.reachSum, _optionsForm.ReachNumMatrices, _optionsForm.ERPOLType, _optionsForm.Alpha, _optionsForm.KCliqueValue, _optionsForm.KCliqueDiag);
                    }
                    progress.curYear = year;
                    Application.DoEvents();
                    previousYear = year;
                }

                if (currentYear == endYear)
                    return;

                if (loadFrom == "Matrix")
                {
                    net.LoadFromMatrixFile(openFileDialog.FileName, currentYear);
                }
                else if (loadFrom == "Dyadic")
                {
                    net.LoadFromDyadicFile(openFileDialog.FileName, currentYear);
                }
            }
        }