# Sum of Dependencies in a Graph

Posted: 5 Mar, 2021

Difficulty: Easy

#### You’re given a directed graph with 'V' nodes and 'E' edges. If there is an edge from node A to node B, then A depends on B. Your task is to find the sum of dependencies for every node.

##### Input Format:

```
The first line of the input contains an integer 'T' denoting the number of test cases.
Each test case’s first line contains two space-separated integers 'V' and 'E', denoting the graph’s nodes and edges, respectively.
The next ‘E’ line of each test case contains two space-separated integers X and Y, representing a directed edge from X to Y.
```

##### Output Format:

```
For every test case, print the sum of dependencies for every node.
```

##### Note :

```
You do not need to print anything; it has already been taken care of. Just implement the given function.
```

##### Constraints:

```
1 <= T <= 5
1 <= V<= 10^4
0 <= E <= V * (V-1)
0 <= X, Y <= V - 1
Time Limit: 1 sec
```

SIMILAR PROBLEMS

# Last Exam

Posted: 5 Dec, 2021

Difficulty: Moderate

# Minimum Number Of Moves To Get All Keys

Posted: 10 Dec, 2021

Difficulty: Moderate

# Count Islands

Posted: 26 Dec, 2021

Difficulty: Moderate

# Find Center of Star Graph

Posted: 26 Jan, 2022

Difficulty: Easy

# Critical Connections in a Network

Posted: 27 Jan, 2022

Difficulty: Hard