public void add(Reaction R, Main m){
    
    int IDCheck;
    int index = checkReactionID(R.getIntID());  // index = index of R in Graph. checks if R is in Graph, if it is, returns index.
   
    if(index==-1){                               // ie. if R isnt in Graph
      index=graphNodes.size();
      graphNodes.add(new GraphNode(new Reaction(R), index));  // NEW INSTANCE OF R IS ADDED
      //R.printReaction();
    }
    
    for(int i=0; i<R.getReactants().length; i++){
      
      IDCheck = R.getReactants()[i];
      int reactantIndex = checkMoleculeID(IDCheck);   // Checks to see if reactant is already in graph.
      
      if(reactantIndex==-1){    // ie. if reactant isnt in graph
        reactantIndex = graphNodes.size();
        graphNodes.add(new GraphNode(new Molecule(m.getLibrary().get(IDCheck).getMol()), reactantIndex));   // NEW INSTANCE OF MOLECULE IS ADDEDx
      }
      
      //System.out.printf("(%d) is a parent of (%d)\n", reactantIndex, index);
      graphNodes.get(reactantIndex).connect(graphNodes.get(index));      //Makes directed edge
      
    }
    
    for(int i=0; i<R.getProducts().length; i++){
      
      IDCheck = R.getProducts()[i];
      int productIndex = checkMoleculeID(IDCheck);
      
      if(productIndex==-1){
        productIndex = graphNodes.size();
        graphNodes.add(new GraphNode(new Molecule(m.getLibrary().get(IDCheck).getMol()), productIndex));
      }
      //if(index==1){System.out.printf("\n(1) has another child` ie %d child!!!!\n", R.getProducts().length);}
      //if(index==0){System.out.printf("!!!!!!!!\n");}
      //System.out.printf("(%d) is a parent of (%d)\n", index, productIndex);
      graphNodes.get(index).connect(graphNodes.get(productIndex));
      
    }
  
  }