import
java.util.*;
class
GFG {
static
void
findInOutDegree(List<List<Integer> > adjList,
int
n)
{
int
in[] =
new
int
[n];
int
out[] =
new
int
[n];
for
(
int
i =
0
; i < adjList.size(); i++) {
List<Integer> list = adjList.get(i);
out[i] = list.size();
for
(
int
j =
0
; j < list.size(); j++)
in[list.get(j)]++;
}
System.out.println(
"Vertex\tIn\tOut"
);
for
(
int
k =
0
; k < n; k++) {
System.out.println(k +
"\t"
+ in[k] +
"\t"
+ out[k]);
}
}
public
static
void
main(String args[])
{
List<List<Integer> > adjList =
new
ArrayList<>();
List<Integer> tmp =
new
ArrayList<Integer>(Arrays.asList(
1
,
2
));
adjList.add(tmp);
tmp =
new
ArrayList<Integer>(Arrays.asList(
3
));
adjList.add(tmp);
tmp =
new
ArrayList<Integer>(Arrays.asList(
0
,
5
,
6
));
adjList.add(tmp);
tmp =
new
ArrayList<Integer>(Arrays.asList(
1
,
4
));
adjList.add(tmp);
tmp =
new
ArrayList<Integer>(Arrays.asList(
2
,
3
));
adjList.add(tmp);
tmp =
new
ArrayList<Integer>(Arrays.asList(
4
,
6
));
adjList.add(tmp);
tmp =
new
ArrayList<Integer>(Arrays.asList(
5
));
adjList.add(tmp);
int
n = adjList.size();
findInOutDegree(adjList, n);
}
}