Consider the assignment problem where we have two groups $u = {1, \ldots, n}$ and $v = {1, \ldots, n}$. The task is to assign each of the elements of $u$ to one and only element in $v$, such that the sum of costs is minimized. The cost $c_{ij}$ is the cost of assigning $u_i$ to $v_j$. This can also be represented as bipartite graph.
I am aware that this problem can be solved using the Hungarian algorithm in $O(n^3)$ time. There is also a network flow formulation to solve the problem.
Question:
I have a slightly different variant. I have additional pair-wise assignment constraints. For example, if $u_1$ is assigned to $v_2$ then $u_2$ cannot be assigned that $v_3$. In other words, there are pair of assignments which are restricted. I understand that this can lead to situations where there might not be a feasible solution. Is there an algorithm which gives the optimal solution and returns failure if one does not exist? Any pointers on how the Hungarian algorithm or the network flow algorithms can be modified for the needful. Alternatively, can we show it that a polynomial time solution does not exist?
Mathematical formulation of the assignment problem:
Minimize: $\sum_{i=1}^n \sum_{j=1}^n c_{ij}x_{ij}$
subject to : $\sum_{i=1}^n x_{ij}=1 \quad j = 1,\ldots, n\\ \sum_{j=1}^n x_{ij}=1 \quad i = 1, \ldots, n\\x_{ij} \in \{0, 1\} \quad i, j = 1,\ldots, n$