Skip to content

Commit

Permalink
much improved graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLeoni committed Dec 11, 2018
1 parent cd98cc4 commit 0cc7632
Show file tree
Hide file tree
Showing 22 changed files with 18,242 additions and 473 deletions.
15,979 changes: 15,979 additions & 0 deletions exercises/graph-algos/graph-algos.ipynb

Large diffs are not rendered by default.

701 changes: 701 additions & 0 deletions exercises/graph-algos/graph_solution.py

Large diffs are not rendered by default.

840 changes: 840 additions & 0 deletions exercises/graph-algos/graph_test.py

Large diffs are not rendered by default.

161 changes: 161 additions & 0 deletions exercises/graph-algos/img/flux-capacitor-depth-2.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
209 changes: 209 additions & 0 deletions exercises/graph-algos/img/flux-capacitor-depth-3.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added exercises/graph-algos/img/flux-capacitor.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added exercises/graph-algos/img/flux-capacitor.odg
Binary file not shown.
Binary file added exercises/graph-algos/img/pie.odg
Binary file not shown.
Binary file added exercises/graph-algos/img/pie.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
180 changes: 180 additions & 0 deletions exercises/graph-algos/img/pie.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions exercises/trees/bin_tree_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ def get_children(bt):
def rec_assert(c1, c2, row):

