Skip to content
Snippets Groups Projects
Commit ba8eae3b authored by beginner1010's avatar beginner1010
Browse files

Graph is updated. Null pointer exception is fixed

parent b28b52ff
No related branches found
No related tags found
No related merge requests found
...@@ -45,7 +45,7 @@ public class Graph { ...@@ -45,7 +45,7 @@ public class Graph {
} }
public int addVertex (String vertex) { public int addVertex (String vertex) {
if (vertexIndex.containsKey(vertex) == false) { if (!vertexIndex.containsKey(vertex)) {
this.vertices.add(numberOfVertices) ; this.vertices.add(numberOfVertices) ;
this.vertexIndex.put(vertex, numberOfVertices++) ; this.vertexIndex.put(vertex, numberOfVertices++) ;
this.AdjList.add(new HashSet<>()) ; this.AdjList.add(new HashSet<>()) ;
...@@ -54,7 +54,10 @@ public class Graph { ...@@ -54,7 +54,10 @@ public class Graph {
} }
public Graph(String args) { public Graph(String args) {
AdjList = new ArrayList<>(); this.AdjList = new ArrayList<>();
this.vertexIndex = new HashMap<>() ;
this.numberOfVertices = 0 ;
this.vertices = new ArrayList<>() ;
trianglecount = new HashMap<>(); trianglecount = new HashMap<>();
try { try {
BufferedReader br = new BufferedReader(new FileReader(args)); BufferedReader br = new BufferedReader(new FileReader(args));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment