Create graph || Data Structure And Algorithm || Java Script
class Node{
constructor(src , nbr , wt){
this.src = src;
this.nbr = nbr;
this.wt = wt
}
}
function adgencyArr(vertex){
let graph = {};
for(let i =0 ; i<vertex ; i++){
graph[i] = [];
}
graph[0].push(new Node(0 ,3 , 40))
graph[0].push(new Node(0 ,1 , 10))
graph[1].push(new Node(1 ,0 , 10))
graph[1].push(new Node(1 ,2 , 10))
graph[2].push(new Node(2 ,3 , 10))
graph[2].push(new Node(2 ,1 , 10))
graph[3].push(new Node(3 ,0 , 40))
graph[3].push(new Node(3 ,2 , 10))
graph[3].push(new Node(3 ,4 , 2))
graph[4].push(new Node(4 ,3 , 2))
graph[4].push(new Node(4 ,5 , 3))
graph[4].push(new Node(4 ,6 , 3))
graph[5].push(new Node(5 ,4 , 3))
graph[5].push(new Node(5 ,6 , 3))
graph[6].push(new Node(6 ,5 , 3))
graph[6].push(new Node(6 ,4 , 8))
console.log(graph);
}