Skip to content

Commit

Permalink
slightly better graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLeoni committed Dec 12, 2019
1 parent 3ae3f1e commit b6c912a
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 93 deletions.
42 changes: 23 additions & 19 deletions exercises/graph-algos/graph-algos.ipynb

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions exercises/graph-algos/graph_solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,18 @@ def remove_vertex(self, vertex):
def transpose(self):
""" Reverses the direction of all the edges
- MUST perform in O(|V|+|E|)
Note in adjacency lists model we suppose there are only few edges per node,
so if you end up with an algorithm which is O(|V|^2) you are ending up with a
complexity usually reserved for matrix representations !!
NOTE: this method changes in-place the graph: does **not** create a new instance
and does *not* return anything !!
and does *not* return anything !!
NOTE: To implement it *avoid* modifying the existing _edges dictionary (would
probably more problems than anything else).
Instead, create a new dictionary, fill it with the required
verteces and edges ad then set _edges to point to the new dictionary.
probably more problems than anything else).
Instead, create a new dictionary, fill it with the required
verteces and edges ad then set _edges to point to the new dictionary.
"""
#jupman-raise

Expand Down
72 changes: 4 additions & 68 deletions index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -466,72 +466,6 @@
"\n",
"7 November 2019: published [Midterm Part A solution](exams/2019-11-07/exam-2019-11-07-solution.ipynb) \n",
"\n",
"5 November 2019: **WARNING: TUTORING CHANGE**\n",
"\n",
"Since Fridays apparently aren't the best day for tutoring (nobody went twice in a row), **we're moving Friday tutoring to Wednesday 9:00-11:00 starting with Wednesday 6 November. Rooms: A219 until Wednesday 13 November included, A218 afterwards**\n",
"\n",
"Given the fact many of you took ages to do the midterm simulation, I'd recommend attendance.\n",
"\n",
"2 November 2019:\n",
"\n",
"- published [Midterm simulation solutions](exams/2019-10-31/exam-2019-10-31-solution.ipynb) \n",
"- added NaN and infinities section to [matrix: numpy exercises](exercises/matrices-numpy/matrices-numpy-solution.ipynb)\n",
"- improved [pandas exercises](exercises/pandas/pandas-solution.ipynb)\n",
"- added [functions exercises](exercises/functions/functions-solution.ipynb)\n",
"\n",
"24 October 2019: updated [numpy matrices](exercises/matrices-numpy/matrices-numpy-solution.ipynb) and [visualization](exercises/visualization/visualization-solution.ipynb) \n",
"\n",
"22 October 2019: WARNING: TUTORING TIMETABLE CHANGE! \n",
"\n",
"Unfortunately, due to reasons beyond our control we need need to change timetable for tutoring:\n",
"\n",
"- Mondays remain the same: room A215 from 11.30-13.30\n",
"\n",
"- Fridays change: instead of previous 12.30-14:30, the new hours will be 11.00-13.00. Friday room is also changed, it will be A218 for all fridays\n",
"\n",
"\n",
"- Graph formats draw functions:\n",
" - fixed bug about username not found in windows\n",
" - now it is possible to save to file in draw_mat, draw_nx, etc by passing filename in parameter `save_to`, [see documentation](https://datasciprolab.readthedocs.io/en/latest/exercises/graph-formats/graph-formats-solution.html#Saving-a-graph-to-a-file)\n",
"\n",
"17 October 2019 : rewrote [Graph formats](exercises/graph-formats/graph-formats-solution.ipynb) page\n",
"\n",
"12 October 2019 : tutoring service has been set up on Mondays and Fridays starting Monday 14th October, see [timetable](#Tutoring)\n",
"\n",
"\n",
"10 October 2019: Save the dates:\n",
"\n",
"- MIDTERM PART A SIMULATION: 31 october 15:30-17:30 room a202\n",
"\n",
"- MIDTERM PART A: 7 november 11:30-13:30 room b106 \n",
"\n",
"IMPORTANT: differently from past Part A exams, there will also be an exercise on Pandas.\n",
"\n",
"- merged Part A graph stuff into [graph formats](https://datasciprolab.readthedocs.io/en/latest/exercises/graph-formats/graph-formats-solution.html)\n",
"\n",
"7 October 2019\n",
"\n",
"- added [Tuples](exercises/tuples/tuples-solution.ipynb) page (were extracted from [Lists](exercises/lists/lists-solution.ipynb))\n",
"- updated [Dictionaries](exercises/dictionaries/dictionaries-solution.ipynb)\n",
"- rewrote [Sets](exercises/sets/sets-solution.ipynb), now belongs to Part A\n",
"\n",
"3 October 2019: updated [Lists](exercises/lists/lists-solution.ipynb)\n",
"\n",
"1 October 2019\n",
"\n",
"- updated [Strings](exercises/strings/strings-solution.ipynb)\n",
"- updated [error handling and testing](exercises/errors-and-testing/errors-and-testing-solution.ipynb) \n",
"\n",
"24 September 2019\n",
"\n",
"- updated [introduction](exercises/introduction/introduction-solution.ipynb)\n",
"- added [Python basics](exercises/basics/basics-solution.ipynb)\n",
"\n",
"27 August 2019: published [exam solutions](exams/2019-08-26/exam-2019-08-26-solution.ipynb)\n",
"\n",
"2 July 2019: published [exam solutions](exams/2019-07-02/exam-2019-07-02-solution.ipynb)\n",
"\n",
"10 June 2019: published [exam solutions](exams/2019-06-10/exam-2019-06-10-solution.ipynb)\n",
"\n",
"[Old news](old-news.ipynb)"
]
Expand Down Expand Up @@ -813,7 +747,9 @@
"\n",
"* Part B theory slides by Luca Bianco\n",
"\n",
"* [Problem Solving with Algorithms and Data Structures using Python](https://runestone.academy/runestone/static/pythonds/index.html) online book by Brad Miller and David Ranum\n"
"* [Problem Solving with Algorithms and Data Structures using Python](https://runestone.academy/runestone/static/pythonds/index.html) online book by Brad Miller and David Ranum\n",
"\n",
"* [Theory exercises (complexity, tree visits, graph visits) - by Alberto Montresor](https://drive.google.com/drive/folders/1RwjiSvIq60Z9mj_gCd5K2E6Bj9y1R0CL)"
]
},
{
Expand Down Expand Up @@ -883,7 +819,7 @@
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
"toc_window_display": true
}
},
"nbformat": 4,
Expand Down
69 changes: 68 additions & 1 deletion old-news.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,73 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"5 November 2019: WARNING: TUTORING CHANGE\n",
"\n",
"Since Fridays apparently aren't the best day for tutoring (nobody went twice in a row), we're moving Friday tutoring to Wednesday 9:00-11:00 starting with Wednesday 6 November. Rooms: A219 until Wednesday 13 November included, A218 afterwards\n",
"\n",
"Given the fact many of you took ages to do the midterm simulation, I'd recommend attendance.\n",
"\n",
"2 November 2019:\n",
"\n",
"- published [Midterm simulation solutions](exams/2019-10-31/exam-2019-10-31-solution.ipynb) \n",
"- added NaN and infinities section to [matrix: numpy exercises](exercises/matrices-numpy/matrices-numpy-solution.ipynb)\n",
"- improved [pandas exercises](exercises/pandas/pandas-solution.ipynb)\n",
"- added [functions exercises](exercises/functions/functions-solution.ipynb)\n",
"\n",
"24 October 2019: updated [numpy matrices](exercises/matrices-numpy/matrices-numpy-solution.ipynb) and [visualization](exercises/visualization/visualization-solution.ipynb) \n",
"\n",
"22 October 2019: WARNING: TUTORING TIMETABLE CHANGE! \n",
"\n",
"Unfortunately, due to reasons beyond our control we need need to change timetable for tutoring:\n",
"\n",
"- Mondays remain the same: room A215 from 11.30-13.30\n",
"\n",
"- Fridays change: instead of previous 12.30-14:30, the new hours will be 11.00-13.00. Friday room is also changed, it will be A218 for all fridays\n",
"\n",
"\n",
"- Graph formats draw functions:\n",
" - fixed bug about username not found in windows\n",
" - now it is possible to save to file in draw_mat, draw_nx, etc by passing filename in parameter `save_to`, [see documentation](https://datasciprolab.readthedocs.io/en/latest/exercises/graph-formats/graph-formats-solution.html#Saving-a-graph-to-a-file)\n",
"\n",
"17 October 2019 : rewrote [Graph formats](exercises/graph-formats/graph-formats-solution.ipynb) page\n",
"\n",
"12 October 2019 : tutoring service has been set up on Mondays and Fridays starting Monday 14th October, see [timetable](#Tutoring)\n",
"\n",
"\n",
"10 October 2019: Save the dates:\n",
"\n",
"- MIDTERM PART A SIMULATION: 31 october 15:30-17:30 room a202\n",
"\n",
"- MIDTERM PART A: 7 november 11:30-13:30 room b106 \n",
"\n",
"IMPORTANT: differently from past Part A exams, there will also be an exercise on Pandas.\n",
"\n",
"- merged Part A graph stuff into [graph formats](https://datasciprolab.readthedocs.io/en/latest/exercises/graph-formats/graph-formats-solution.html)\n",
"\n",
"7 October 2019\n",
"\n",
"- added [Tuples](exercises/tuples/tuples-solution.ipynb) page (were extracted from [Lists](exercises/lists/lists-solution.ipynb))\n",
"- updated [Dictionaries](exercises/dictionaries/dictionaries-solution.ipynb)\n",
"- rewrote [Sets](exercises/sets/sets-solution.ipynb), now belongs to Part A\n",
"\n",
"3 October 2019: updated [Lists](exercises/lists/lists-solution.ipynb)\n",
"\n",
"1 October 2019\n",
"\n",
"- updated [Strings](exercises/strings/strings-solution.ipynb)\n",
"- updated [error handling and testing](exercises/errors-and-testing/errors-and-testing-solution.ipynb) \n",
"\n",
"24 September 2019\n",
"\n",
"- updated [introduction](exercises/introduction/introduction-solution.ipynb)\n",
"- added [Python basics](exercises/basics/basics-solution.ipynb)\n",
"\n",
"27 August 2019: published [exam solutions](exams/2019-08-26/exam-2019-08-26-solution.ipynb)\n",
"\n",
"2 July 2019: published [exam solutions](exams/2019-07-02/exam-2019-07-02-solution.ipynb)\n",
"\n",
"10 June 2019: published [exam solutions](exams/2019-06-10/exam-2019-06-10-solution.ipynb)\n",
"\n",
"- 13 January 2019: published [exam solutions](exams/2019-02-13/exam-2019-02-13-solution.ipynb)\n",
"- 23 January 2019: published [exam solutions](exams/2019-01-23/exam-2019-01-23-solution.ipynb)\n",
"- 23 January 2019: removed children() method from GenericTree (you shouldn't use it anyway)\n",
Expand Down Expand Up @@ -497,7 +564,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.7.3"
},
"toc": {
"base_numbering": 1,
Expand Down
16 changes: 16 additions & 0 deletions slides.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,22 @@
"At home: finish generic trees section"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Lab B.10\n",
"\n",
"Thursday 12 December\n",
"\n",
"* [Graphs](exercises/graphs/graphs.ipynb) \n",
"\n",
" 1. [Implement building](/exercises/graph-algos/graph-algos.html#1.-Implement-building)\n",
" 2. [Manipulate graphs](/exercises/graph-algos/graph-algos.html#2.-Manipulate-graphs)\n",
"\n",
"At home: finish Section 1 and 2"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit b6c912a

Please sign in to comment.