For this Question: Given an undirected graph G (V, E) and two vertices v1 and v2 (as integers), check if there exists any path between them or not. Print true or false.
V is the number of vertices present in graph G and vertices are numbered from 0 to V-1.
E is the number of edges present in graph G.Line 1: Two Integers V and E (separated by space)
Next E lines: Two integers a and b, denoting that there exists an edge between vertex a and vertex b (separated by space)
Line (E+2): Two integers v1 and v2 (separated by space)

Constraints :
2 <= V <= 1000
1 <= E <= 1000
0 <= v1, v2 <= V-1For each testcase in new line, you need to print true or false.Sample Input 1 :
4 4
0 1
0 3
1 2
2 3
1 3

Sample Output 1 :
true

Explanation:
There are multiple path exists between 1 and 3. One of them is as such: 1 -> 2 -> 3., I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
	public static void main (String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str[] = br.readLine().trim().split(" ");

		int v = Integer.parseInt(str[0]);
		int e = Integer.parseInt(str[1]);

		ArrayList<ArrayList<Integer>> list = new ArrayList<>();

		for(int i=0;i<v;i++)
		{
			list.add(i, new ArrayList<>());
		}
		for(int i=0;i<e;i++)
		{
			String st[] = br.readLine().trim().split(" ");
			int e1 = Integer.parseInt(st[0]);
			int e2 = Integer.parseInt(st[1]);

			list.get(e1).add(e2);
			list.get(e2).add(e1);
		}
		String strg[] = br.readLine().trim().split(" ");

		int v1 = Integer.parseInt(strg[0]);
		int v2 = Integer.parseInt(strg[1]);

		System.out.print(bfs(list, v1, v2, v));
	}
	public static boolean bfs(ArrayList<ArrayList<Integer>> list, int v1,int v2, int v)
	{
		boolean visit[] = new boolean[v];

		LinkedList<Integer> queue = new LinkedList<>();

		visit[v1] = true;
		queue.add(v1);

		while(!queue.isEmpty())
		{
			int ans = queue.poll();

			Iterator<Integer> i = list.get(ans).listIterator();

			while(i.hasNext())
			{
				int n = i.next();
				if(n==v2)
				{
					return true;
				}
				if(!visit[n])
				{
					visit[n] = true;
					queue.add(n);
				}
			}
		}
		return false;
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?