问题
Suppose I have N teams and what to generate a fixture list, where every team plays every other team, what is the best practice for this. Is there a known algorithm that does this nicely? Efficiency isn't really a necessity as this only needs to be generated once a season.
To be more specific, I'll start with some definitions: I have N teams... T_1, T_2, ... , T_n. If N is odd, include a 'ghost' team to make the amount of teams even. A set of fixtures for a week is a set of N/2 pairs, with no team in more than one pair. A 'fixture list' is set of sets of fixtures such that every team is paired with every other team.
What I am trying to do is create a 'fixture list' with some kind of random element to it. Thanks
回答1:
Here is the usual way. If you need some random element, you can shuffle the list of teams first. It doesn't matter much, since every team plays every other anyway.
来源:https://stackoverflow.com/questions/4418452/generating-fixtures-from-a-list-of-n