Question: Identify gnomes in different hat colors In this question, we start conceptualising gnome evidences as a graph, focusing on the cases where gnomes in
Identify gnomes in different hat colors In this question, we start conceptualising gnome evidences as a graph, focusing on the cases where gnomes in the same tuple (i.e. a gnome pair) in the evidence can wear hats that differ in colors. The graph is represented as a dictionary. Nodes in the graph are gnome IDs, and edges connect genome-pairs who have distinct hat colors. Note: In this question, we only focus on gnome pairs with different coloured hats in evidence. Write a function make_color_mutex_graph (evidences) that takes a list of evidences as input and returns a graph (dictionary) of gnomes with different hat colors (negation_edges). The keys of the dictionary are gnome IDs, and the values contain other gnome IDs, which satisfy: (1) the key gnome and each value gnome are in the same evidence tuple (i.e. they are gnome pairs) (2) the key and value gnomes differ in hat colors. (Just for this question) For consistency of the output, if a dictionary value contains two or more entries, please make sure that they are sorted in the increasing order (and, therefore, each value should be a list). Sample runs: >>> evidences = [((11, 2), 0), ((3, 6), 2), ((4, 9), 2), (( >>> print (make_color_mutex_graph (evidences)) {4: [6], 6: [4]} It corresponds to the following graph (note that the graph is undirected, and the dictionary contains two entries (directions) for each edge): 4 6 >>> evidences = [((11, 2), 0), ((3, 2), 2), ((4, 9), 2)] >>> print (make_color_mutex_graph (evidences)) {} There are no gnome pairs with different coloured hats. >>> evidences = [((11, 2), 1), ((3, 2), 1), ((4, 9), 2)] >>> print (make_color_mutex_graph (evidences)) {11: [2], 2: [3, 11], 3: [2]} It corresponds to the following graph: 11 2 3
Step by Step Solution
There are 3 Steps involved in it
There are no images attached to your message Based on your provided question I will answer it direct... View full answer
Get step-by-step solutions from verified subject matter experts
