An integer n representing the number of nodes in the tree.
An integer k representing the exact distance (in edges) between pairs of nodes to be counted.
A list of tuples edges, where each tuple (a, b) represents an edge between nodes a and b.
The function must return an integer that represents the number of unique pairs of nodes that are exactly k edges apart.
Input/Output Requirements
Input:
n (1 ≤ n ≤ 10^5): The total number of nodes in the tree.
k (0 ≤ k < n): The desired distance between pairs.
edges: A list of tuples, where each tuple consists of two integers (a, b) such that 1 ≤ a, b ≤ n and represents an undirected edge between nodes a and b.
Output:
An integer representing the number of unique pairs of nodes that are exactly k edges apart.
This example shows that there are 3 pairs of nodes that are 2 edges apart.
Implementation
You must implement the solution in a Python file located at /app/solution.py. The file should contain only the implementation of the function described above. Ensure that you handle any edge cases, such as when n is 1 or when no pairs exist for the provided k.