/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package graphalgorithms;

/**
 *
 * @author piyush
 */
import java.util.*;
        
public class Graph {
    private List<Vertex> vertices= new ArrayList<>();
    private List<Edge> edges= new ArrayList<>();
    private Map adjMat= new HashMap();
    private boolean madeAdjacencyMatrix= false;
    
    Graph(ArrayList <Vertex> vertices, ArrayList <Edge> edges){
        this.vertices=vertices;
        this.edges=edges;
    }
    
    public void addVertex(Vertex vertex){
        this.vertices.add(vertex);
    }
    
    public void addEdge(Edge edge){
        this.edges.add(edge);
        if (this.madeAdjacencyMatrix)
    }
    
    public void makeAdjacencyMatrix(){
        this.madeAdjacencyMatrix=true;
        
    
    }
    
    public Map getAdjacencyMatrix(){
        if (madeAdjacencyMatrix==false){
            this.makeAdjacencyMatrix();
            
        }
        
        return this.adjMat;
    }
    
}

@@ -473,16 +473,46 @@
  false;%0A
+    private boolean isSparse;%0A
     %0A   
@@ -832,16 +832,240 @@
 yMatrix)
+%7B%0A            this.updateAdjacencyMatrix(edge);%0A        %7D%0A    %7D%0A    %0A    public void updateAdjacencyMatrix(Edge edge)%7B%0A        //do nothing%0A    %7D%0A    %0A    public void updateAdjacecyMatrix(Vertex vertex)%7B%0A        //do nothing
 %0A    %7D%0A 
@@ -1150,24 +1150,88 @@
 ue;%0A        
+for (int i=0; i%3C0; i++)%7B%0A        //do nothing%0A        %0A        %7D
 %0A    %0A    %7D%0A
@@ -1424,10 +1424,130 @@
  %7D%0A    %0A
+    public boolean isSparse()%7B%0A        return 2*this.edges.size()%3Cthis.vertices.size()*this.vertices.size();%0A    %7D%0A    %0A
 %7D%0A

Update Graph.java