if c2 == None:
raise Exception("Bad test code! Found a None node in EXPECTED tree!\n\n"
raise Exception("Found a None node in EXPECTED tree!\n\n"
+ str_btrees(actual,expected,row))

if c1 == None:
raise Exception("Found a None node in actual tree! \n\n"
raise Exception("Found a None node in ACTUAL tree! \n\n"
+ str_btrees(actual,expected,row))

if not isinstance(c2, BinaryTree):
raise Exception("Bad test code! EXPECTED value is an instance of %s , which is not a BinaryTree !\n\n%s" % (type(c2).__name__ , str_btrees(actual,expected,row)))
raise Exception("EXPECTED value is an instance of %s , which is not a BinaryTree !\n\n%s" % (type(c2).__name__ , str_btrees(actual,expected,row)))

if not isinstance(c1, BinaryTree):
raise Exception("ACTUAL node is an instance of %s , which is not a BinaryTree !\n\n%s"
Expand Down
34 changes: 17 additions & 17 deletions exercises/trees/gen_tree_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ def assertTreeEqual(self, actual, expected):
def rec_assert(c1, c2, row):

if c2 == None:
raise Exception("Bad test code! Found a None node in EXPECTED tree!\n\n"
raise Exception("Found a None node in EXPECTED tree!\n\n"
+ str_trees(actual,expected,row))

if c1 == None:
raise Exception("Found a None node in actual tree! \n\n"
raise Exception("Found a None node in ACTUAL tree! \n\n"
+ str_trees(actual,expected,row))

if not isinstance(c2, GenericTree):
raise Exception("Bad test code! EXPECTED value is an instance of %s , which is not a GenericTree !\n\n%s" % (type(c2).__name__ , str_trees(actual,expected,row)))
raise Exception("EXPECTED value is an instance of %s , which is not a GenericTree !\n\n%s" % (type(c2).__name__ , str_trees(actual,expected,row)))

if not isinstance(c1, GenericTree):
raise Exception("ACTUAL node is an instance of %s , which is not a GenericTree !\n\n%s"
Expand Down Expand Up @@ -157,7 +157,7 @@ def rec_assert(c1, c2, row):
+ " Expected parent = None"
+ "\n\n" + str_trees(actual,expected,row))
else: # let's just check data for now
self.assertEquals(c1.parent().data(), c2.parent().data(),
self.assertEqual(c1.parent().data(), c2.parent().data(),
"Different parents ! "
+ "Actual parent.data() = " + str(c1.parent().data())
+ " Expected parent.data() = " + str(c2.parent().data()
Expand Down Expand Up @@ -442,22 +442,22 @@ def test_level2(self):
class GrandChildrenTest(GenericTreeTest):

def test_grandchildren_root(self):
self.assertEquals(gt('a').grandchildren(), [])
self.assertEqual(gt('a').grandchildren(), [])

"""
a
\-b
"""
def test_grandchildren_one_child_no_children(self):
self.assertEquals(gt('a', gt('b')).grandchildren(), [])
self.assertEqual(gt('a', gt('b')).grandchildren(), [])

"""
a
\-b
\-c
"""
def test_grandchildren_one_child_one_grandchildren(self):
self.assertEquals(gt('a', gt('b', gt('c'))).grandchildren(), ['c'])
self.assertEqual(gt('a', gt('b', gt('c'))).grandchildren(), ['c'])

"""
a
Expand All @@ -466,7 +466,7 @@ def test_grandchildren_one_child_one_grandchildren(self):
\-d
"""
def test_grandchildren_one_child_two_grandchildren(self):
self.assertEquals(gt('a', gt('b', gt('c'), gt('d'))).grandchildren(), ['c', 'd'])
self.assertEqual(gt('a', gt('b', gt('c'), gt('d'))).grandchildren(), ['c', 'd'])

"""
a
Expand All @@ -476,7 +476,7 @@ def test_grandchildren_one_child_two_grandchildren(self):
\-e
"""
def test_grandchildren_two_children_two_grandchildren(self):
self.assertEquals(gt('a', gt('b', gt('c')), gt('d', gt('e'))).grandchildren(), ['c', 'e'])
self.assertEqual(gt('a', gt('b', gt('c')), gt('d', gt('e'))).grandchildren(), ['c', 'e'])

"""
a
Expand All @@ -489,7 +489,7 @@ def test_grandchildren_two_children_two_grandchildren(self):
\-f
"""
def test_grandchildren_complex_grandgrandchildren(self):
self.assertEquals(gt('a', gt('b', gt('c'), gt('d', gt('g'))),
self.assertEqual(gt('a', gt('b', gt('c'), gt('d', gt('g'))),
gt('e', gt('h')),
gt('f')).grandchildren(), ['c', 'd', 'h'])

Expand Down Expand Up @@ -629,7 +629,7 @@ def test_uncles_unique_single_child(self):
tb = gt('b')
ta = gt('a', tb, gt('c') )

self.assertEquals(tb.uncles(), [])
self.assertEqual(tb.uncles(), [])


"""
Expand All @@ -642,7 +642,7 @@ def test_uncles_unique_single_grandchild(self):
tc = gt('c')
ta = gt('a', gt('b'), tc)

self.assertEquals(tc.uncles(), [])
self.assertEqual(tc.uncles(), [])

"""
a
Expand All @@ -655,7 +655,7 @@ def test_uncles_one_uncle_after(self):
tc = gt('c')
ta = gt('a', gt('b', tc), gt('d'))

self.assertEquals(tc.uncles(), ['d'])
self.assertEqual(tc.uncles(), ['d'])



Expand All @@ -671,7 +671,7 @@ def test_uncles_one_uncle_before(self):
td = gt('d')
ta = gt('a', gt('b'), gt('c', td))

self.assertEquals(td.uncles(), ['b'])
self.assertEqual(td.uncles(), ['b'])


"""
Expand All @@ -687,7 +687,7 @@ def test_uncles_middle(self):
td = gt('d')
ta = gt('a', gt('b'), gt('c', td), gt('e'))

self.assertEquals(td.uncles(), ['b', 'e'])
self.assertEqual(td.uncles(), ['b', 'e'])

"""
a
Expand All @@ -705,7 +705,7 @@ def test_uncles_complex_1(self):
ta = gt('a', gt('b', gt('c'), gt('d', gt('g'))),
gt('e', th),
gt('f'))
self.assertEquals(th.uncles(), ['b', 'f'])
self.assertEqual(th.uncles(), ['b', 'f'])

"""
a
Expand All @@ -723,7 +723,7 @@ def test_uncles_complex_2(self):
ta = gt('a', gt('b', gt('c'), gt('d', tg)),
gt('e', gt('h')),
gt('f'))
self.assertEquals(tg.uncles(), ['c'])
self.assertEqual(tg.uncles(), ['c'])


class CommonAncestorTest(GenericTreeTest):
Expand Down
27 changes: 4 additions & 23 deletions index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -459,34 +459,15 @@
"source": [
"## News\n",
"\n",
"- **the lab of Friday 14th Dec is moved to _A211_ from 8:30 to 11:30** . As you have noticed, there is even an extra FREE hour of coding, so don't miss this special Friday offer !\n",
"- **IMPORTANT: the lab of Friday 14th Dec is moved to _A211_ from 8:30 to 11:30** . As you have noticed, there is even an extra FREE hour of coding, so don't miss this special Friday offer !\n",
"- **11 December 2018**: published [graph algorithm exercises](exercises/graph-algos/graph-algos.ipynb)\n",
"- **9 December 2018**: fixed [tree exercises](exercises/trees/trees.ipynb)\n",
"- 6 December 2018: published [linked-lists exercises](exercises/linked-lists/linked-lists.ipynb)\n",
"- 5 December 2018: expanded [sorting](exercises/sorting/sorting.ipynb) with insertion_sort, merge_sort, quick_sort\n",
"- 16 November 2018: Published [midterm solutions](exams/2018-11-16/exam-2018-11-16-solution.ipynb)\n",
"- 14 November 2018: Published [midterm simulation exam solutions](exams/2018-11-13/exam-2018-11-13-solution.ipynb)\n",
"- 6 November 2018: RESTRUCTURED WEBSITE\n",
" - Added [Exam modalities](#What-I-expect) , please read them\n",
" - Added difficulty ratings to exercises\n",
" - Added sections:\n",
" - [Strings](exercises/strings/strings-solution.ipynb)\n",
" - [Graph formats](exercises/graph-formats/graph-formats-solution.ipynb)\n",
" - [Binary relations](exercises/binary-relations/binary-relations-solution.ipynb)\n",
" - [Pandas](exercises/pandas/pandas-solution.ipynb)\n",
" - Expanded sections:\n",
" - [Lists](exercises/lists/lists-solution.ipynb)\n",
" - [Visualization](exercises/visualization/visualization-solution.ipynb) \n",
"- 26 October 2018: IMPORTANT: there will be NO LABS on Tuesday 20 October and on Friday 2 November. Next lab is scheduled for Tuesday 6 November.\n",
"- 23 October 2018: \n",
"Restructured Basic data structures material, separating into pages [Lists](exercises/lists/lists-solution.ipynb) and [Dictionaries](exercises/dictionaries/dictionaries-solution.ipynb)\n",
"- 16 October 2018:\n",
" - restructured Matrix material, separating matrix chapter into pages [Matrix as lists of lists](exercises/matrix-lists/matrix-lists-solution.ipynb) and [Matrix networks](exercises/matrix-networks/matrix-networks-solution.ipynb) \n",
" - fixed graph drawing function and moved it to `sciprog` module. \n",
"- 13 October 2018: added explanations to [Matrix as lists of lists lesson](exercises/matrix-lists/matrix-lists-solution.ipynb)\n",
"- The missed lab of 2nd October is moved to Wednesday 10 October 11.30-13.30 room A209 Povo 1. Other scheduled labs will be held regularly.\n",
"- 5 October 2018 14:30 A214 Povo 1: lab to be held regularly\n",
"- 2 October 2018: Lab 2 did not happen, I apologize for the inconvenience. See you on Friday 5th October at 14:30\n",
"- 21 Sept 2018: Moved website from old [QCB master sciprolab2.readthedocs.io](https://sciprolab2.readthedocs.io) to [datasciprolab.readthedocs.io](https://datasciprolab.readthedocs.io)"
"\n",
"[Old news](old-news.ipynb)"
]
},
{
Expand Down
27 changes: 23 additions & 4 deletions old-news.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@
"\n",
"<div class=\"alert alert-warning\">\n",
"\n",
"**Warning**: last news are published at the [top of course description](home.ipynb) <br/>\n",
"**Warning**: last news are published at the [top of course description](index.ipynb) \n",
"\n",
"</div>\n",
"\n"
Expand All @@ -426,9 +426,28 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"**September 2018, DataSciproLab is born !**\n",
"\n",
"Let's celebrate !"
"- 6 November 2018: RESTRUCTURED WEBSITE\n",
" - Added [Exam modalities](#What-I-expect) , please read them\n",
" - Added difficulty ratings to exercises\n",
" - Added sections:\n",
" - [Strings](exercises/strings/strings-solution.ipynb)\n",
" - [Graph formats](exercises/graph-formats/graph-formats-solution.ipynb)\n",
" - [Binary relations](exercises/binary-relations/binary-relations-solution.ipynb)\n",
" - [Pandas](exercises/pandas/pandas-solution.ipynb)\n",
" - Expanded sections:\n",
" - [Lists](exercises/lists/lists-solution.ipynb)\n",
" - [Visualization](exercises/visualization/visualization-solution.ipynb) \n",
"- 26 October 2018: IMPORTANT: there will be NO LABS on Tuesday 20 October and on Friday 2 November. Next lab is scheduled for Tuesday 6 November.\n",
"- 23 October 2018: \n",
"Restructured Basic data structures material, separating into pages [Lists](exercises/lists/lists-solution.ipynb) and [Dictionaries](exercises/dictionaries/dictionaries-solution.ipynb)\n",
"- 16 October 2018:\n",
" - restructured Matrix material, separating matrix chapter into pages [Matrix as lists of lists](exercises/matrix-lists/matrix-lists-solution.ipynb) and [Matrix networks](exercises/matrix-networks/matrix-networks-solution.ipynb) \n",
" - fixed graph drawing function and moved it to `sciprog` module. \n",
"- 13 October 2018: added explanations to [Matrix as lists of lists lesson](exercises/matrix-lists/matrix-lists-solution.ipynb)\n",
"- The missed lab of 2nd October is moved to Wednesday 10 October 11.30-13.30 room A209 Povo 1. Other scheduled labs will be held regularly.\n",
"- 5 October 2018 14:30 A214 Povo 1: lab to be held regularly\n",
"- 2 October 2018: Lab 2 did not happen, I apologize for the inconvenience. See you on Friday 5th October at 14:30\n",
"- 21 Sept 2018: Moved website from old [QCB master sciprolab2.readthedocs.io](https://sciprolab2.readthedocs.io) to [datasciprolab.readthedocs.io](https://datasciprolab.readthedocs.io)"
]
},
{
Expand Down
8 changes: 8 additions & 0 deletions past-exams.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"- no biological examples\n",
"- less dynamic programming\n",
"- more exercises on graphs & matrices\n",
"- custom DiGraph won't have Visit and VertexLog classes\n",
"\n",
"## 2016-17\n",
"\n",
Expand All @@ -47,6 +48,13 @@
"\n",
"</div>\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit 0cc7632

Please sign in to comment.