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", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "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", " # TODO: Implement me\n",
" pass\n", " pass\n",
"\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", " # TODO: Implement me\n",
" pass\n", " pass\n",
"\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", " # TODO: Implement me\n",
" pass" " pass"
] ]

View File

@ -4,7 +4,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "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", "cell_type": "code",
"execution_count": 1, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false "outputs": [],
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting graph.py\n"
]
}
],
"source": [ "source": [
"%%writefile graph.py\n", "%%writefile graph.py\n",
"from enum import Enum # Python 2 users: Run pip install enum34\n", "from enum import Enum # Python 2 users: Run pip install enum34\n",
@ -231,19 +221,17 @@
" self.add_node(dest_key)\n", " self.add_node(dest_key)\n",
" self.nodes[source_key].add_neighbor(self.nodes[dest_key], weight)\n", " self.nodes[source_key].add_neighbor(self.nodes[dest_key], weight)\n",
"\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", " if src_key is None or dst_key is None:\n",
" raise TypeError('key cannot be None')\n", " raise TypeError('key cannot be None')\n",
" self.add_edge(src_key, dst_key, weight)\n", " self.add_edge(source_key, dest_key, weight)\n",
" self.add_edge(dst_key, src_key, weight)" " self.add_edge(dest_key, source_key, weight)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"%run graph.py" "%run graph.py"
@ -258,19 +246,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false "outputs": [],
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting test_graph.py\n"
]
}
],
"source": [ "source": [
"%%writefile test_graph.py\n", "%%writefile test_graph.py\n",
"from nose.tools import assert_equal\n", "from nose.tools import assert_equal\n",
@ -351,9 +329,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 4,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
@ -389,5 +365,5 @@
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }