Exemplo n.º 1
0
 /// <summary>
 /// Compares node marking and this marking
 /// </summary>
 /// <param name="node"></param>
 /// <returns>-1 - if this is not bigger as node, 0 - if this marking is equals as node marking and 1 if this marking is bigger</returns>
 public int Compare(MarkingTreeNode node)
 {
     if (this.Marking.Length != node.Marking.Length)
         throw new Exception("Ivalid parameter");
     bool f = false;
     for (int i = 0; i < node.Marking.Length; i++)
     {
         // 0 < 1 or 1 < w
         if ((node.Marking[i] > this.Marking[i] || node.Marking[i] == MarkingTreeNode.w) && this.Marking[i] != MarkingTreeNode.w)
             return -1;
         // 1 > 0 or w > 1
         // w == w
         if (node.Marking[i] < this.Marking[i] || (this.Marking[i] == MarkingTreeNode.w && node.Marking[i] != MarkingTreeNode.w))
             f = true;
     }
     return f ? 1 : 0;
 }
Exemplo n.º 2
0
        private uint GetPlaceLimit(int index, MarkingTreeNode node, uint max)
        {
            uint _max;
            if (node.Marking[index] > max)
                _max = node.Marking[index];
            else
                _max = max;

            if (node.Children.Count == 0)
                return _max;

            uint maxChilds = node.Children.Max(child => this.GetPlaceLimit(index, child as MarkingTreeNode, _max));
            return Math.Max(_max, maxChilds);
        }
Exemplo n.º 3
0
 private bool EqualsMarks(MarkingTreeNode node, int sum)
 {
     if (node.HasW() || node.GetMarksSum() != sum)
         return false;
     return node.Children.All(child => this.EqualsMarks(child as MarkingTreeNode, sum));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Проверка на достижимости маркировки. Если маркировка достижима, то возвращается 1, если нет, то -1.
 /// В случае, если достижимость не возможно определить с помощью дерева достижимости возвращается 0.
 /// </summary>
 /// <param name="marking"></param>
 /// <returns></returns>
 public int IsAchievable(uint[] marking)
 {
     bool f = false;
     var m = new MarkingTreeNode(null, null, null, marking);
     foreach (MarkingTreeNode node in this)
     {
         if(node.Compare(m) == 0)
         {
             return 1;
         }
         if (node.Compare(m) == 1)
         {
             f = true;
         }
     }
     return f ? 0 : -1;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Проверка на наличие сивола w в маркировке и всех её детях.
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 public bool HasW(MarkingTreeNode node)
 {
     if (node.HasW())
         return true;
     return node.Children.Any(child => this.HasW(child as MarkingTreeNode));
 }
 public MarkingTreeNodeWrapper(MarkingTreeWrapper wrapper, MarkingTreeNode node)
     : base(wrapper, node)
 {
 }
Exemplo n.º 7
0
 public MarkingTreeNode(TreeGraph tree, string markingName, MarkingTreeNode parent, uint[] marking)
     : base(tree, markingName, parent)
 {
     this.Marking = marking;
     this.Status = MarkingNodeStatus.Boundary;
 }
Exemplo n.º 8
0
 private MarkingTreeNode Covers(MarkingTreeNode node)
 {
     if (this.Compare(node) == 1)
         return node;
     MarkingTreeNode res = null;
     node.Children.ForEach(delegate(ITreeNode child)
     {
         res = this.Covers(child as MarkingTreeNode);
         if (res != null)
             return;
     });
     return res;
 }