What is the error in my code?
import java.util.Scanner;
import java.util.ArrayList;
class Main{
static class Edge{
int p ;
int v ;
Edge(int p, int v){
this.p = p; //parent
this.v = v;
}
}
public static void addEdge(ArrayList<ArrayList<Edge>>graph, int u, int v){
graph.get(u).add(new Edge(u,v));
// graph.get(v).add(new Edge(u));
}
public static int countBVtx(ArrayList<ArrayList<Edge>> graph){
int count = 0;
for(int v = 1; v < graph.size(); v++){
int pSize = graph.get(v).size();
for(int i = 0; i<pSize; i++){
Edge ce =graph.get(v).get(i);
int cSize = graph.get(ce.v).size();
if(cSize>pSize)
{
count++;
}
}
}
return count;
}
public static void display(ArrayList<ArrayList<Edge>> graph){
for(int i =1; i<graph.size(); i++){
System.out.print(i+"->");
for(int j =0; j<graph.get(i).size(); j++){
Edge curr = graph.get(i).get(j);
System.out.print("(" +curr.p+","+ curr.v + ")-");
}
System.out.println();
}
}
public static Scanner scn = new Scanner(System.in);
public static void main(String[] args){
ArrayList<ArrayList<Edge>> graph = new ArrayList<>();
int n = scn.nextInt(); //no of vertex
int m = scn.nextInt(); //no of edge
for(int i = 0; i<=n; i++){
graph.add(new ArrayList<Edge>());
}
for(int i = 0; i< m; i++){
int a = scn.nextInt();
int b = scn.nextInt();
addEdge(graph,a,b);
}
// display(graph);
System.out.print(countBVtx(graph));
}
}