예제 #1
0
        private void tableToolStripMenuItem_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")
                    {
                        if (useMultipleFiles)
                        {
                            net.LoadFromMultipleFiles(fileNames, year);
                        }
                        else
                        {
                            net.LoadFromMatrixFile(openFileDialog.FileName, year);
                        }
                    }
                    else if (loadFrom == "Dyadic")
                    {
                        if (useMultipleFiles)
                        {
                            net.LoadFromMultivariableDyadicFile(fileNames[0], year);
                        }
                        else
                        {
                            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);
                    }
                    progress.curYear = year;
                    Application.DoEvents();
                    previousYear = year;

                    if (displayMatrix == "Counter" || displayMatrix == "SignedNetwork" || displayMatrix == "Centrality" ||
                        displayMatrix == "NetworkPower" || displayMatrix == "LocalTransitivity" || displayMatrix == "NatDep" ||
                        displayMatrix == "Triadic" || displayMatrix == "Characteristics" || displayMatrix == "ClusterCharacteristics" ||
                        displayMatrix == "BlockCharacteristics" || displayMatrix == "Community" || displayMatrix == "OverlapCommCharacteristics" ||
                        displayMatrix == "LocalBalance" || displayMatrix == "CliqueCoefficients" || displayMatrix == "BlockCoefficients" ||
                        displayMatrix == "ClusterCoefficients" || displayMatrix == "OverlapCommCoefficients" || displayMatrix == "SingleNetworkExpectations" ||
                        displayMatrix == "NetworkSpilloverStatistics")
                    {
                        if (net.CohesionFilename != null)
                            net.CohesionMatrix = MatrixReader.ReadMatrixFromFile(net.CohesionFilename, year);
                        //DoLoadCorrect(year);
                        currentYear = year;
                        LoadData();
                        if (displayMatrix == "NatDep")
                        {
                            net.LoadUnitDependency(year);
                        }
                        else if (displayMatrix == "Community")
                        {
                            if (communityType == CommunityType.Char || communityType == CommunityType.Cluster || communityType == CommunityType.Coefficients || communityType == CommunityType.ovCoefficients || communityType == CommunityType.newCoefficients || communityType == CommunityType.newChar)
                            {
                                // do nothing; just avoiding a nested if statement
                            }
                            else
                            {
                                throw new Exception("Cannot save matrix as a Table format");
                            }
                        }
                    }
                    else
                    {
                        throw new Exception("Cannot save " + displayMatrix.ToString() + " matrix as a Table format");
                    }
                        
                    net.SaveAsTableToFile(saveFileDialog.FileName, year == startYear, _optionsForm.SaveOverwrite && year == startYear, displayMatrix, communityType);
                }
            }
        }
예제 #2
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);
                }
            }
        }
예제 #3
0
        private void signedNetworkCharacteristicsFileToolStripMenuItem_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 (year != previousYear && year <= endYear)
                    {
                        net.LoadSignedNetworkCharacteristics(dataGrid, _optionsForm.ReachNumMatrices, _optionsForm.reachSum, _optionsForm.reachZero, prevDisplayMatrix, year, reachBinary);
                        net.SaveSignedNetworkToFile(saveFileDialog.FileName, year == startYear, _optionsForm.SaveOverwrite && year == startYear);
                    }

                    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);
                    }
                    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);
                }
            }
        }
예제 #4
0
        private void multivariableDyadicFileToolStripMenuItem1_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;

                int prevYear = -1;
                for (int year = startYear; year <= endYear; ++year)
                {
                    prevYear = net.SaveToMultivariableDyadicFile(fileNames, saveFileDialog.FileName, year, prevYear, _optionsForm.SaveOverwrite);
                    if (prevYear == -1)
                        return;
                }

            }

        }
