Пример #1
0
 public String pathLabel() {
   if (parentEdge != null) {
     StringBuilder sb = new StringBuilder(parentEdge.headNode.pathLabel());
     for (int i = 0; i < parentEdge.length(); i++) {
       sb.append(parentEdge.getChar(i));
     }
     return sb.toString();
   } else {
     return "";
   }
 }
Пример #2
0
    public void addEdge(TreeEdge e) {
      if (e.start() == e.string.length() - 1) {
        int key = e.string.getIndex();
        if (terminalEdges.containsKey(key)) {
          throw new IllegalArgumentException();
        }

        e.headNode = this;
        terminalEdges.put(key, e);
      } else {
        char key = e.getChar(0);
        if (childEdges.containsKey(key)) {
          throw new IllegalArgumentException();
        }
        e.headNode = this;
        childEdges.put(key, e);
      }
    }