예제 #1
0
 public static Tree MakeRoot()
 {
     return(new Tree {
         branches = new[] {
             TreeBranch.MakeRoot()
         }
     });
 }
예제 #2
0
 static public Tree Parse(string s)
 {
     return(new Tree {
         branches = s.Split(';')
                    .Select(b => TreeBranch.FromString(b))
                    .ToArray()
     });
 }
예제 #3
0
        public static TreeBranch FromString(string s)
        {
            string[] cs   = s.Split("-→".ToCharArray());
            var      b    = new TreeBranch();
            int      code = int.Parse(cs[1]);

            Debug.Assert(code < 100, "Only parent may be out of main sector");
            b.node = Grid.Instance.GetNode(code);
            if (cs[0] != "")
            {
                int parentCode = int.Parse(cs[0]);
                b.parentDir = Array.IndexOf(b.node.neighbors, parentCode);
                Debug.Assert(b.parentDir != -1, "Parent not found");
            }
            return(b);
        }