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 |
|
---|
22 | using System.Collections.Generic;
|
---|
23 | using System.Linq;
|
---|
24 |
|
---|
25 | namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.LayoutEngines {
|
---|
26 | public class LayoutNode<T> : ILayoutNode<T> where T : class {
|
---|
27 | public ILayoutNode<T> NextLeft {
|
---|
28 | get {
|
---|
29 | return Children == null ? Thread : Children.First();
|
---|
30 | }
|
---|
31 | }
|
---|
32 | public ILayoutNode<T> NextRight {
|
---|
33 | get {
|
---|
34 | return Children == null ? Thread : Children.Last();
|
---|
35 | }
|
---|
36 | }
|
---|
37 | public ILayoutNode<T> LeftSibling {
|
---|
38 | get {
|
---|
39 | if (Parent == null) return null;
|
---|
40 | return Number == 0 ? null : Parent.Children[Number - 1];
|
---|
41 | }
|
---|
42 | }
|
---|
43 | public ILayoutNode<T> LeftmostSibling {
|
---|
44 | get {
|
---|
45 | if (Parent == null) return null;
|
---|
46 | return Number == 0 ? null : Parent.Children[0];
|
---|
47 | }
|
---|
48 | }
|
---|
49 |
|
---|
50 | public ILayoutNode<T> Thread { get; set; }
|
---|
51 | public ILayoutNode<T> Ancestor { get; set; }
|
---|
52 | public ILayoutNode<T> Parent { get; set; }
|
---|
53 | public List<ILayoutNode<T>> Children { get; set; }
|
---|
54 | public float Mod { get; set; }
|
---|
55 | public float Prelim { get; set; }
|
---|
56 | public float Change { get; set; }
|
---|
57 | public float Shift { get; set; }
|
---|
58 | public int Number { get; set; }
|
---|
59 | public int Level { get; set; }
|
---|
60 | public float X { get; set; }
|
---|
61 | public float Y { get; set; }
|
---|
62 |
|
---|
63 | public bool IsLeaf {
|
---|
64 | get { return Children == null || Children.Count == 0; }
|
---|
65 | }
|
---|
66 |
|
---|
67 | public T Content { get; set; }
|
---|
68 | }
|
---|
69 | }
|
---|