Write a function tournamentWinners
that accepts a reference to a BasicGraph
representing a tournament and returns a Set
of strings representing the names of all the winners in that tournament.
A tournament is a graph of a contest among n players.
Each player plays a game against each other player, and either wins or loses it (no draws).
A player is represented by a vertex, and a directed edge shows the winner pointing to the loser.
In the tournament shown below, player A won against player E, but lost against players B, C, and D.
A tournament winner is a player who, for each other player, either won a game against that player, or won a game against a player who won their game against that player (or both).
For example, in the graph above, players B, C, and E are tournament winners, so your function should return {"B", "C", "E"}
.
However, player D is not a tournament winner, because he neither beat player C, nor beat anyone who in turn beat player C.
Although player D won against player E, who in turn won against player B, who then won against player C, under our definition player D is not a winner.
You may assume that the parameter values passed are valid.