public CharactersTreeNode()
 {
     _id       = Guid.NewGuid().ToString();
     _parent   = null;
     _childred = new HashSet <CharactersTreeNode>();
     _path     = new HashSet <string>();
     _path.Add(_id);
 }
 public CharactersTreeNode()
 {
     _id = Guid.NewGuid().ToString();
     _parent = null;
     _childred = new HashSet<CharactersTreeNode>();
     _path = new HashSet<string>();
     _path.Add(_id);
 }
 public CharactersTreeNode(string id, CharactersTreeNode parent, IEnumerable <CharactersTreeNode> children)
 {
     _id       = id;
     _parent   = parent;
     _childred = new HashSet <CharactersTreeNode>(children);
     _path     = new HashSet <string>();
     if (parent != null)
     {
         foreach (string pathNode in parent.Path)
         {
             _path.Add(pathNode);
         }
     }
     _path.Add(_id);
 }
 public CharactersTreeNode(string id, CharactersTreeNode parent, IEnumerable<CharactersTreeNode> children)
 {
     _id = id;
     _parent = parent;
     _childred = new HashSet<CharactersTreeNode>(children);
     _path = new HashSet<string>();
     if (parent != null)
     {
         foreach (string pathNode in parent.Path)
         {
             _path.Add(pathNode);
         }
     }
     _path.Add(_id);
 }
        /// <summary>
        /// Implements BFS to find all the path from the start node to the end node.
        /// NOTE: Needs Character-Characters data to be loaded.
        /// </summary>
        /// <param name="characterStartId"></param>
        /// <param name="characterEnd"></param>
        /// <returns></returns>
        private List<HashSet<string>> FindAllPaths(string characterStartId, string characterEndId)
        {
            if (_characterCharactersData == null) return null;

            List<HashSet<string>> allPaths = new List<HashSet<string>>();

            HashSet<CharactersTreeNode> nodesToExplore = new HashSet<CharactersTreeNode>();
            CharactersTreeNode nodeStart = new CharactersTreeNode(characterStartId, null);
            nodesToExplore.Add(nodeStart);
            CharactersTreeNode curNode = null;

            while (nodesToExplore.Count > 0)
            {
                foreach (CharactersTreeNode node in nodesToExplore)
                {
                    curNode = node;
                    break;
                }

                if (curNode.ID.Equals(characterEndId) && (curNode.PathLength() > 1))
                {
                    allPaths.Add(curNode.Path);
                }
                else if (curNode.PathLength() < LEGTH_THRESHOLD)
                {
                    curNode.LoadChildren(GetConnections(curNode.ID));
                    foreach (CharactersTreeNode child in curNode.Children)
                    {
                        nodesToExplore.Add(child);
                    }
                }

                nodesToExplore.Remove(curNode);
            }

            return allPaths;
        }