예제 #1
0
 public static void FillTransitions(List <StateVertex> list, CommonMatrix state)
 {
     for (int i = 0; i < state.Rows; i++)
     {
         var trans = list[i].Transitions;
         for (int j = 0; j < state.Columns; j++)
         {
             trans.Add(list[(int)state.Value[i, j].Value]);
         }
     }
 }
예제 #2
0
        public static List <StateVertex> GetVertexes(CommonMatrix vert, Func <int, int, Rectangle> rectAction)
        {
            var list = new List <StateVertex>();

            for (int i = 0; i < vert.Rows; i++)
            {
                for (int j = 0; j < vert.Columns; j++)
                {
                    var num = vert.Value[i, j].Value;
                    if (num > -1)
                    {
                        list.Add(new StateVertex((int)num, rectAction(i, j)));
                    }
                }
            }

            return(list.OrderBy(v => v.Number).ToList());
        }
예제 #3
0
        public static CommonMatrix GetMatrixFromFile(string filePath)
        {
            if (!File.Exists(filePath))
            {
                return(null);
            }

            var lines  = File.ReadAllLines(filePath);
            var matrix = new CommonMatrix(lines.Length, lines[0].Split(' ').Length);

            for (int i = 0; i < matrix.Rows; i++)
            {
                var numbers = lines[i].Split(' ');
                for (int j = 0; j < matrix.Columns; j++)
                {
                    matrix.Value[i, j] = new RealNumber(numbers[j]);
                }
            }

            return(matrix);
        }