public int searchForGraphInIndex(DocumentNGramGraph dgNewGraph){
  int idgName=0;
  NGramCachedGraphComparator ngcIntra=new NGramCachedGraphComparator();
  Set<String> graphSet=indexOfGraphs.keySet();
  DocumentNGramGraph dgSeg=(DocumentNGramGraph)dgNewGraph.clone();
  for (  String graphName : graphSet) {
    DocumentNGramGraph ClassGraph=indexOfGraphs.get(graphName);
    GraphSimilarity gs;
    gs=ngcIntra.getSimilarityBetween(dgSeg,ClassGraph);
    if (calcOverallSimilarity(gs) >= maxForMerging) {
      idgName=Integer.valueOf(graphName);
      break;
    }
 else     if (calcOverallSimilarity(gs) >= minForMerging) {
      idgName=Integer.valueOf(graphName);
      ClassGraph.mergeGraph(dgSeg,1 - (dNameInstanceCount.getValue(graphName) / (dNameInstanceCount.getValue(graphName) + 1)));
      dNameInstanceCount.increaseValue(graphName,1.0);
      break;
    }
    if (1.0 - gs.ContainmentSimilarity > 10e-5) {
      dgSeg=dgSeg.allNotIn(ClassGraph);
    }
  }
  if (idgName == 0) {
    if (!indexOfGraphs.isEmpty()) {
      idgName=graphSet.size() + 1;
    }
 else {
      idgName++;
    }
    indexOfGraphs.put(Integer.toString(idgName),dgSeg);
  }
  return idgName;
}

public int searchForGraphInIndex ( DocumentNGramGraph dgNewGraph ) { int idgName = 0 ; NGramCachedGraphComparator ngcIntra = new NGramCachedGraphComparator ( ) ; Set < String > graphSet = indexOfGraphs . keySet ( ) ; DocumentNGramGraph dgSeg = ( DocumentNGramGraph ) dgNewGraph . clone ( ) ; for ( String graphName : graphSet ) { DocumentNGramGraph ClassGraph = indexOfGraphs . get ( graphName ) ; GraphSimilarity gs ; gs = ngcIntra . getSimilarityBetween ( dgSeg , ClassGraph ) ; if ( calcOverallSimilarity ( gs ) >= maxForMerging ) { idgName = Integer . valueOf ( graphName ) ; break ; } else if ( calcOverallSimilarity ( gs ) >= minForMerging ) { idgName = Integer . valueOf ( graphName ) ; ClassGraph . mergeGraph ( dgSeg , 1 - ( dNameInstanceCount . getValue ( graphName ) / ( dNameInstanceCount . getValue ( graphName ) + 1 ) ) ) ; dNameInstanceCount . increaseValue ( graphName , 1.0 ) ; break ; } if ( 1.0 - gs . ContainmentSimilarity > 10e-5 ) { dgSeg = dgSeg . allNotIn ( ClassGraph ) ; } } if ( idgName == 0 ) { if ( ! indexOfGraphs . isEmpty ( ) ) { idgName = graphSet . size ( ) + 1 ; } else { idgName ++ ; } indexOfGraphs . put ( Integer . toString ( idgName ) , dgSeg ) ; } return idgName ; }
searches into the index for a given graph , updating the index if required . returns the symbol number for the given graph .
