package com.graph; import java.util.LinkedList; import java.util.Queue; import java.util.Stack; public class BFSGraph { int size; adjList[] array; public BFSGraph(int size) { this.size=size; array= new adjList[ this.size]; for(int i=0;i q= new LinkedList(); q.add(StartVertex); while( !q.isEmpty()){ int n= q.poll(); System.out.println("Visted node: "+ n); visited[n]=true; Node head= array[n].head; while(head!=null){ if(visited[head.value]==false){ q.add(head.value); visited[head.value]=true; }else{ head=head.next; } } } } }