예제 #5
0
        private void affiliationFileToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (loadFrom == "")
                return;

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                int startYear, endYear;
                YearRangeForm range = new YearRangeForm();

                if (displayMatrix == "Affiliation")
                    range.SetMode(true);

                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();

                // Should we standardize?
                if (byRowToolStripMenuItem.Checked == true)
                    net.StandardizeByRow(displayMatrix);
                else if (byColumnToolStripMenuItem.Checked == true)
                    net.StandardizeByColumn(displayMatrix);
                else if (rowToolStripMenuItem.Checked == true)
                    net.StandardizeByDiagonalRow(displayMatrix);
                else if (columnToolStripMenuItem.Checked == true)
                    net.StandardizeByDiagonalColumn(displayMatrix);
                else if (minimumToolStripMenuItem.Checked == true)
                    net.StandardizeByDiagonalMinimum(displayMatrix);
                else if (maximumToolStripMenuItem.Checked == true)
                    net.StandardizeByDiagonalMaximum(displayMatrix);

                int year = startYear;
                while (true)
                {
                    progress.curYear = year;

                    if (displayMatrix == "Affiliation")
                    {
                        net.FindCliques(_optionsForm.Cutoff[currentYear], _optionsForm.InputType != "None", _optionsForm.Density, currentYear, _optionsForm.CMinMembers, false, _optionsForm.KCliqueValue, _optionsForm.KCliqueDiag);
                        net.SaveAffiliationToDyadicFile(saveFileDialog.FileName, year, year == startYear, _optionsForm.SaveOverwrite && year == startYear);
                    }
                    else if (displayMatrix == "CONCOR")
                    {
                        net.CONCOR(_blocForm.pos, openFileDialog.Multiselect, GetCONCORConvergenceFunction(), _blocForm.MaxNoSteps);
                        net.SaveBlocAffiliationToAffiliationFile(saveFileDialog.FileName, year, _blocForm.pos, _optionsForm.SaveOverwrite && year == startYear, openFileDialog.Multiselect, false);
                    }
                    else if (displayMatrix == "Cluster")
                    {
                        net.LoadClustering(_clusterForm.ClusteringMethod, _clusterForm.MaxNoClusters, currentYear, _optionsForm.Density);
                        net.SaveBlocAffiliationToAffiliationFile(saveFileDialog.FileName, year, _blocForm.pos, _optionsForm.SaveOverwrite && year == startYear, openFileDialog.Multiselect, true);
                    }
                    else if (displayMatrix == "Community")
                    {
                        net.calculateCommunities(dataGrid, communityType, currentYear, _comForm.SVC, _comForm.DVC, _comForm.attrMatrix, _optionsForm.getCutOff(currentYear), _optionsForm.Density);
                        net.SaveCommAffiliationToAffiliationFile(saveFileDialog.FileName, year, year == startYear, _optionsForm.SaveOverwrite && year == startYear);
                    }
                    else if (displayMatrix == "OverlappingCommunity")
                    {
                        net.FindCliques(_optionsForm.Cutoff[currentYear], _optionsForm.InputType != "None", _optionsForm.Density, currentYear, _optionsForm.CMinMembers, false, _optionsForm.KCliqueValue, _optionsForm.KCliqueDiag);
                        net.CalculateOverlapComm();
                        net.LoadOverlapCommAffilMatrix();
                        net.SaveOverlapCommAffiliationToAffiliationFile(saveFileDialog.FileName, year, year == startYear, _optionsForm.SaveOverwrite && year == startYear);
                    }

                    if (year < endYear)
                    {
                        if (loadFrom == "Matrix")
                        {
                            if (openFileDialog.Multiselect)
                                year = net.LoadFromMultipleFiles(fileNames, year + 1);
                            else
                                year = net.LoadFromMatrixFile(openFileDialog.FileName, year + 1);
                        }
                        else if (loadFrom == "Dyadic")
                        {
                            if (openFileDialog.Multiselect)
                                year = net.LoadFromMultivariableDyadicFile(openFileDialog.FileName, year + 1);
                            else
                                year = net.LoadFromDyadicFile(openFileDialog.FileName, year + 1);
                        }
                        else if (loadFrom == "Affil")
                        {
                            year = net.LoadFromAffiliationFile(openFileDialog.FileName, year + 1);
                        }
                        else if (loadFrom == "Random")
                        {
                            net.LoadRandom(_randomForm.N, "Data", _randomSymmetric, _randomForm.ProbRange, _randomForm.MinProb, _randomForm.MaxProb, _randomForm.RandomN, _randomForm.RandomMinN, _randomForm.RandomMaxN, _randomForm.RandomIntN);
                            ++year;
                        }
                        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);
                            ++year;
                        }
                        else if (loadFrom == "Monadic")
                        {
                            year = net.LoadFromMonadicFile(openFileDialog.FileName, year + 1);
                        }

                        //DoLoadCorrect(year);
                    }
                    else
                        break;
                }
            }
        }
