Esempio n. 1
0
 void doTraversal(Node n, int length, ref int idx)
 {
     if (n.childCount() > 0) //If it is internal node
      {
     var iter = n.childIterator();
     while (iter.MoveNext())
     {
        Edge edgein = Edges[iter.Current.Value.edgeIn];
        int length_with_edge = length + (edgein.indexOfLastCharacter - edgein.indexOfFirstCharacter) + 1;
        doTraversal(iter.Current.Value, length_with_edge, ref idx);
     }
      }
      else if (n.childCount() == 0)
      {
     suffixArray[idx++] = suffixArray.Count - length;
      }
 }
Esempio n. 2
0
 public void addChild(Node child)
 {
     if (!children.ContainsKey(child.suffixNode))
     children.Add(child.suffixNode, child);
 }
Esempio n. 3
0
        public int SplitEdge(Suffix s, List<int> theString, Dictionary<int, Edge> edges, Dictionary<int, Node> nodes)
        {
            Remove(theString, edges);
             Edge newEdge = new Edge(theString,
                                 this.indexOfFirstCharacter,
                                 this.indexOfFirstCharacter + s.indexOfLastCharacter - s.indexOfFirstCharacter,
                                 s.originNode);
             newEdge.Insert(theString, edges, nodes);

             if (nodes.ContainsKey(newEdge.endNode))
             {
            nodes[newEdge.endNode].suffixNode = s.originNode;
             }
             else
             {
            Node newNode = new Node();
            newNode.suffixNode = s.originNode;
            nodes.Add(newEdge.endNode, newNode);
             }

             this.indexOfFirstCharacter += s.indexOfLastCharacter - s.indexOfFirstCharacter + 1;
             this.startNode = newEdge.endNode;
             this.Insert(theString, edges, nodes);
             return newEdge.endNode;
        }