Implement the functionality to assign values to nodes in a graph based on edge constraints. Each edge connects two nodes and has an associated weight. The algorithm must determine if it is possible to assign values to the nodes such that the sum of the values at both ends of an edge equals the edge's weight. If feasible, the function should return those values; otherwise, it should return a failure indicator.
Input/Output Requirements
Input:
An integer n (1 ≤ n ≤ 1000) representing the number of nodes.
An integer m (0 ≤ m ≤ 10000) representing the number of edges.
A list edges containing m tuples, where each tuple consists of:
Two integers u and v (1 ≤ u, v ≤ n) representing the nodes that are connected by an edge.
An integer t (1 ≤ t ≤ 10^9) representing the weight of the edge between nodes u and v.
Output:
If the assignment is possible, return a tuple containing:
A string "YES".
A list of n integers where the i-th integer represents the value assigned to node i.
If the assignment is impossible, return:
A string "NO".
None.
Implementation Instructions
Write the solution to a file named /app/solution.py.
Ensure that the function follows the provided signature: def assign_node_values(n, m, edges):.