Solving the Königsberg Bridge Problem with Python | Graph Theory With Python #1

  Рет қаралды 12,914

David Amos

David Amos

Күн бұрын

Пікірлер: 30
@JosephChan4701
@JosephChan4701 2 жыл бұрын
For another perspective on the Königsberg Bridge problem, one can consider the number of edges on each vertex. To visit any vertex in a path once, there needs to be at least one edge going in, and another edge going out, for a total of 2 edges (so that each edge is only travelled once). If a vertex is visited twice, then there needs to be 2 edges in and 2 edges out, for a total of 4 edges. To generalise, any valid path needs an *even* number of edges for each edge to be visited once. There are two exceptions: the start vertex and end vertex. For the start vertex, there doesn’t _need_ to be an edge in, only an edge out, so it can just have one edge. It’s possible that the start edge can be visited another time (in which case we need to add another pair of edges to go in and out). It’s also possible that in a cyclical graph (of say 3 nodes), the start vertex has an even number (2) of edges. Likewise, the end vertex doesn’t _need_ an edge out (although it can!). From these facts, we can come up with a simple heuristic to solve this problem: there can be a maximum of 2 nodes with an odd number of edges. As the Königsberg graph has 3 vertices with an odd number of edges, it can’t be traversed with each edge being travelled only once.
@SP-db6sh
@SP-db6sh 2 жыл бұрын
Every programmer should watch this !
@georgelaing2578
@georgelaing2578 2 жыл бұрын
This is the most complete treatment of the 7 bridge problem I have ever seen! I especially enjoyed the historical details that you included. You are right that Euler would have hated the work in tabulating paths, although he did produce about 100 volumes of work. Did they ever finish collecting his material? Thanks again for a great video!
@DavidAmos
@DavidAmos 2 жыл бұрын
Thanks! I don’t know if they ever finished collecting all of his work. My guess is probably not. Who knows was left in his mind that he never wrote down? I doubt you can be that prolific without a constant stream of ideas coming in…
@VauRDeC
@VauRDeC 2 жыл бұрын
Indeed ! Thanks a lot David :)
@mukundraj1980
@mukundraj1980 3 жыл бұрын
Hi David. Its a Theory + Explanation + Programming RIght Mix and Enjoyable Learning that I was looking for Research.
@DavidAmos
@DavidAmos 3 жыл бұрын
Glad you found it helpful! I'll be adding more videos in the coming weeks!
@brightsideofmaths
@brightsideofmaths 3 жыл бұрын
Great content, very good quality and really enjoyable. Thank you :)
@DavidAmos
@DavidAmos 3 жыл бұрын
Thanks 🙏
@VanessaHernandez-zd1lg
@VanessaHernandez-zd1lg 3 жыл бұрын
Very well done! I found the use of colors especially helpful since I’m a visual learner
@DavidAmos
@DavidAmos 3 жыл бұрын
Thanks! Glad you liked it 🙂
@mkartmkart6335
@mkartmkart6335 2 жыл бұрын
Totally thumbsup with possibilities for more :) Thanx :)
@CodeSolid
@CodeSolid 11 ай бұрын
I enjoyed this quite a bit. I thought the Python could have been a bit more "dumbed down" to be more approachable for others (since you clearly are quite good at it), but that's a minor quibble. I was able to follow it. I also enjoyed the historical details, as another poster mentioned.
@giannisgrammatikakis6785
@giannisgrammatikakis6785 3 жыл бұрын
This is the channel I needed. Great job Danid! Thank you!
@DavidAmos
@DavidAmos 3 жыл бұрын
Glad to hear it!
@yatima1158
@yatima1158 3 жыл бұрын
I was playing around with the walks_starting_from function and I think there is a bug. I wanted to get all walks from the 5 cycle encoded as C_5 = [ ‘AbB', 'BbC', 'CcD', 'DdE', 'EeA'], walks_starting_from(‘B’, C_5) gave [‘BbA’] where I would expect the answer is [‘BbAeEdDcC’, ‘BbCcDdEeA’] - going round the clock both clockwise and anticlockwise. Seems like you’re missing some walks and need more conditional logic somewhere. Thanks for the great lecture otherwise! Look forward to learning more about how to implement graph theory.
@DavidAmos
@DavidAmos 3 жыл бұрын
Hey! It’s awesome to see someone is playing around with the code! I tested it out but couldn’t recreate the problem you had. I get both expected walks, one clockwise and one anticlockwise. I made a Google Colab with the modified code (all I did was change the BRIDGES list) which you can see and run here: colab.research.google.com/drive/1_6KPqHiVVVDGv2lfsfyfH6mQvLF_uItY?usp=sharing I’m happy to look at your code, if needed. Feel free to open an issue over at github.com/somacdivad/graph-theory-with-python if you want a second set of eyes 🙂
@sinnvollerkommentar263
@sinnvollerkommentar263 3 жыл бұрын
Very helpful if you want to get started in solving math problems yourself like I am. Also you showed very well how to include python
@slater-cguy
@slater-cguy 3 жыл бұрын
Just discovering this channel, great content/presentation!
@DavidAmos
@DavidAmos 3 жыл бұрын
Thanks! glad you like the videos!
@philipwest4553
@philipwest4553 2 жыл бұрын
Euler (a Swiss-German gentleman) is pronounced more like eo-ler than it is like oi-ler. The English language doesn't really have a diphthong that matches the eu in Euler. Oi is an approximation but not a good one. Better would be a short soft o-ler. This is a slightly random comment 🙂
@avalealidzy6739
@avalealidzy6739 3 жыл бұрын
Fully subscribed to channel. Your mathematical insights will have great applications to data science!
@DavidAmos
@DavidAmos 3 жыл бұрын
Thanks, Ava! I’m very happy to see you here 🙂
@samiakel260
@samiakel260 3 жыл бұрын
Well done! Great explanation. I really enjoyed it
@canaldofetrentin
@canaldofetrentin Жыл бұрын
hii, I am taking a graph course in my university and from now on I'm watching your videos to get along with python etc. I just would like to know why is it necessary to declare a variable in available_bridhes and iterate over it, like: available_bridges = [ bridge for bridge in bridges: ] not simply: available_bridges = [ for bridge in bridges ]
@yevgen4195
@yevgen4195 8 ай бұрын
Amazing material!
@theencryptedpartition4633
@theencryptedpartition4633 Жыл бұрын
Euler was such a badass
@avalealidzy6739
@avalealidzy6739 3 жыл бұрын
Could this be considered a Search Optimization Algorithm?
@DavidAmos
@DavidAmos 3 жыл бұрын
Hmm, I don't _think_ so... The solution _is_ using a version of depth first search (DFS), though.
@5thbatman
@5thbatman 8 ай бұрын
legend
Confronting Ronaldo
00:21
MrBeast
Рет қаралды 27 МЛН
From Small To Giant 0%🍫 VS 100%🍫 #katebrush #shorts #gummy
00:19
Do you love Blackpink?🖤🩷
00:23
Karina
Рет қаралды 22 МЛН
The Fastest Way to Loop in Python - An Unfortunate Truth
8:06
mCoding
Рет қаралды 1,4 МЛН
Is This The Best Graph Theory Book Ever?
13:28
David Amos
Рет қаралды 16 М.
Degrees and Degree Sequences | Graph Theory With Python #4
39:30
David Amos
Рет қаралды 4,7 М.
Solutions to Part 4 Exercises | Graph Theory With Python #4.5
14:51
5 Good Python Habits
17:35
Indently
Рет қаралды 632 М.
25 nooby Python habits you need to ditch
9:12
mCoding
Рет қаралды 1,8 МЛН
NetworkX Crash Course - Graph Theory in Python
38:49
NeuralNine
Рет қаралды 74 М.
15 Python Libraries You Should Know About
14:54
ArjanCodes
Рет қаралды 403 М.