예제 #6
0
        private void counterDataFileToolStripMenuItem_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) // used to be year = startYear
                {
                    

                    if (year != previousYear && year <= endYear)
                    {
                        DetermineCounter(year);
                        net.SaveCounterToFile(saveFileDialog.FileName, year == startYear, _optionsForm.SaveOverwrite && year == startYear);
                    }

                    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);
                    }
                    
                    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);
                }
            }

        }
예제 #7
0
        private void multipleMatrixFilesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (loadFrom == "")
                return;
            // Get however many we will need
            int fileCount = net.CountVarsInMultivariableDyadicFile(openFileDialog.FileName);

            MessageBox.Show("The multivariable dyadic data will be saved to " + fileCount + " matrix files."
                + " Please select them in order when prompted. You will then be able to choose the year range.", "Please Note!");

            List<string> files = new List<string>();
            while (fileCount-- > 0)
            {
                if (saveFileDialog.ShowDialog() != DialogResult.OK)
                    return;

                files.Add(saveFileDialog.FileName);
            }

            int startYear, endYear;
            YearRangeForm range = new YearRangeForm();
            range.from = currentYear;
            range.to = currentYear;
            range.ShowDialog();
            startYear = range.from;
            endYear = range.to;

            for (int year = startYear; year <= endYear; ++year)
            {
                net.SaveToMultipleMatrixFiles(openFileDialog.FileName, files.ToArray(), year, _optionsForm.SaveOverwrite && year == startYear);
            }

        }
예제 #8
0
        private void dyadicFileToolStripMenuItem1_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 p = new ProgressForm(startYear, endYear, 0);
                p.Show();

                int previousYear = -1;
                for (int year = startYear; year <= endYear; ++year)
                {
                    if (loadFrom == "Matrix")
                    {
                        if (openFileDialog.Multiselect)
                            year = net.LoadFromMultipleFiles(fileNames, year);
                        else
                            year = net.LoadFromMatrixFile(openFileDialog.FileName, year);
                    }
                    else if (loadFrom == "Dyadic")
                    {
                        if (openFileDialog.Multiselect)
                            year = net.LoadFromMultivariableDyadicFile(openFileDialog.FileName, year);
                        else
                            year = net.LoadFromDyadicFile(openFileDialog.FileName, year);
                    }
                    else if (loadFrom == "Affil")
                    {
                        year = net.LoadFromAffiliationFile(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);
                    }
                    else if (loadFrom == "Monadic")
                    {
                        year = net.LoadFromMonadicFile(openFileDialog.FileName, year );
                    }

                    // Should we standardize?
                    if (byRowToolStripMenuItem.Checked == true)
                        net.StandardizeByRow(displayMatrix);
                    else if (byColumnToolStripMenuItem.Checked == true)
                        net.StandardizeByColumn(displayMatrix);
                    else if (rowToolStripMenuItem.Checked == true)
                        net.StandardizeByDiagonalRow(displayMatrix);
                    else if (columnToolStripMenuItem.Checked == true)
                        net.StandardizeByDiagonalColumn(displayMatrix);
                    else if (minimumToolStripMenuItem.Checked == true)
                        net.StandardizeByDiagonalMinimum(displayMatrix);
                    else if (maximumToolStripMenuItem.Checked == true)
                        net.StandardizeByDiagonalMaximum(displayMatrix);

                    if (year != previousYear && year <= endYear)
                    {
                        if (net.CohesionFilename != null)
                            net.CohesionMatrix = MatrixReader.ReadMatrixFromFile(net.CohesionFilename, year);
                        //DoLoadCorrect(year);
                        currentYear = year;
                        LoadData();
                        
                        string s = net.MakeDefaultDyadicLabel(displayMatrix);
                        if (year != startYear)
                            s = null;
                        net.SaveMatrixToDyadicFile(saveFileDialog.FileName, year, displayMatrix, s, _optionsForm.SaveOverwrite && year == startYear);

                    }
                    p.curYear = year;
                    previousYear = year;
                }

                if (currentYear == endYear)
                    return;

                if (loadFrom == "Matrix")
                {
                    net.LoadFromMatrixFile(openFileDialog.FileName, currentYear);
                }
                else if (loadFrom == "Dyadic")
                {
                    net.LoadFromDyadicFile(openFileDialog.FileName, currentYear);
                }
                else if (loadFrom == "Affil")
                {
                    net.LoadFromAffiliationFile(openFileDialog.FileName, currentYear);
                }
                else if (loadFrom == "Monadic")
                {
                    net.LoadFromMonadicFile(openFileDialog.FileName, currentYear);
                }
            }
        }
