Likes ===== Consider a scenario of a social network where people "gives *likes*" to each other. Let's use an example represented in the follwing picture where nodes are people and directed arrows represent that the origin gave a like to the target: .. image:: likes.jpeg :width: 800px :height: 400px :scale: 50 % :alt: alternate text :align: center The information about the "likes" can be represented in Python as a dictionary where the keys are person names in the network (:class:`str`) and the associated value is the list of people names (:class:`list` of :class:`str`) to whom that person gave a like. For example: .. literalinclude:: compute_likedby_dict.test :language: pycon :start-after: --ini-in :end-before: --fi-in .. note:: We assume that all likes involve people appearing as a key in the dictionary (no likes to people who is not in the network. You are required to implement the following functions and deliver them in the module :mod:`likes` (file :file:`likes.py`). ------------------------------------------------------------------------------------------------ The first function is: .. py:function:: compute_likedby_dict(likesD) such that **given** *likesD* (:class:`dict`) a *likes dictionary* as described above. **returns** a new :class:`dict` where: #. The keys are all the names (:class:`str`) of people in the network. #. The value associated to each key is a :class:`list` with all the names of people that has given a like to the key person. The names must be **alphabetically ordered**. The input :class:`dict` should **not** be modified. .. note:: The new dict must also include the people who did not receive any like, whose value will consequently be the empty list. For example, the expected outpout for the above *likes* :class:`dict` would be: .. literalinclude:: compute_likedby_dict.test :language: pycon :start-after: --ini-out :end-before: --fi-out Doctests are available in the :download:`compute_likedby_dict.test` file. ------------------------------------------------------------------------------------------------ The second function is: .. py:function:: compute_matches_list(langD) such that **given** *likesD* (:class:`dict`) a *likes dictionary* as described above. **returns** a :class:`list` of pairs of people (:class:`tuple`) that **matched**. Both, the names inside each tuple and the list of tuples must be **alphabetically ordered**. For example, the expected outpout for the above example dict would be: .. literalinclude:: compute_matches_list.test :language: pycon :start-after: --ini-out :end-before: --fi-out Doctests are available in the :download:`compute_matches_list.test` file.