// Build a graph using an adjacency list.
// No vertex class
// Should have a storage property that holds vertex id along with all the edges.

// Methods:
// addVertex
// removeVertex
// addEdge
// removeEdge
// neighbors(vertex) -> return the array of neighbors for a vertex


class Graph{
  constructor(){
    this.vertices = {};
    this.totalVertices = 0;
    this.totalEdges = 0;
  }

  addVertex(val){
    this.vertices[val] = []; // storage
    this.totalVertices++;
  }

  removeVertex(val){
    delete this.vertices[val];
    this.totalVertices--;
  }

  addEdge(valOne, valTwo){
    this.vertices[valOne].push(valTwo);
    this.vertices[valTwo].push(valOne);

    this.totalEdges++;
   }

   removeEdge(valOne, valTwo){
    valOne.splice( valOne.indexOf(valTwo), 1 );
    valTwo.splice( valTwo.indexOf(valOne), 1 );

    this.totalEdges--;
  }

  neighbors(val){
    return this.vertices[val]
  }

}

var graph = new Graph;
var myVertices = ['A','B','C','D','E','F','G','H','I']; // 9
for( var i=0; i<myVertices.length; i++ ){
  graph.addVertex( myVertices[i] );
}
graph.addEdge('A', 'B');
graph.addEdge('A', 'C');
graph.addEdge('A', 'D');
graph.addEdge('C', 'D');
graph.addEdge('C', 'G');
graph.addEdge('D', 'G');
graph.addEdge('D', 'H');
graph.addEdge('B', 'E');
graph.addEdge('B', 'F');
graph.addEdge('E', 'I');
// console.log(graph)
console.log(graph.neighbors('A'))

@@ -397,24 +397,75 @@
 ertex(val)%7B%0A
+    if ( !this.vertices%5Bval%5D )%7B // no duplicates%0A  
     this.ver
@@ -492,24 +492,26 @@
 storage%0A    
+ 
+ 
 this.totalVe
@@ -520,16 +520,22 @@
 ices++;%0A
+    %7D%0A
   %7D%0A%0A  r
@@ -786,22 +786,37 @@
 o)%7B%0A    
+this.vertices%5B
 valOne
+%5D
 .splice(
@@ -816,22 +816,37 @@
 splice( 
+this.vertices%5B
 valOne
+%5D
 .indexOf
@@ -864,22 +864,37 @@
  );%0A    
+this.vertices%5B
 valTwo
+%5D
 .splice(
@@ -894,22 +894,37 @@
 splice( 
+this.vertices%5B
 valTwo
+%5D
 .indexOf
@@ -993,33 +993,117 @@
     
-return this.vertices%5Bval%5D
+if( this.vertices%5Bval%5D )%7B%0A      return this.vertices%5Bval%5D%0A    %7D else %7B%0A      return 'val doesnt exist';%0A    %7D
 %0A  %7D
@@ -1183,16 +1183,21 @@
 ,'H','I'
+, 'A'
 %5D; // 9%0A
@@ -1526,19 +1526,16 @@
 , 'I');%0A
-// 
 console.
@@ -1579,8 +1579,195 @@
 s('A'))%0A
+console.log(graph.neighbors('B'))%0Agraph.removeEdge('A', 'B')%0Aconsole.log(graph.neighbors('A'))%0Aconsole.log(graph.neighbors('B'))%0Agraph.removeVertex('A')%0Aconsole.log(graph.neighbors('A'))%0A

test methods