public static bool IsForestSpecificationValid(ForestSpecification fs, NodeSymbol backTrack, out string errorInformation) { if (null == fs) { errorInformation = "Forest Specification is null."; return(false); } if (string.IsNullOrEmpty(backTrack)) { errorInformation = "Invalid back track symbol."; return(false); } if (null == fs.Labels || fs.Labels.Count <= 0) { errorInformation = "Number of labels must be larger than 0."; return(false); } if (fs.Labels.Contains(backTrack)) { errorInformation = string.Format("The set of labels should not contain '{0}', it is reserved for back tracking.", backTrack); return(false); } if (fs.Labels.Distinct().Count() != fs.Labels.Count) { errorInformation = GetDuplicationInformation(fs.Labels); return(false); } errorInformation = "Forest Specification is valid."; return(true); }
private static bool IsForestSpecificationValid(ForestSpecification fs, NodeSymbol backTrack) { string errMsg; if (ForestSpecification.IsForestSpecificationValid(fs, backTrack, out errMsg)) { return(true); } MessageBox.Show(errMsg); return(false); }
public static List <ITextTree> Generate(ForestSpecification fs, NodeSymbol backTrack) { if (!IsForestSpecificationValid(fs, backTrack)) { return(null); } var forest = new List <ITextTree>(); var ts = new TreeSpecification(fs.Labels) { MaxDepth = fs.MaxTreeDepth, MaxDegree = fs.MaxDegree }; for (var i = 0; i < fs.NumberOfTrees; i++) { var tree = PlantTree(string.Format("{0:00000000}", i), ts, Random); forest.Add(tree); } return(forest); }