diff --git a/labs/10-graphs-exercises.ipynb b/labs/10-graphs-exercises.ipynb index 61a1428e4d896e583813403ed9a32e8efcf61afc..1a02600f793d72680b35fd3cadb368dfc7b041d1 100644 --- a/labs/10-graphs-exercises.ipynb +++ b/labs/10-graphs-exercises.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "53c1dc9b", + "id": "73af87e2", "metadata": {}, "source": [ "NAME:" @@ -63,7 +63,20 @@ "1. Draw the graph using a node-link diagram\n", "2. Does it have a cycle?\n", "3. Is it connected? If not, how many components?\n", - "4. Does it have a self loop?" + "4. Does it have a self loop?\n", + "5. What is the matrix representation?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4931afb4-c133-45a3-b124-5581d2e4d11a", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "M = [[]]" ] }, { @@ -73,9 +86,107 @@ "tags": [] }, "source": [ - "We will now check the properties programmatically in the next questions." + "Write a function that caculates the degree using the dictionnary data structure:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "64570050-4358-4f6f-bc47-d40cc11caccb", + "metadata": { + "deletable": false, + "nbgrader": { + "cell_type": "code", + "checksum": "06689d18aeb4da61ebaf404b394d1a2f", + "grade": false, + "grade_id": "cell-9d8017340cffddbb", + "locked": false, + "schema_version": 3, + "solution": true, + "task": false + }, + "tags": [] + }, + "outputs": [], + "source": [ + "def degree_dict(g, node):\n", + " # YOUR CODE HERE\n", + " raise NotImplementedError()" + ] + }, + { + "cell_type": "markdown", + "id": "8ef7c05c-0003-4eca-ac67-e4c712fa2b45", + "metadata": { + "tags": [] + }, + "source": [ + "Write a function that caculates the degree using the matrix data structure:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b6c61914-196b-4a4c-9309-70d08cd32bc5", + "metadata": { + "deletable": false, + "nbgrader": { + "cell_type": "code", + "checksum": "4118a7f0d5d0d42c626693f77b61c60e", + "grade": false, + "grade_id": "cell-99551fa4c7868af9", + "locked": false, + "schema_version": 3, + "solution": true, + "task": false + }, + "tags": [] + }, + "outputs": [], + "source": [ + "def degree_matrix(M, node):\n", + " # YOUR CODE HERE\n", + " raise NotImplementedError()" + ] + }, + { + "cell_type": "markdown", + "id": "81622da3-97c5-470e-af37-deb760cc009c", + "metadata": {}, + "source": [ + "Write tests" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bcaeac38-5109-444b-ab06-474bd570459a", + "metadata": { + "deletable": false, + "nbgrader": { + "cell_type": "code", + "checksum": "5efef8ca414623dc53969edbb004e64b", + "grade": false, + "grade_id": "cell-eef2d364b9c640f2", + "locked": false, + "schema_version": 3, + "solution": true, + "task": false + }, + "tags": [] + }, + "outputs": [], + "source": [ + "# YOUR CODE HERE\n", + "raise NotImplementedError()" ] }, + { + "cell_type": "markdown", + "id": "651a7b71-f636-4289-b13f-973ac71629d7", + "metadata": {}, + "source": [] + }, { "cell_type": "markdown", "id": "2d324f2e-25d4-488b-9178-c29f52caee1a",