public bool AddChild(Node node) { if (children.ContainsKey(node.c)) //node already present as child return false; children.Add(node.c, node); return true; }
//Add every substring found along the way to a hashset private void AddSubString(Node cur_node) { if (hs.Contains(cur_node.str)) { if (cur_node.str.Length > LongestRepeatedStr.Length) { LongestRepeatedStr = cur_node.str; //update if this is the max repeating substring } } else hs.Add(cur_node.str); }