示例#1
0
        public int GetNextMatrixRows()
        {
            switch (_type)
            {
            case Type.MatrixFile:
                return(MatrixReader.ReadMatrixFromFile(_sourceFile, _networkId).Rows);

            case Type.VectorFile:
                return(MatrixReader.ReadVectorFromFile(_sourceFile, _networkId).Rows);

            case Type.RandomDiagonal:
                return(_rows);

            case Type.RandomSymmetric:
                return(_rows);

            case Type.RandomNonSymmetric:
                return(_rows);

            case Type.RandomVector:
                return(_rows);

            case Type.RandomWithProbRange:
                return(_rows);

            case Type.NullFile:
                return(-1);

            default:
                return(0);
            }
        }
示例#2
0
        public Matrix ReadNext(bool overwrite)
        {
            Matrix m = null;

            switch (_type)
            {
            case Type.MatrixFile:
                m = MatrixReader.ReadMatrixFromFile(_sourceFile, _networkId);
                break;

            case Type.VectorFile:
                m = MatrixReader.ReadVectorFromFile(_sourceFile, _networkId);
                break;

            case Type.RandomDiagonal:
                m           = RandomMatrix.LoadDiagonal(_rows, true);
                m.NetworkId = _networkId;
                break;

            case Type.RandomSymmetric:
                m           = RandomMatrix.LoadSymmetric(_rows, range, pmin, pmax);
                m.NetworkId = _networkId;
                break;

            case Type.RandomNonSymmetric:
                m           = RandomMatrix.LoadNonSymmetric(_rows, range, pmin, pmax);
                m.NetworkId = _networkId;
                break;

            case Type.RandomVector:
                m           = RandomMatrix.LoadVector(_rows);
                m.NetworkId = _networkId;
                break;

            case Type.RandomWithProbRange:
                m           = RandomMatrix.LoadWithProbabilisticRange(_rows, _cols, _min, _max);
                m.NetworkId = _networkId;
                break;

            case Type.NullFile:
                return(null);
            }

            _networkId = m.NetworkId + 1;

            if (!string.IsNullOrEmpty(_outputFile) && _type != Type.NullFile)
            {
                WriteMatrixToFile(m, _isdyadic, overwrite);
            }

            /*
             * if (m.NetworkId < 1000)
             *  m.NetworkId = int.Parse("1" + m.NetworkId);
             */
            //else
            //  m.NetworkId = int.Parse("2" + m.NetworkId);
            //m.NetworkId = int.Parse("1" + m.NetworkId);
            return(m);
        }
示例#3
0
        private void goButton_Click(object sender, EventArgs e)
        {
            if (maxExtraction.Checked)
            {
                net.cet = Network.CliqueExtractionType.Max;
            }
            else if (minExtraction.Checked)
            {
                net.cet = Network.CliqueExtractionType.Min;
            }
            else if (upperExtraction.Checked)
            {
                net.cet = Network.CliqueExtractionType.Upper;
            }
            else if (lowerExtraction.Checked)
            {
                net.cet = Network.CliqueExtractionType.Lower;
            }

            if (inputTypeMatrix.Checked || inputTypeDyadic.Checked || inputTypeAtt.Checked) //(12/12/15) for invalid file selection
            {
                net.CohesionFilename = CohesionFileName;

                if (inputTypeAtt.Checked) //attribute vector
                {
                    //obtains the Network Id from the main Matrix
                    net.CohesionMatrix = MatrixReader.ReadAttributeVector(CohesionFilename, net.GetMatrix("Data").NetworkId);
                }

                else // other options
                {
                    net.CohesionMatrix = MatrixReader.ReadMatrixFromFile(CohesionFilename);
                }
            }
            double tmp;

            if ((binaryCutoff.Text != Constants.FileSelected && !double.TryParse(binaryCutoff.Text, out tmp) ||
                 (densityMax.Text != Constants.FileSelected && !double.TryParse(densityMax.Text, out d))) ||
                (reachNumMatrices.Text != Constants.FileSelected && !int.TryParse(reachNumMatrices.Text, out r)) ||
                (viableCoalitionValue.Text != Constants.FileSelected && !double.TryParse(viableCoalitionValue.Text, out v)) ||
                (cMinMembers.Text != Constants.FileSelected && !int.TryParse(cMinMembers.Text, out m)) ||
                (kCliqueValue.Text != Constants.FileSelected && !int.TryParse(kCliqueValue.Text, out k)) ||
                (!double.TryParse(alphaValue.Text, out a)))
            {
                MessageBox.Show("You have not entered proper real numbers!", "Error!");
            }
            else
            {
                if (densityMax.Text == Constants.FileSelected)
                {
                    d = -1.0;
                }
                if (reachNumMatrices.Text == Constants.FileSelected)
                {
                    r = -1;
                }
                if (viableCoalitionValue.Text == Constants.FileSelected)
                {
                    v = -1;
                }
                if (cMinMembers.Text == Constants.FileSelected)
                {
                    m = -1;
                }
                if (kCliqueValue.Text == Constants.FileSelected)
                {
                    k = -1;
                }
                this.Close();
            }
        }