예제 #9
0
        private void SaveAffiliationWithoutDisplay() //copy most of code from previous method
        {
            if (loadFrom == "")
                return;
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                int startYear, endYear;
                YearRangeForm range = new YearRangeForm();

                if (displayMatrix == "Affiliation")
                    range.SetMode(true);

                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();

                // Should we standardize?
                if (byRowToolStripMenuItem.Checked == true)
                    net.StandardizeByRow(displayMatrix);
                else if (byColumnToolStripMenuItem.Checked == true)
                    net.StandardizeByColumn(displayMatrix);
                else if (rowToolStripMenuItem.Checked == true)
                    net.StandardizeByDiagonalRow(displayMatrix);
                else if (columnToolStripMenuItem.Checked == true)
                    net.StandardizeByDiagonalColumn(displayMatrix);
                else if (minimumToolStripMenuItem.Checked == true)
                    net.StandardizeByDiagonalMinimum(displayMatrix);
                else if (maximumToolStripMenuItem.Checked == true)
                    net.StandardizeByDiagonalMaximum(displayMatrix);

                int year = startYear;
                while (true)
                {
                    progress.curYear = year;
                    if (displayMatrix == "Affiliation")
                        net.SaveAffiliationToMatrixFile(saveFileDialog.FileName, year, _optionsForm.Cutoff[currentYear], _optionsForm.InputType != "None", _optionsForm.InputType == "StructEquiv",
                                                         _optionsForm.FileName, _optionsForm.InputType == "Dyadic", _optionsForm.Density, _optionsForm.SumMean, _optionsForm.SumMeanFilename,
                                                         _optionsForm.svcFile, _optionsForm.SaveOverwrite && year == startYear,
                                                         cliqueSizeToolStripMenuItem1.Checked, cliqueCohesionToolStripMenuItem1.Checked, estebanRayIndexToolStripMenuItem1.Checked, _optionsForm.KCliqueValue, _optionsForm.KCliqueDiag);
                    else
                    {
                        //Thread s = new Thread(delegate()
                        //{
                        //    net.SaveCBCOverlapToFile(saveFileDialog.FileName, year, displayMatrix != "Characteristics",
                        //        displayMatrix != "Characteristics" || year == startYear, _optionsForm.SaveOverwrite && year == startYear);
                        //});
                     //   s.Start();
                        //while (!s.IsAlive) ;
                        //    Thread.Sleep(1);
                          //s.Join();
                        net.SaveCBCOverlapToFile(saveFileDialog.FileName, year, displayMatrix != "Characteristics",
                            displayMatrix != "Characteristics" || year == startYear, _optionsForm.SaveOverwrite && year == startYear, diag);
                    }
                    if (year < endYear)
                    {
                        if (loadFrom == "Matrix")
                        {
                            if (openFileDialog.Multiselect)
                                year = net.LoadFromMultipleFiles(fileNames, year + 1);
                            else
                                year = net.LoadFromMatrixFile(openFileDialog.FileName, year + 1);
                        }
                        else if (loadFrom == "Dyadic")
                        {
                            if (openFileDialog.Multiselect)
                                year = net.LoadFromMultivariableDyadicFile(openFileDialog.FileName, year + 1);
                            else
                                year = net.LoadFromDyadicFile(openFileDialog.FileName, year + 1);
                        }
                        else if (loadFrom == "Affil")
                        {
                            year = net.LoadFromAffiliationFile(openFileDialog.FileName, year + 1);
                        }
                        else if (loadFrom == "Random")
                        {
                            net.LoadRandom(_randomForm.N, "Data", _randomSymmetric, _randomForm.ProbRange, _randomForm.MinProb, _randomForm.MaxProb, _randomForm.RandomN, _randomForm.RandomMinN, _randomForm.RandomMaxN, _randomForm.RandomIntN);
                            ++year;
                        }
                        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);
                            ++year;
                        }
                        else if (loadFrom == "Monadic")
                        {
                            year = net.LoadFromMonadicFile(openFileDialog.FileName, year + 1);
                        }
                        //Thread t = new Thread(delegate() { DoLoadCorrect(year); });
                      //  t.Start();
                        //while (!t.IsAlive) ;
                        //   Thread.Sleep(1);
                      //  t.Join();
                        DoLoadCorrect(year);
                    }
                    else
                        break;
                }


                if (loadFrom == "Matrix")
                {
                    if (openFileDialog.Multiselect)
                        currentYear = net.LoadFromMultipleFiles(fileNames, currentYear);
                    else
                        currentYear = net.LoadFromMatrixFile(openFileDialog.FileName, currentYear);
                }
                else if (loadFrom == "Dyadic")
                {
                    if (openFileDialog.Multiselect)
                        currentYear = net.LoadFromMultivariableDyadicFile(openFileDialog.FileName, currentYear);
                    else
                        currentYear = net.LoadFromDyadicFile(openFileDialog.FileName, currentYear);
                }
                else if (loadFrom == "Affil")
                {
                    currentYear = net.LoadFromAffiliationFile(openFileDialog.FileName, currentYear);
                }
                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);
                }
            }
        }
