Double-Degree Array solved by 1576

Feb. 21, 2014, 4:22 p.m. by Rosalind Team

Topics: Graphs

Problem

Figure 1. The graph from the dataset

Given: A simple graph with $n \le 10^3$ vertices in the edge list format.

Return: An array $D[1..n]$ where $D[i]$ is the sum of the degrees of $i$'s neighbors.

See Figure 1 for visual example from the sample dataset.

Sample Dataset

5 4
1 2
2 3
4 3
2 4


Sample Output

3 5 5 5 0