Sounds like an application of a connected directed weighted graph - one, or more, of the various graph theory related modules may be your friend ... along with a judicious coating of combinatorics/graph theory (allowing you to discern the best module(s) for your use).
A user level that continues to overstate my experience :-))