Example #1
0
        public void Floyd()
        {
            if (Data == null)
            {
                return;
            }
            int n = Data.GetLength(0);

            FloydData = new FloydCell[n, n];

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    FloydData[i, j] = new FloydCell(Data[i, j]);
                }
            }

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    if (FloydData[j, i].Value > 0)
                    {
                        for (int k = 0; k < n; k++)
                        {
                            if (FloydData[i, k].Value > 0)
                            {
                                if (FloydData[j, k].Value < 0 || FloydData[j, i].Value + FloydData[i, k].Value < FloydData[j, k].Value)
                                {
                                    FloydData[j, k].Value = FloydData[j, i].Value + FloydData[i, k].Value;

                                    FloydData[j, k].Previous = i;
                                }
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        public void Floyd()
        {
            if (Data == null)
                return;
            int n = Data.GetLength(0);

            FloydData = new FloydCell[n, n];

            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                    FloydData[i, j] = new FloydCell(Data[i, j]);

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    if (FloydData[j, i].Value > 0)
                    {
                        for (int k = 0; k < n; k++)
                        {
                            if (FloydData[i, k].Value > 0)
                            {
                                if (FloydData[j, k].Value < 0 || FloydData[j, i].Value + FloydData[i, k].Value < FloydData[j, k].Value)
                                {
                                    FloydData[j, k].Value = FloydData[j, i].Value + FloydData[i, k].Value;

                                    FloydData[j, k].Previous = i;
                                }
                            }
                        }
                    }
                }
            }
        }