source: branches/HeuristicLab.ReingoldTilfordTreeLayout/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs @ 10487

Last change on this file since 10487 was 10471, checked in by bburlacu, 6 years ago

#2076: Thanks for the feedback:

  • I removed the ILayoutNode Interfaces
  • Fixed the error that was causing it to crash in the textual representation
  • The ancestor is a node on the path between the root and the current node (from the paper), but in the algorithm it's assigned differently
  • Parent is the immediate parent

I also increased the node label text size a bit and did some cosmetic improvements.

File size: 2.4 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Linq;
25
26namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
27  public class LayoutNode<T> where T : class {
28    public LayoutNode<T> NextLeft {
29      get {
30        return Children == null ? Thread : Children.First();
31      }
32    }
33    public LayoutNode<T> NextRight {
34      get {
35        return Children == null ? Thread : Children.Last();
36      }
37    }
38    public LayoutNode<T> LeftSibling {
39      get {
40        if (Parent == null) return null;
41        return Number == 0 ? null : Parent.Children[Number - 1];
42      }
43    }
44    public LayoutNode<T> LeftmostSibling {
45      get {
46        if (Parent == null) return null;
47        return Number == 0 ? null : Parent.Children[0];
48      }
49    }
50
51    public LayoutNode<T> Thread { get; set; }
52    public LayoutNode<T> Ancestor { get; set; }
53    public LayoutNode<T> Parent { get; set; }
54    public List<LayoutNode<T>> Children { get; set; }
55    public float Mod { get; set; }
56    public float Prelim { get; set; }
57    public float Change { get; set; }
58    public float Shift { get; set; }
59    public int Number { get; set; }
60    public int Level { get; set; }
61    public float X { get; set; }
62    public float Y { get; set; }
63
64    public bool IsLeaf {
65      get { return Children == null || Children.Count == 0; }
66    }
67
68    private T content;
69    public T Content {
70      get { return content; }
71      set {
72        if (value == null)
73          throw new ArgumentNullException("LayoutNode: Content cannot be null.");
74        content = value;
75      }
76    }
77  }
78}
Note: See TracBrowser for help on using the repository browser.