public void formBond(Molecule A, Molecule B, Molecule Asub, Molecule Bsub, int bondingSite1, int bondingSite2){
    
    
    
    A.calculateMoleculeID(0,0,new int[0]);
    B.calculateMoleculeID(0,0, new int[0]);
    ArrayList<Molecule> molsA = A.split(Asub.getMolID());
    A.unFlagAll();
    ArrayList<Molecule> molsB = B.split(Bsub.getMolID());
    B.unFlagAll();
    if(molsA.size()>0){
      //System.out.printf("!!!!!!!!!!!! %d\n", molsA.size());
      
    }
    //System.out.printf(""+Arrays.toString(Asub.getMolID())+"\n");
    
    ArrayList<Network> after = new ArrayList<Network>();
    
    after.addAll( moleculeArrToNetworkArr(molsA) );
    after.addAll( moleculeArrToNetworkArr(molsB) );
    after.add( bond(Asub, Bsub, bondingSite1, bondingSite2) );

    
    numReactions++;
    ArrayList<Molecule> reactants = new ArrayList<Molecule>();
    ArrayList<Molecule> products = new ArrayList<Molecule>();
    
    reactants.add(A);
    reactants.add(B);
    //
    //System.out.printf("\n\t"+A.toStringf()+" + "+B.toStringf()+" --> ");
    bucket.remove(A);
    bucket.remove(B);
    library.get(A.getID()).decrPop();
    library.get(B.getID()).decrPop();
    
    
    
    for(int i=0; i<molsA.size(); i++){
      
      bucket.add(molsA.get(i));
      products.add(molsA.get(i));
      library.get(molsA.get(i).getID()).incrPop();
     // System.out.printf(""+molsA.get(i).toStringf()+" + ");
    }
    
    for(int i=0; i<molsB.size(); i++){
        
        bucket.add(molsB.get(i));
        products.add(molsB.get(i));
        library.get(molsB.get(i).getID()).incrPop();
       // System.out.printf(""+molsB.get(i).toStringf()+" + ");
      }
    
    
    
    int index = libraryUpdate(after.get(after.size()-1), Asub, Bsub);
    bucket.add(new Molecule(index, Asub, Bsub));
    library.get(index).incrPop();
    bucket.get(bucket.size()-1).setSize(Asub.getSize()+Bsub.getSize());
    
    products.add(bucket.get(bucket.size()-1));
    
    checkCatalysis(reactants, products);
    
    Reaction R = new Reaction(reactants, products);
    int reactionIndex = reactionsUpdate(R);
    reactions.get(reactionIndex).incrCount();
    

    //System.out.printf(""+bucket.get(bucket.size()-1).toStringf()+"\n");

    
  }