private void addNodes(ArrayList<Term> query, int redGreenOrBlue, ArrayList<Integer> filterPages){
		//Build the nodes for the query.
		if(query.size() != 0){
			ArrayList<Integer> totalPagesInSelectedChapters = new ArrayList<>();
			for(int i = 0;i < selectedChapters.size();i++){
				for(int j = current.getChapter(selectedChapters.get(i)).getStart();j <= current.getChapter(selectedChapters.get(i)).getEnd();j++){
					totalPagesInSelectedChapters.add(j);
				}
			}
			for(int i = 0;i < query.size();i++){
				nodeCount++;
				Term termRoot = query.get(i);
				ArrayList<Term> queryOverlappingTerms = current.getOverlappingTerms(termRoot.getTerm(), selectedChapters);
				//create the node with the appropriate color.
				Node root = null;
				if(redGreenOrBlue == 1){
					//The node was already considered a related term so it needs to be removed.
					if(!rootTerms.contains(termRoot.getTerm()) && getNode(termRoot) != null){
						nodeCount--;
						Node.decrementNumberOfNodesGenerated();
						g.removeVertex(getNode(termRoot));
						termsInGraph.remove(getNode(termRoot));
					}
					if(!rootTerms.contains(termRoot.getTerm())){
						addTextInformation(termRoot, queryOverlappingTerms, totalPagesInSelectedChapters);
						root = new Node(termRoot, new Color((float)1.0, (float)0.0, (float)0.0), new Color((float)1.0, (float)0.0, (float)0.0), minimumSize+current.getNumberOfPagesInSelectedChapters(termRoot, selectedChapters).size()*magnificationFactor, redGreenOrBlue); 
					}
					//The term was already added to the graph
					else {
						continue;
					}
				}
				else if(redGreenOrBlue == 2){
					//The node was already considered a related term so it needs to be removed.
					if(!rootTerms.contains(termRoot.getTerm()) && getNode(termRoot) != null){
						nodeCount--;
						Node.decrementNumberOfNodesGenerated();
						g.removeVertex(getNode(termRoot));
						termsInGraph.remove(getNode(termRoot));
					}
					if(!rootTerms.contains(termRoot.getTerm())){
						addTextInformation(termRoot, queryOverlappingTerms, totalPagesInSelectedChapters);
						root = new Node(termRoot, new Color((float)0.0, (float)1.0, (float)0.0), new Color((float)0.0, (float)1.0, (float)0.0), minimumSize+(current.getNumberOfPagesInSelectedChapters(termRoot, selectedChapters).size())*magnificationFactor, redGreenOrBlue); 
					}
					//The term was already added to the graph
					else {
						continue;
					}
				}
				else if(redGreenOrBlue == 3){
					//The node was already considered a related term so it needs to be removed.
					if(!rootTerms.contains(termRoot.getTerm()) && getNode(termRoot) != null){
						nodeCount--;
						Node.decrementNumberOfNodesGenerated();
						g.removeVertex(getNode(termRoot));
						termsInGraph.remove(getNode(termRoot));
					}
					if(!rootTerms.contains(termRoot.getTerm())){
						addTextInformation(termRoot, queryOverlappingTerms, totalPagesInSelectedChapters);
						root = new Node(termRoot, new Color((float)0.0, (float)0.0, (float)1.0), new Color((float)0.0, (float)0.0, (float)1.0), minimumSize+current.getNumberOfPagesInSelectedChapters(termRoot, selectedChapters).size()*magnificationFactor, redGreenOrBlue); 
					}
					//The term was already added to the graph
					else {
						continue;
					}
				}
				else {
					System.out.println("Error in usage in the addNodes function in class GraphView. Ensure to pass 1 2 or 3 only");
					System.exit(0);
				}
				rootTerms.add(termRoot.getTerm());
				termsInGraph.add(root);
				ArrayList<Term> subTerms = termRoot.getSubTerms();
				//Add the subterms to the graph.
				for(int j = 0;j < subTerms.size();j++){
					ArrayList<Integer> pageRangeForSubTermInSelectedChapters = determinePagesOfTermInSelectedChapters(subTerms.get(j).getExtendedRange().getRanges(),totalPagesInSelectedChapters);
					//Get the correlation coefficient for the subterm.
					double correlationCoefficient = determineCorrelationCoeffecient(current.getNumberOfPagesInSelectedChapters(termRoot, selectedChapters), pageRangeForSubTermInSelectedChapters);
					System.out.println("Root pages: "+current.getNumberOfPagesInSelectedChapters(termRoot, selectedChapters));
					System.out.println("Sub Term pages: "+pageRangeForSubTermInSelectedChapters);
					System.out.println("Correlation: "+correlationCoefficient);
					if(pageRangeForSubTermInSelectedChapters.size() != 0){
						if(redGreenOrBlue == 1){
							//Check if the node is in the root terms.
							if(rootTerms.contains(subTerms.get(j).getTerm())){
								//Draw the connection but don't update the color since it's a search term.
								Node to = getNode(subTerms.get(j));
								g.addEdge(new MyLink(1, 2), to, root);
							}
							//Check if the node is already in the graph as either a potentially related term or a directly related term
							else if(!rootTerms.contains(subTerms.get(j).getTerm()) && isAlreadyInGraph(subTerms.get(j))){
								//Draw the connection and update the color.
								Node to = getNode(subTerms.get(j));
								float[] components = to.getColor().getColorComponents(null);
								to.updateColor(MAX_COLOR_FOR_SUB_TERMS, components[1], components[2]);
								to.updateScaledColor((float)(MIN_COLOR_FOR_SUB_TERMS+(MAX_ADDITIONAL_COLOR_FOR_SUB_TERMS*correlationCoefficient)), components[1], components[2]);
								g.addEdge(new MyLink(1, 2), to, root);
							}
							//It's a new term, add it to the graph. (exclude from termsingraph temporarily as I need to figure out how to update the page ranges for the node while keeping the original one intact.
							else {
								Term isInIndex = current.queryForTerm(subTerms.get(j).getTerm());
								//The term is not defined in the index anywhere, so create a new node for it.
								if(isInIndex == null){
									if(selectedChapters.size() != 0){
										ArrayList<Integer> PagesForSubTerm = subTerms.get(j).getExtendedRange().getRanges();
										boolean nodePageRangeFallsInsideSpecifiedChapters = false;
										Collections.sort(totalPagesInSelectedChapters);
										for(Integer k : totalPagesInSelectedChapters){
											if(PagesForSubTerm.contains(k)){
												nodePageRangeFallsInsideSpecifiedChapters = true;
												break;
											}
										}
										if(nodePageRangeFallsInsideSpecifiedChapters){
											nodeCount++;
											Node subTerm = new Node(subTerms.get(j), new Color(MAX_COLOR_FOR_SUB_TERMS,0.0f,0.0f), new Color((float)(MIN_COLOR_FOR_SUB_TERMS+(MAX_ADDITIONAL_COLOR_FOR_SUB_TERMS*correlationCoefficient)),0.0f,0.0f), minimumSize+(pageRangeForSubTermInSelectedChapters.size())*magnificationFactor, 0);
											subtermsInGraph.add(subTerm);
											termsInGraph.add(subTerm);
											g.addEdge(new MyLink(1, 2), subTerm, root);
										}
										else {
											//Do nothing because the node doesn't need to be drawn.
										}
									}
									else {
										nodeCount++;
										Node subTerm = new Node(subTerms.get(j), new Color(MAX_COLOR_FOR_SUB_TERMS,0.0f,0.0f), new Color((float)(MIN_COLOR_FOR_SUB_TERMS+(MAX_ADDITIONAL_COLOR_FOR_SUB_TERMS*correlationCoefficient)),0.0f,0.0f), minimumSize+(pageRangeForSubTermInSelectedChapters.size())*magnificationFactor, 0);
										subtermsInGraph.add(subTerm);
										termsInGraph.add(subTerm);
										g.addEdge(new MyLink(1, 2), subTerm, root);
									}
								}
								//TODO:It is defined in the index, it's page range needs to be combined with the existing subterms and it's color updated.
								//TODO:Just noticed a bug here, if the subterm node(after getting the root term from the index) is already created in the graph this will create a new node, rather than updating it. ENSURE TO DOUBLE CHECK AS IT HAS NOT BEEN FIXED AS OF 7/6.
								//For now just update the node color and add the line.
								else {
									//Draw the connection and update the color.
									nodeCount++;
									Node subTerm = new Node(current.queryForTerm(subTerms.get(j).getTerm()), new Color(MAX_COLOR_FOR_SUB_TERMS,0.0f,0.0f), new Color((float)(MIN_COLOR_FOR_SUB_TERMS+(MAX_ADDITIONAL_COLOR_FOR_SUB_TERMS*correlationCoefficient)),0.0f,0.0f), minimumSize+(pageRangeForSubTermInSelectedChapters.size())*magnificationFactor, 0);
									subtermsInGraph.add(subTerm);
									termsInGraph.add(subTerm);
									g.addEdge(new MyLink(1, 2), subTerm, root);
									System.out.println("ERROR IN LOGIC WITH SUBTERMS");
								}
							}
						}
						if(redGreenOrBlue == 2){
							//Check if the node is in the root terms.
							if(rootTerms.contains(subTerms.get(j).getTerm())){
								//Draw the connection but don't update the color since it's a search term.
								Node to = getNode(subTerms.get(j));
								g.addEdge(new MyLink(1, 2), to, root);
							}
							//Check if the node is already in the graph as either a potentially related term or a directly related term
							else if(!rootTerms.contains(subTerms.get(j).getTerm()) && isAlreadyInGraph(subTerms.get(j))){
								//Draw the connection and update the color.
								Node to = getNode(subTerms.get(j));
								float[] components = to.getColor().getColorComponents(null);
								to.updateColor(components[0], MAX_COLOR_FOR_SUB_TERMS, components[2]);
								to.updateScaledColor(components[0], (float)(MIN_COLOR_FOR_SUB_TERMS+(MAX_ADDITIONAL_COLOR_FOR_SUB_TERMS*correlationCoefficient)), components[2]);
								g.addEdge(new MyLink(1, 2), to, root);
							}
							//It's a new term, add it to the graph. (exclude from termsingraph temporarily as I need to figure out how to update the page ranges for the node while keeping the original one intact.
							else {
								Term isInIndex = current.queryForTerm(subTerms.get(j).getTerm());
								//The term is not defined in the index anywhere, so create a new node for it.
								if(isInIndex == null){
									if(selectedChapters.size() != 0){
										ArrayList<Integer> PagesForSubTerm = subTerms.get(j).getExtendedRange().getRanges();
										boolean nodePageRangeFallsInsideSpecifiedChapters = false;
										Collections.sort(totalPagesInSelectedChapters);
										for(Integer k : totalPagesInSelectedChapters){
											if(PagesForSubTerm.contains(k)){
												nodePageRangeFallsInsideSpecifiedChapters = true;
												break;
											}
										}
										if(nodePageRangeFallsInsideSpecifiedChapters){
											nodeCount++;
											Node subTerm = new Node(subTerms.get(j), new Color(0.0f,MAX_COLOR_FOR_SUB_TERMS,0.0f), new Color(0.0f,(float)(MIN_COLOR_FOR_SUB_TERMS+(MAX_ADDITIONAL_COLOR_FOR_SUB_TERMS*correlationCoefficient)),0.0f), minimumSize+(pageRangeForSubTermInSelectedChapters.size())*magnificationFactor, 0);
											subtermsInGraph.add(subTerm);
											termsInGraph.add(subTerm);
											g.addEdge(new MyLink(1, 2), subTerm, root);
										}
										else {
											//Do nothing because the node doesn't need to be drawn.
										}
									}
									else {
										nodeCount++;
										Node subTerm = new Node(subTerms.get(j), new Color(0.0f,MAX_COLOR_FOR_SUB_TERMS,0.0f), new Color(0.0f,(float)(MIN_COLOR_FOR_SUB_TERMS+(MAX_ADDITIONAL_COLOR_FOR_SUB_TERMS*correlationCoefficient)),0.0f), minimumSize+(pageRangeForSubTermInSelectedChapters.size())*magnificationFactor, 0);
										subtermsInGraph.add(subTerm);
										termsInGraph.add(subTerm);
										g.addEdge(new MyLink(1, 2), subTerm, root);
									}
								}
								//TODO:It is defined in the index, it's page range needs to be combined with the existing subterms and it's color updated.
								//For now just update the node color and add the line.
								else {
									//Draw the connection and update the color.
									nodeCount++;
									Node subTerm = new Node(current.queryForTerm(subTerms.get(j).getTerm()), new Color(0.0f,MAX_COLOR_FOR_SUB_TERMS,0.0f), new Color(0.0f,(float)(MIN_COLOR_FOR_SUB_TERMS+(MAX_ADDITIONAL_COLOR_FOR_SUB_TERMS*correlationCoefficient)),0.0f), minimumSize+(pageRangeForSubTermInSelectedChapters.size())*magnificationFactor, 0);
									subtermsInGraph.add(subTerm);
									termsInGraph.add(subTerm);
									g.addEdge(new MyLink(1, 2), subTerm, root);
									System.out.println("ERROR IN LOGIC WITH SUBTERMS");
								}
							}
						}
						if(redGreenOrBlue == 3){
							//Check if the node is in the root terms.
							if(rootTerms.contains(subTerms.get(j).getTerm())){
								//Draw the connection but don't update the color since it's a search term.
								Node to = getNode(subTerms.get(j));
								g.addEdge(new MyLink(1, 2), to, root);
							}
							//Check if the node is already in the graph as either a potentially related term or a directly related term
							else if(!rootTerms.contains(subTerms.get(j).getTerm()) && isAlreadyInGraph(subTerms.get(j))){
								//Draw the connection and update the color.
								Node to = getNode(subTerms.get(j));
								float[] components = to.getColor().getColorComponents(null);
								to.updateColor(components[0], components[1], MAX_COLOR_FOR_SUB_TERMS);
								to.updateScaledColor(components[0], components[1], (float)(MIN_COLOR_FOR_SUB_TERMS+(MAX_ADDITIONAL_COLOR_FOR_SUB_TERMS*correlationCoefficient)));
								g.addEdge(new MyLink(1, 2), to, root);
							}
							//It's a new term, add it to the graph. (exclude from termsingraph temporarily as I need to figure out how to update the page ranges for the node while keeping the original one intact.
							else {
								Term isInIndex = current.queryForTerm(subTerms.get(j).getTerm());
								//The term is not defined in the index anywhere, so create a new node for it.
								if(isInIndex == null){
									if(selectedChapters.size() != 0){
										ArrayList<Integer> PagesForSubTerm = subTerms.get(j).getExtendedRange().getRanges();
										boolean nodePageRangeFallsInsideSpecifiedChapters = false;
										Collections.sort(totalPagesInSelectedChapters);
										for(Integer k : totalPagesInSelectedChapters){
											if(PagesForSubTerm.contains(k)){
												nodePageRangeFallsInsideSpecifiedChapters = true;
												break;
											}
										}
										if(nodePageRangeFallsInsideSpecifiedChapters){
											nodeCount++;
											Node subTerm = new Node(subTerms.get(j), new Color(0.0f,0.0f,MAX_COLOR_FOR_SUB_TERMS), new Color(0.0f,0.0f,(float)(MIN_COLOR_FOR_SUB_TERMS+(MAX_ADDITIONAL_COLOR_FOR_SUB_TERMS*correlationCoefficient))), minimumSize+(pageRangeForSubTermInSelectedChapters.size())*magnificationFactor, 0);
											subtermsInGraph.add(subTerm);
											termsInGraph.add(subTerm);
											g.addEdge(new MyLink(1, 2), subTerm, root);
										}
										else {
											//Do nothing because the node doesn't need to be drawn.
										}
									}
									else {
										nodeCount++;
										Node subTerm = new Node(subTerms.get(j), new Color(0.0f,0.0f,MAX_COLOR_FOR_SUB_TERMS), new Color(0.0f,0.0f,(float)(MIN_COLOR_FOR_SUB_TERMS+(MAX_ADDITIONAL_COLOR_FOR_SUB_TERMS*correlationCoefficient))), minimumSize+(pageRangeForSubTermInSelectedChapters.size())*magnificationFactor, 0);
										subtermsInGraph.add(subTerm);
										termsInGraph.add(subTerm);
										g.addEdge(new MyLink(1, 2), subTerm, root);
									}
								}
								//TODO:It is defined in the index, it's page range needs to be combined with the existing subterms and it's color updated.
								//For now just update the node color and add the line.
								else {
									//Draw the connection and update the color.
									nodeCount++;
									Node subTerm = new Node(current.queryForTerm(subTerms.get(j).getTerm()), new Color(0.0f,0.0f,MAX_COLOR_FOR_SUB_TERMS), new Color(0.0f,0.0f,(float)(MIN_COLOR_FOR_SUB_TERMS+(MAX_ADDITIONAL_COLOR_FOR_SUB_TERMS*correlationCoefficient))), minimumSize+(pageRangeForSubTermInSelectedChapters.size())*magnificationFactor, 0);
									subtermsInGraph.add(subTerm);
									termsInGraph.add(subTerm);
									g.addEdge(new MyLink(1, 2), subTerm, root);
									System.out.println("ERROR IN LOGIC WITH SUBTERMS");
								}
							}
						}
					}
				}
				//The term has overlapping terms.
				if(queryOverlappingTerms.size() != 0){
					for(int j = 0;j < queryOverlappingTerms.size();j++){
						nodeCount++;
						Term termChild = queryOverlappingTerms.get(j);
						//create the node with the appropriate color.
						boolean inGraphAlready = isAlreadyInGraph(termChild);
						if(redGreenOrBlue == 1){
							if(inGraphAlready){
								//Don't do anything if it's a subterm of the current node, as it has already been drawn with connection.
								if(!termRoot.hasSubTerm(termChild.getTerm())){
									//Ignore the relationship(as far as coloring is concerned) if it is with a search term, as there is no recoloring needed to be done. Otherwise update the color.
									if(!rootTerms.contains(termChild.getTerm())){
										double correlationCoeffecient = determineCorrelationCoeffecient(current.getNumberOfPagesInSelectedChapters(termRoot, selectedChapters), current.getNumberOfPagesInSelectedChapters(termChild, selectedChapters));
										nodeCount--;
										Node child = getNode(termChild);
										float blueComponent = child.getColor().getRGBColorComponents(null)[2];
										float greenComponent = child.getColor().getRGBColorComponents(null)[1];
										child.updateColor((float)(MAX_ADDITIONAL_COLOR_FOR_POTENTIALLY_RELATED_TERMS), greenComponent, blueComponent);
										child.updateScaledColor((float)(MAX_ADDITIONAL_COLOR_FOR_POTENTIALLY_RELATED_TERMS*correlationCoeffecient), greenComponent, blueComponent);
										g.addEdge(new MyLink(correlationCoeffecient, 1), root, child, EdgeType.UNDIRECTED);
									}
									else if (!root.getTerm().getSubTerms().contains(termChild)){
										double correlationCoeffecient = determineCorrelationCoeffecient(current.getNumberOfPagesInSelectedChapters(termRoot, selectedChapters), current.getNumberOfPagesInSelectedChapters(termChild, selectedChapters));
										nodeCount--;
										Node child = getNode(termChild);
										//TODO:MAKE ALL THESE ONLY DRAW THIS LINE WHEN THE OVERLAPPING TERM ISN'T A SUBTERM.
										g.addEdge(new MyLink(correlationCoeffecient, 3), root, child, EdgeType.UNDIRECTED);
									}
								}
							}
							else {
								//Don't do anything if it's a subterm of the current node, as it has already been drawn with connection.
								if(!termRoot.hasSubTerm(termChild.getTerm())){
									//Ignore the relationship if it is with a search term, as there is no recoloring needed to be done. Otherwise update the color.
									if(!rootTerms.contains(termChild.getTerm())){
										double correlationCoeffecient = determineCorrelationCoeffecient(current.getNumberOfPagesInSelectedChapters(termRoot, selectedChapters), current.getNumberOfPagesInSelectedChapters(termChild, selectedChapters));
										Node child = new Node(termChild, new Color(MAX_ADDITIONAL_COLOR_FOR_POTENTIALLY_RELATED_TERMS, 0, 0), new Color((float)(MAX_ADDITIONAL_COLOR_FOR_POTENTIALLY_RELATED_TERMS*correlationCoeffecient), 0, 0), minimumSize+current.getNumberOfPagesInSelectedChapters(termChild, selectedChapters).size()*magnificationFactor, 0);
										termsInGraph.add(child);
										g.addEdge(new MyLink(correlationCoeffecient, 1), root, child, EdgeType.UNDIRECTED);
									}
									else if (!root.getTerm().getSubTerms().contains(termChild)){
										double correlationCoeffecient = determineCorrelationCoeffecient(current.getNumberOfPagesInSelectedChapters(termRoot, selectedChapters), current.getNumberOfPagesInSelectedChapters(termChild, selectedChapters));
										nodeCount--;
										Node child = getNode(termChild);
										g.addEdge(new MyLink(correlationCoeffecient, 3), root, child, EdgeType.UNDIRECTED);
									}
								}
							}
						}
						else if(redGreenOrBlue == 2){
							if(inGraphAlready){
								//Don't do anything if it's a subterm of the current node, as it has already been drawn with connection.
								if(!termRoot.hasSubTerm(termChild.getTerm())){
									//Ignore the relationship if it is with a search term, as there is no recoloring needed to be done. Otherwise update the color.
									if(!rootTerms.contains(termChild.getTerm())){
										double correlationCoeffecient = determineCorrelationCoeffecient(current.getNumberOfPagesInSelectedChapters(termRoot, selectedChapters), current.getNumberOfPagesInSelectedChapters(termChild, selectedChapters));
										nodeCount--;
										Node child = getNode(termChild);
										float redComponent = child.getColor().getRGBColorComponents(null)[0];
										float blueComponent = child.getColor().getRGBColorComponents(null)[2];
										child.updateColor(redComponent, (float)(MAX_ADDITIONAL_COLOR_FOR_POTENTIALLY_RELATED_TERMS), blueComponent);
										child.updateScaledColor(redComponent, (float)(MAX_ADDITIONAL_COLOR_FOR_POTENTIALLY_RELATED_TERMS*correlationCoeffecient), blueComponent);
										g.addEdge(new MyLink(correlationCoeffecient, 1), root, child, EdgeType.UNDIRECTED);
									}
									else if (!root.getTerm().getSubTerms().contains(termChild)){
										double correlationCoeffecient = determineCorrelationCoeffecient(current.getNumberOfPagesInSelectedChapters(termRoot, selectedChapters), current.getNumberOfPagesInSelectedChapters(termChild, selectedChapters));
										nodeCount--;
										Node child = getNode(termChild);
										g.addEdge(new MyLink(correlationCoeffecient, 3), root, child, EdgeType.UNDIRECTED);
									}
								}
							}
							else {
								//Don't do anything if it's a subterm of the current node, as it has already been drawn with connection.
								if(!termRoot.hasSubTerm(termChild.getTerm())){
									//Ignore the relationship if it is with a search term, as there is no recoloring needed to be done. Otherwise update the color.
									if(!rootTerms.contains(termChild.getTerm())){
										double correlationCoeffecient = determineCorrelationCoeffecient(current.getNumberOfPagesInSelectedChapters(termRoot, selectedChapters), current.getNumberOfPagesInSelectedChapters(termChild, selectedChapters));
										Node child = new Node(termChild, new Color(0, MAX_ADDITIONAL_COLOR_FOR_POTENTIALLY_RELATED_TERMS, 0), new Color(0, (float)(MAX_ADDITIONAL_COLOR_FOR_POTENTIALLY_RELATED_TERMS*correlationCoeffecient), 0), minimumSize+current.getNumberOfPagesInSelectedChapters(termChild, selectedChapters).size()*magnificationFactor, 0);
										termsInGraph.add(child);
										g.addEdge(new MyLink(correlationCoeffecient, 1), root, child, EdgeType.UNDIRECTED);
									}
									else if (!root.getTerm().getSubTerms().contains(termChild)){
										double correlationCoeffecient = determineCorrelationCoeffecient(current.getNumberOfPagesInSelectedChapters(termRoot, selectedChapters), current.getNumberOfPagesInSelectedChapters(termChild, selectedChapters));
										nodeCount--;
										Node child = getNode(termChild);
										g.addEdge(new MyLink(correlationCoeffecient, 3), root, child, EdgeType.UNDIRECTED);
									}
								}
							}
						}
						else if(redGreenOrBlue == 3){
							//Ignore the relationship if it is with a search term, as there is no recoloring needed to be done. Otherwise update the color.
							if(inGraphAlready){
								//Don't do anything if it's a subterm of the current node, as it has already been drawn with connection.
								if(!termRoot.hasSubTerm(termChild.getTerm())){
									if(!rootTerms.contains(termChild.getTerm())){
										double correlationCoeffecient = determineCorrelationCoeffecient(current.getNumberOfPagesInSelectedChapters(termRoot, selectedChapters), current.getNumberOfPagesInSelectedChapters(termChild, selectedChapters));
										nodeCount--;
										Node child = getNode(termChild);
										float redComponent = child.getColor().getRGBColorComponents(null)[0];
										float greenComponent = child.getColor().getRGBColorComponents(null)[1];
										child.updateColor(redComponent, greenComponent, (float)(MAX_ADDITIONAL_COLOR_FOR_POTENTIALLY_RELATED_TERMS));
										child.updateScaledColor(redComponent, greenComponent, (float)(MAX_ADDITIONAL_COLOR_FOR_POTENTIALLY_RELATED_TERMS*correlationCoeffecient));
										g.addEdge(new MyLink(correlationCoeffecient, 1), root, child, EdgeType.UNDIRECTED);
									}
									else if (!root.getTerm().getSubTerms().contains(termChild)){
										double correlationCoeffecient = determineCorrelationCoeffecient(current.getNumberOfPagesInSelectedChapters(termRoot, selectedChapters), current.getNumberOfPagesInSelectedChapters(termChild, selectedChapters));
										nodeCount--;
										Node child = getNode(termChild);
										g.addEdge(new MyLink(correlationCoeffecient, 3), root, child, EdgeType.UNDIRECTED);
									}
								}
							}
							else {
								//Don't do anything if it's a subterm of the current node, as it has already been drawn with connection.
								if(!termRoot.hasSubTerm(termChild.getTerm())){
									//Ignore the relationship if it is with a search term, as there is no recoloring needed to be done. Otherwise update the color.
									if(!rootTerms.contains(termChild.getTerm())){
										double correlationCoeffecient = determineCorrelationCoeffecient(current.getNumberOfPagesInSelectedChapters(termRoot, selectedChapters), current.getNumberOfPagesInSelectedChapters(termChild, selectedChapters));
										Node child = new Node(termChild, new Color(0, 0, MAX_ADDITIONAL_COLOR_FOR_POTENTIALLY_RELATED_TERMS), new Color(0, 0, (float)(MAX_ADDITIONAL_COLOR_FOR_POTENTIALLY_RELATED_TERMS*correlationCoeffecient)), minimumSize+current.getNumberOfPagesInSelectedChapters(termChild, selectedChapters).size()*magnificationFactor, 0);
										termsInGraph.add(child);
										g.addEdge(new MyLink(correlationCoeffecient, 1), root, child, EdgeType.UNDIRECTED);
									}
									else if (!root.getTerm().getSubTerms().contains(termChild)){
										double correlationCoeffecient = determineCorrelationCoeffecient(current.getNumberOfPagesInSelectedChapters(termRoot, selectedChapters), current.getNumberOfPagesInSelectedChapters(termChild, selectedChapters));
										nodeCount--;
										Node child = getNode(termChild);
										g.addEdge(new MyLink(correlationCoeffecient, 3), root, child, EdgeType.UNDIRECTED);
									}
								}
							}
						}
						else {
							System.out.println("Error in usage in the addNodes function in class GraphView. Ensure to pass 1 2 or 3 only");
							System.exit(0);
						}
					}
				}
				else {
					g.addVertex(root);
				}
			}
		}
		else {
			//TODO: Do nothing?
		}
		//If the page range was specified, filter out nodes that are not in the range.
		if(filterPages != null){
			for(int i = 0;i < termsInGraph.size();i++){
				Node currentCheck = termsInGraph.get(i);
				boolean isNotInTheList = true;
				for(int j = 0;j < filterPages.size();j++){
					if(currentCheck.getTerm().getExtendedRange().getRanges().contains(filterPages.get(j))){
						isNotInTheList = false;
						//System.out.println("Match for term: "+currentCheck.getTerm().getTerm()+" on page: "+filterPages.get(j));
						break;
					}
				}
				//Remove the node
				if(isNotInTheList){
					g.removeVertex(currentCheck);
					termsInGraph.remove(currentCheck);
					nodeCount--;
					Node.decrementNumberOfNodesGenerated();
				}
			}
		}
	}