#region License Information /* HeuristicLab * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System.Collections.Generic; using System.Linq; namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.LayoutEngines { public class LayoutNode : ILayoutNode where T : class { public ILayoutNode NextLeft { get { return Children == null ? Thread : Children.First(); } } public ILayoutNode NextRight { get { return Children == null ? Thread : Children.Last(); } } public ILayoutNode LeftSibling { get { if (Parent == null) return null; return Number == 0 ? null : Parent.Children[Number - 1]; } } public ILayoutNode LeftmostSibling { get { if (Parent == null) return null; return Number == 0 ? null : Parent.Children[0]; } } public ILayoutNode Thread { get; set; } public ILayoutNode Ancestor { get; set; } public ILayoutNode Parent { get; set; } public List> Children { get; set; } public float Mod { get; set; } public float Prelim { get; set; } public float Change { get; set; } public float Shift { get; set; } public int Number { get; set; } public int Level { get; set; } public float X { get; set; } public float Y { get; set; } public bool IsLeaf { get { return Children == null || Children.Count == 0; } } public T Content { get; set; } } }