I need to implement a 3 dimensional bipartite matching algorithm. I have this code which is a 2 dimensional bipartite matching algorithm. I have been able to convert it to PHP and it works fine. However I just realized that in my program, I need to match courses to rooms for specific time slots. If I use the 2 dimensional bipartite matching algorithm, the rooms already assigned cannot be used for courses in other time slots. I want to be able to have a match where the same room can be used again for another course once the time slot is different. How can I modify this code to use as input a graph with three dimensions: graph[u][v][w], where u is index of course, v is index of room and w is index of time slot?
I need to implement a 3 dimensional bipartite matching algorithm. I have this code
Share
Bipartite matching doesn’t work this way. ‘Bi’ means two. However, you can easily convert the graph to bipartite. Instead of thinking courses on the left and rooms on the right, think it this way – courses will still remain on the left, but on the right will be combined nodes of room and timeslot. Like this –
If you’re working on a real world problem, there will be other constraints like assigning 3 class rooms for a course in a week, 2 classes of the same course shouldn’t be on the same day etc. In such cases, you’d have to move away from bipartite model of the graph to general flow networks.