Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 It corresponds to the following graph (note that the graph is undirected, and the dictionary contains two

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

Step: 1

To create the makecolormutexgraph function as described you will need to process the given list of evidences which appear to be tuples where the first ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intermediate Microeconomics

Authors: Hal R. Varian

9th edition

978-0393123975, 393123979, 393123960, 978-0393919677, 393919676, 978-0393123968

More Books

Students also viewed these Programming questions

Question

Case : Karl and June Monroe

Answered: 1 week ago

Question

what is number of IP address if number of host 2 7

Answered: 1 week ago