fix inconsistencies between graph challenge and solution

This commit is contained in:
Kevin Chan 2018-09-07 13:51:56 -07:00
parent 561b3203cc
commit edb1ac4143
2 changed files with 16 additions and 40 deletions

View File

@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/interactive-coding-challenges)."
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin) and [Kevin Chan](https://github.com/kevinxchan). Source and license info is on [GitHub](https://github.com/donnemartin/interactive-coding-challenges)."
]
},
{
@ -145,11 +145,11 @@
" # TODO: Implement me\n",
" pass\n",
"\n",
" def add_edge(self, source, dest, weight=0):\n",
" def add_edge(self, source_key, dest_key, weight=0):\n",
" # TODO: Implement me\n",
" pass\n",
"\n",
" def add_undirected_edge(self, source, dest, weight=0):\n",
" def add_undirected_edge(self, source_key, dest_key, weight=0):\n",
" # TODO: Implement me\n",
" pass"
]

View File

@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/interactive-coding-challenges)."
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin) and [Kevin Chan](https://github.com/kevinxchan). Source and license info is on [GitHub](https://github.com/donnemartin/interactive-coding-challenges)."
]
},
{
@ -153,19 +153,9 @@
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting graph.py\n"
]
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%writefile graph.py\n",
"from enum import Enum # Python 2 users: Run pip install enum34\n",
@ -231,19 +221,17 @@
" self.add_node(dest_key)\n",
" self.nodes[source_key].add_neighbor(self.nodes[dest_key], weight)\n",
"\n",
" def add_undirected_edge(self, src_key, dst_key, weight=0):\n",
" def add_undirected_edge(self, source_key, dest_key, weight=0):\n",
" if src_key is None or dst_key is None:\n",
" raise TypeError('key cannot be None')\n",
" self.add_edge(src_key, dst_key, weight)\n",
" self.add_edge(dst_key, src_key, weight)"
" self.add_edge(source_key, dest_key, weight)\n",
" self.add_edge(dest_key, source_key, weight)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"%run graph.py"
@ -258,19 +246,9 @@
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting test_graph.py\n"
]
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%writefile test_graph.py\n",
"from nose.tools import assert_equal\n",
@ -351,9 +329,7 @@
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -389,5 +365,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}