Suppose I had a dictionary that contains events and the corresponding periods they are occurring. For example:
$$ \begin{align} \textrm{Event 1} &\rightarrow \textrm{[1, 2, 3]} \\ \textrm{Event 2} &\rightarrow \textrm{[2, 4]} \\ \textrm{Event 3} &\rightarrow \textrm{[4]} \\ \textrm{Event 4} &\rightarrow \textrm{[2, 3]} \end{align} $$
How would I go about generating a schedule so that the events are scheduled optimally? For the example above, one possible optimal schedule would be:
$$ \begin{align} \textrm{Period 1} &\rightarrow \textrm{Event 1} \\ \textrm{Period 2} &\rightarrow \textrm{Event 2} \\ \textrm{Period 3} &\rightarrow \textrm{Event 4} \\ \textrm{Period 4} &\rightarrow \textrm{Event 3} \\ \end{align} $$
Is there any way to do this in better than checking every permutation? This seems like the reverse of the graph-coloring problem for scheduling, so is there any way to construct a graph to encapsulate this relationship and maybe find a shortest path? Can someone point me in the right direction on how to approach this?