public int libraryUpdate(Network A, Molecule Asub, Molecule Bsub){
    int index=-1;
    int i = 0;
    while (index==-1 && i<library.size()){
      
      index = (A.equals(library.get(i))) ? i : -1;
      i++;
    }
    
    if(index == -1){
      library.add(A);
      index = library.size()-1;
      library.get(index).setMol(new Molecule( index, Asub, Bsub ) );
    }
    
    return index;
  }