- Timestamp:
- 03/31/10 18:34:34 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/SymbolicExpressionTree.cs
r3237 r3244 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-20 08Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 21 21 22 22 using System; 23 using System.Linq; 23 24 using System.Collections.Generic; 24 25 using System.Text; … … 60 61 public SymbolicExpressionTree(SymbolicExpressionTreeNode root) : base() { } 61 62 63 public IEnumerable<SymbolicExpressionTreeNode> IterateNodesPrefix() { 64 return IterateNodesPrefix(root); 65 } 66 private IEnumerable<SymbolicExpressionTreeNode> IterateNodesPrefix(SymbolicExpressionTreeNode node) { 67 yield return node; 68 foreach (var subtree in node.SubTrees) { 69 foreach (var n in IterateNodesPrefix(subtree)) 70 yield return n; 71 } 72 } 73 public IEnumerable<SymbolicExpressionTreeNode> IterateNodesPostfix() { 74 return IterateNodesPostfix(root); 75 } 76 private IEnumerable<SymbolicExpressionTreeNode> IterateNodesPostfix(SymbolicExpressionTreeNode node) { 77 foreach (var subtree in node.SubTrees) { 78 foreach (var n in IterateNodesPrefix(subtree)) 79 yield return n; 80 } 81 yield return node; 82 } 83 62 84 public override IDeepCloneable Clone(Cloner cloner) { 63 85 SymbolicExpressionTree clone = new SymbolicExpressionTree(); -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/SymbolicExpressionTreeNode.cs
r3237 r3244 26 26 using System.Xml; 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Data; 28 29 29 30 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { … … 49 50 //} 50 51 51 internalvirtual bool HasLocalParameters {52 public virtual bool HasLocalParameters { 52 53 get { return false; } 53 54 } … … 62 63 } 63 64 64 internalint GetSize() {65 public int GetSize() { 65 66 int size = 1; 66 67 foreach (SymbolicExpressionTreeNode tree in SubTrees) size += tree.GetSize(); … … 68 69 } 69 70 70 internalint GetHeight() {71 public int GetHeight() { 71 72 int maxHeight = 0; 72 73 foreach (SymbolicExpressionTreeNode tree in SubTrees) maxHeight = Math.Max(maxHeight, tree.GetHeight());
Note: See TracChangeset
for help on using the changeset viewer.