예제 #10
0
        private void matrixFileToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (loadFrom == "")
                return;
            if (displayMatrix == "Counter")                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
            {
                counterDataFileToolStripMenuItem_Click(sender, e);
                return;
            }
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                int startYear, endYear;
                YearRangeForm range = new YearRangeForm();

                if (displayMatrix == "Affiliation")
                    range.SetMode(true);

                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();

                // Should we standardize?
                if (byRowToolStripMenuItem.Checked == true)
                    net.StandardizeByRow(displayMatrix);
                else if (byColumnToolStripMenuItem.Checked == true)
                    net.StandardizeByColumn(displayMatrix);
                else if (rowToolStripMenuItem.Checked == true)
                    net.StandardizeByDiagonalRow(displayMatrix);
                else if (columnToolStripMenuItem.Checked == true)
                    net.StandardizeByDiagonalColumn(displayMatrix);
                else if (minimumToolStripMenuItem.Checked == true)
                    net.StandardizeByDiagonalMinimum(displayMatrix);
                else if (maximumToolStripMenuItem.Checked == true)
                    net.StandardizeByDiagonalMaximum(displayMatrix);

                int year = startYear;
                while (true)
                {
                    progress.curYear = year;

                    if (displayMatrix == "Affiliation")
                        net.SaveAffiliationToMatrixFile(saveFileDialog.FileName, year, _optionsForm.Cutoff[currentYear], _optionsForm.InputType != "None", _optionsForm.InputType == "StructEquiv",
                                                        _optionsForm.FileName, _optionsForm.InputType == "Dyadic", _optionsForm.Density, _optionsForm.SumMean, _optionsForm.SumMeanFilename,
                                                        _optionsForm.svcFile, _optionsForm.SaveOverwrite && year == startYear,
                                                        cliqueSizeToolStripMenuItem1.Checked, cliqueCohesionToolStripMenuItem1.Checked, estebanRayIndexToolStripMenuItem1.Checked, _optionsForm.KCliqueValue, _optionsForm.KCliqueDiag);
                    else if (displayMatrix == "Affil" && loadFrom == "Affil")
                        net.SaveAffiliationMatrixToMatrixFile(saveFileDialog.FileName, year, _optionsForm.SaveOverwrite && year == startYear);
                    else if (displayMatrix == "NatDep")
                        net.SaveNationalDependencyToMatrixFile(saveFileDialog.FileName, year, _optionsForm.SaveOverwrite && year == startYear);
                    else if (displayMatrix == "CONCOR")
                        net.SaveBlocAffiliationToMatrixFile(saveFileDialog.FileName, year, _blocForm.pos, _optionsForm.SaveOverwrite && year == startYear, openFileDialog.Multiselect);
                    else if (displayMatrix == "Clustering")
                        net.SaveBlocAffiliationToMatrixFile(saveFileDialog.FileName, year, _blocForm.pos, _optionsForm.SaveOverwrite && year == startYear, openFileDialog.Multiselect);
                    else if (displayMatrix == "CBCO" || displayMatrix == "CBCODiag")
                        net.SaveCBCOverlapToFile(saveFileDialog.FileName, year, displayMatrix != "Characteristics",
                            displayMatrix != "Characteristics" || year == startYear, _optionsForm.SaveOverwrite && year == startYear, diag);
                    else
                        net.SaveMatrixToMatrixFile(saveFileDialog.FileName, year, displayMatrix, displayMatrix != "Characteristics",
                            displayMatrix != "Characteristics" || year == startYear, _optionsForm.SaveOverwrite && year == startYear);



                    if (year < endYear)
                    {
                        if (loadFrom == "Matrix")
                        {
                            if (openFileDialog.Multiselect)
                                year = net.LoadFromMultipleFiles(fileNames, year + 1);
                            else
                                year = net.LoadFromMatrixFile(openFileDialog.FileName, year + 1);
                        }
                        else if (loadFrom == "Dyadic")
                        {
                            if (openFileDialog.Multiselect)
                                year = net.LoadFromMultivariableDyadicFile(openFileDialog.FileName, year + 1);
                            else
                                year = net.LoadFromDyadicFile(openFileDialog.FileName, year + 1);
                        }
                        else if (loadFrom == "Affil")
                        {
                            year = net.LoadFromAffiliationFile(openFileDialog.FileName, year + 1);
                        }
                        else if (loadFrom == "Random")
                        {
                            net.LoadRandom(_randomForm.N, "Data", _randomSymmetric, _randomForm.ProbRange, _randomForm.MinProb, _randomForm.MaxProb, _randomForm.RandomN, _randomForm.RandomMinN, _randomForm.RandomMaxN, _randomForm.RandomIntN);
                            ++year;
                        }
                        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);
                            ++year;
                        }
                        else if (loadFrom == "Monadic")
                        {
                            year = net.LoadFromMonadicFile(openFileDialog.FileName, year + 1);
                        }

                        if (net.CohesionFilename != null)
                            net.CohesionMatrix = MatrixReader.ReadMatrixFromFile(net.CohesionFilename, year);
                        //DoLoadCorrect(year);
                        currentYear = year;
                        LoadData();
                    }
                    else
                        break;
                }

                // display the last matrix in program
                if (loadFrom == "Matrix")
                {
                    if (openFileDialog.Multiselect)
                        currentYear = net.LoadFromMultipleFiles(fileNames, currentYear);
                    else
                        currentYear = net.LoadFromMatrixFile(openFileDialog.FileName, currentYear);
                }
                else if (loadFrom == "Dyadic")
                {
                    if (openFileDialog.Multiselect)
                        currentYear = net.LoadFromMultivariableDyadicFile(openFileDialog.FileName, currentYear);
                    else
                        currentYear = net.LoadFromDyadicFile(openFileDialog.FileName, currentYear);
                }
                else if (loadFrom == "Affil")
                {
                    currentYear = net.LoadFromAffiliationFile(openFileDialog.FileName, currentYear);
                }
                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);
                }
            }
        }
예제 #11
0
        private void counterDataFileToolStripMenuItem_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.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);
                }
            }
        }
예제 #12
0
        private void dyadicFileToolStripMenuItem1_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 p = new ProgressForm(startYear, endYear, 0);
                p.Show();

                int previousYear = -1;
                for (int year = startYear; year <= endYear; ++year)
                {
                    if (loadFrom == "Matrix")
                    {
                        if (openFileDialog.Multiselect)
                            year = net.LoadFromMultipleFiles(fileNames, year);
                        else
                            year = net.LoadFromMatrixFile(openFileDialog.FileName, year);
                    }
                    else if (loadFrom == "Dyadic")
                    {
                        if (openFileDialog.Multiselect)
                            year = net.LoadFromMultivariableDyadicFile(openFileDialog.FileName, year);
                        else
                            year = net.LoadFromDyadicFile(openFileDialog.FileName, year);
                    }
                    else if (loadFrom == "Affil")
                    {
                        year = net.LoadFromAffiliationFile(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);
                    }
                    else if (loadFrom == "Monadic")
                    {
                        year = net.LoadFromMonadicFile(openFileDialog.FileName, year );
                    }

                    // Should we standardize?
                    if (byRowToolStripMenuItem.Checked == true)
                        net.StandardizeByRow(displayMatrix);
                    else if (byColumnToolStripMenuItem.Checked == true)
                        net.StandardizeByColumn(displayMatrix);
                    else if (rowToolStripMenuItem.Checked == true)
                        net.StandardizeByDiagonalRow(displayMatrix);
                    else if (columnToolStripMenuItem.Checked == true)
                        net.StandardizeByDiagonalColumn(displayMatrix);
                    else if (minimumToolStripMenuItem.Checked == true)
                        net.StandardizeByDiagonalMinimum(displayMatrix);
                    else if (maximumToolStripMenuItem.Checked == true)
                        net.StandardizeByDiagonalMaximum(displayMatrix);

                    if (year != previousYear && year <= endYear)
                    {
                        // First load correct matrix
                        if (displayMatrix == "SEE" || displayMatrix == "SEC" || displayMatrix == "SESE")
                            net.LoadStructEquiv(_optionsForm.Density, year, prevDisplayMatrix);
                        else if (displayMatrix == "Dependency")
                            net.LoadDependency(prevDisplayMatrix, _optionsForm.ReachNumMatrices, _optionsForm.Density, year, _optionsForm.reachZero);
                        else if (displayMatrix == "Reachability")
                            net.LoadReachability(_optionsForm.ReachNumMatrices, _optionsForm.reachSum, prevDisplayMatrix, currentYear, reachBinary);
                        else if (displayMatrix == "Components")
                            net.LoadComponents(_optionsForm.Cutoff[currentYear], _optionsForm.InputType != "None", _optionsForm.Density, currentYear, _optionsForm.CMinMembers, _optionsForm.ReachNumMatrices, _optionsForm.reachSum, _optionsForm.reachZero);
                        else if (displayMatrix == "Overlap" || displayMatrix == "OverlapDiag" || displayMatrix == "CBCO" || displayMatrix == "CBCODiag")
                            net.FindCliques(_optionsForm.Cutoff[currentYear], _optionsForm.InputType != "None", _optionsForm.Density, currentYear, _optionsForm.CMinMembers, false, _optionsForm.KCliqueValue, _optionsForm.KCliqueDiag);
                        else if (displayMatrix == "Centrality")
                            net.LoadCentralityIndices(prevDisplayMatrix, year, _centralityForm.Sijmax, _centralityForm.CountMember, _centralityForm.ZeroDiagonal);
                        else if (displayMatrix == "Characteristics")
                            net.LoadCliqueCharacteristics(_cliqueForm.SVC, _cliqueForm.DVC, _cliqueForm.attrMatrix, year);
                        else if (displayMatrix == "Multiplication")
                            net.LoadMultiplicationMatrix(_multiplicationForm.fileName, _multiplicationForm.dyadic, year, "Multiplication", prevDisplayMatrix);
                        else if (displayMatrix == "Elementwise")
                            net.LoadElementwiseMultiplication(openFileDialog2.FileName, currentYear, "Elementwise", ef);
                        else if (displayMatrix == "BinaryComplement")
                            net.LoadBinaryComplement(prevDisplayMatrix);
                        else if (displayMatrix == "RoleEquiv")
                            net.LoadRoleEquivalence(prevDisplayMatrix);
                        else if (displayMatrix == "AffilCorrelation" || displayMatrix == "AffilEuclidean")
                            ;
                        else if (displayMatrix != "Data")
                        {
                            MessageBox.Show("The matrix type '" + displayMatrix + "' cannot be saved to a dyadic file!", "Error!");
                            return;
                        }
                        string s = net.MakeDefaultDyadicLabel(displayMatrix);
                        if (year != startYear)
                            s = null;
                        net.SaveMatrixToDyadicFile(saveFileDialog.FileName, year, displayMatrix, s, _optionsForm.SaveOverwrite && year == startYear);

                    }
                    p.curYear = year;
                    previousYear = year;
                }

                if (currentYear == endYear)
                    return;

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