Graph Introduction - Data Structures & Algorithms Tutorials In Python #12

Поділитися
Вставка
  • Опубліковано 15 гру 2024

КОМЕНТАРІ • 184

  • @codebasics
    @codebasics  2 роки тому +3

    Do you want to learn python from me with a lot of interactive quizzes, and exercises? Here is my project-based python learning course: codebasics.io/courses/python-for-beginner-and-intermediate-learners

    • @xspydazx
      @xspydazx 3 місяці тому

      my favorite tree is the trie i use it for everything !

  • @turjo119
    @turjo119 3 роки тому +28

    Thank you for your efforts. As a self-taught learner who had no background in CS until a year ago, videos such as yours are what's helping me believe I can succeed in a new career field.

  • @19_kartikaswal19
    @19_kartikaswal19 4 роки тому +18

    After completion of data structures sir please dont forget to make videos on algorithms using python because this is really rare to find someone ...your work is awesome please keep going ..we truly rely on you.

    • @codebasics
      @codebasics  4 роки тому +18

      Yes sure. I am going to make this series complete by covering almost all the concepts in DS and algorithms

  • @tusharpatne6863
    @tusharpatne6863 4 роки тому +54

    Sir, please make a playlist on Algorithms with Python.

  • @awsomeslayer1
    @awsomeslayer1 3 роки тому +3

    This is the only video that I had to watch 2nd time in order to understand. But it is because of the complexity of Graph and my friends tell me that even if you get it in 2nd try, the video maker has done a great job. Thanks Daval, your tutorials are the best.

  • @entity5678
    @entity5678 9 місяців тому +1

    I know sir you teach python stuff but never really thought you are this good..I am trying to have this thing in my head for the interviews and the way you taught is beyond excellent..you got a new subscriber..

  • @etorty_dev
    @etorty_dev 3 роки тому +15

    Wow! You put in a great deal of effort into these videos! Thank you so much!
    Please, please give us some exercises or problems we can solve on graphs: directed, undirected and weighted types.
    I've had so much fun working on the previous exercises in this series.

  • @Rahul_1.618
    @Rahul_1.618 Рік тому

    This is hands down the best intro to graphs in python I've come across. Amazing work, dude!

  • @pranavwarke1966
    @pranavwarke1966 3 роки тому +3

    This playlist helped me understand DSA more deeply. Thanks for making it look more easy.

  • @rameshthamizhselvan2458
    @rameshthamizhselvan2458 4 роки тому +2

    Your efforts never waste... alwayzzz will give thumbs up....

  • @sayantanisaha
    @sayantanisaha 3 роки тому +3

    Thank you, awaiting for graphs.....and waiting for Algos.....and also you are the best DSA teacher out there

  • @ExeArjuna
    @ExeArjuna 3 роки тому

    If you have already a method called "get_paths" for getting all possible routes, then you can get the shortest_path by reusing that same method too. This will also show the all possible shortest routes rather than showing just one.
    "Shortest Path between Mumbai and New York: [['Mumbai', 'Paris', 'New York'], ['Mumbai', 'Dubai', 'New York']]"
    def get_shortest_path(self, start, end):
    total_paths = self.get_paths(start,end)
    shortest_paths = []
    for i in total_paths:
    if len(i) == len(min(total_paths)):
    shortest_paths.append(i)

    return shortest_paths
    ALSO A BIG THANK YOU @codebasics FOR SHARING ALL YOUR KNOWLEDGE AND HELPING US.

    • @faisalabdulkadir9439
      @faisalabdulkadir9439 2 роки тому

      pls can u explain why he did path = path + [start] and how does it work recursively?

  • @thammayyaarava2259
    @thammayyaarava2259 3 роки тому +1

    Love from India🇮🇳
    You made data structures like a elementary school subject. I feel so comfortable when you are teaching it sir❤❤

    • @codebasics
      @codebasics  3 роки тому

      Glad it was helpful!

    • @faisalabdulkadir9439
      @faisalabdulkadir9439 2 роки тому

      pls can u explain why he did path = path + [start] and how does it work recursively?

  • @sagardhiman4337
    @sagardhiman4337 Рік тому +1

    Sir You are really doing a great job, lectures are excellent .Keep up the good work.

  • @mr_californian
    @mr_californian Рік тому

    Bro you are helping me a lot on passing my DS class. Thanks so much

  • @chiragmiskin7239
    @chiragmiskin7239 3 роки тому

    This was one of the best DSA series I have seen! It has helped me a lot!!

    • @faisalabdulkadir9439
      @faisalabdulkadir9439 2 роки тому

      pls can u explain why he did path = path + [start] and how does it work recursively?

  • @sachinmaurya3259
    @sachinmaurya3259 3 роки тому

    Finally, I can say I know DSA ..........
    thank you sir for such a good explanation

  • @aaronaaronaaron5922
    @aaronaaronaaron5922 3 роки тому +1

    What a wonderful and patience video!!!!!! Thanks again!!!! 🤸‍♂️

  • @manideep6814
    @manideep6814 3 роки тому

    I've implemented this long ago but did not know this was called Graph. Thanks for deep insights.

    • @faisalabdulkadir9439
      @faisalabdulkadir9439 2 роки тому

      pls can u explain why he did path = path + [start] and how does it work recursively?

    • @babumohanan1467
      @babumohanan1467 9 місяців тому

      this is merging two list in to a single list at the beginning path has a value lets assume "mumbai", second time the sart has another node suppose it is "new york" hence path would be ["mumbai"]+["ne york"] = ["mumbai","new york"]@@faisalabdulkadir9439

  • @ExplorerDheeraj9271
    @ExplorerDheeraj9271 4 роки тому +1

    Superb....I have learnt all data structures from your playlist. Your videos are interesting and attractive.
    THANK YOU SO SO MUCH ❤️❤️❤️❤️
    LOVE FROM ANDHRA PRADESH...❤️❤️

  • @deepikapatra1065
    @deepikapatra1065 4 роки тому +3

    Hello, this series has been really helpful in my coding preparation, especially for understanding how to implement different data structures with Python. Could you please upload more videos on graph and also exercises related to it? Your exercises are really amazing:)

    • @codebasics
      @codebasics  4 роки тому +8

      Yes Deepika I am actively working on this series. It will have many more videos , your one stop solution for all data structure and algo knowledge. Stay tuned! 👍

  • @hassanmoussa4433
    @hassanmoussa4433 Рік тому +1

    hello , thanks for your efforts ,
    but did you upload the part for weighted graphs ?

  • @ganesh.majety5260
    @ganesh.majety5260 4 роки тому +9

    Absolutely fantastic series BIG thumb's up sir.
    Hopefully make a playlist of Algorithms as well😍

    • @codebasics
      @codebasics  4 роки тому +3

      sure i will add algo videos

  • @austinscott1407
    @austinscott1407 3 роки тому +1

    To prevent people from spending 30 mins troubleshooting like me, this is a key difference in the get_paths() method and get_shortest_path() method:
    get_paths():
    if start == end:
    return [path]
    get_shortest_path():
    if start == end:
    return path
    get_paths() returns it's path variable converted to list form, which then allows it to build onto the previous list (Because we're adding additional paths (lists) to eachother). Not the case in get_shortest_path() which is replacing the existing path with a new one, if the new one is shorter than the others.
    Spent a while trying to figure out why it was returning [['Mumbai','Paris','Dubai','New York']] as the shortest path only to realize it was a list of lists, which had a len==1

  • @lost-mar-ble
    @lost-mar-ble 4 роки тому +1

    love this playlist. Keep continuing this!. Thank you

  • @learningwithjuce
    @learningwithjuce 3 роки тому +2

    Thank you for breaking it all down clearly

  • @sepehrnem9773
    @sepehrnem9773 2 місяці тому

    Thank you a lot for this fantastic course

  • @MrJouH4
    @MrJouH4 2 роки тому +1

    Hi prof, i hope you are very well.
    We all hope that you consider making other videos about graph and its implementation (EX: weighted graph, graph using adjacancy matrix, ...)
    And thank you for all your effort, i wish you a great day.

  • @ileanawilson610
    @ileanawilson610 4 роки тому +2

    Sir your explanation is damn good..we need algorithm also like how to use greedy ,dynamic programming, divide and conquer, branch and bound ,bit manipulation etc..pleaseeeee sirrr

    • @codebasics
      @codebasics  4 роки тому +3

      yes i am going to add many more tutorials in this series.

  • @kavandalal
    @kavandalal 2 роки тому

    Waiting for more videos on graphs

  • @vidhanrathore5954
    @vidhanrathore5954 2 роки тому

    please make a detailed video for all the concepts of graph
    Thanks a lot, sir this help me alot

  • @SiddharthSingh-dg6zs
    @SiddharthSingh-dg6zs 3 роки тому

    line 5 to 10 can be reduced as below :)
    for start, end in self.edges:
    self.graph_dict.setdefault(start, []).append(end)
    print(self.graph_dict)

    • @faisalabdulkadir9439
      @faisalabdulkadir9439 2 роки тому

      pls can u explain why he did path = path + [start] and how does it work recursively?

  • @vishwasrchonu7134
    @vishwasrchonu7134 10 місяців тому

    best DS tutorials 💯💯

  • @hshrestha2811
    @hshrestha2811 3 роки тому +1

    Very helpful Sir. I was wondering if you would come up with more videos and exercises related to graph theory and its implementation.

    • @faisalabdulkadir9439
      @faisalabdulkadir9439 2 роки тому

      pls can u explain why he did path = path + [start] and how does it work recursively?

  • @gozdeyzgngl
    @gozdeyzgngl Рік тому

    Sometimes you explain complex things very simply with more basic data.

  • @siddharthsinghh
    @siddharthsinghh 3 роки тому

    Sir please make all further videos related to the graph

  • @ujjwal4441
    @ujjwal4441 4 роки тому +4

    whats the need of creating paths when it gives the same thing as in new_paths?

  • @kasrayazdani8628
    @kasrayazdani8628 2 роки тому

    Nicely explained.

  • @ethanhunt8493
    @ethanhunt8493 Рік тому

    Sir jald bhut sare problem ke saath bnaiye video

  • @Abhishek-jh9lz
    @Abhishek-jh9lz Рік тому

    Great Educational content ❤

    • @codebasics
      @codebasics  Рік тому

      I am happy this was helpful to you.

  • @SENAPATIENTERTAINMENT
    @SENAPATIENTERTAINMENT 3 роки тому

    More graph videos please 🙏

  • @fahadreda3060
    @fahadreda3060 4 роки тому +2

    Great video as usual,Thanks

  • @netraamrale3850
    @netraamrale3850 Рік тому

    Very nice explanation!!! Any more graph videos teaching traversals?

  • @marcubale
    @marcubale 3 роки тому

    Nice explanation

  • @howardchin406
    @howardchin406 Рік тому

    Thanks for the video sir! I'm glad I have finished all the basic knowledge in data structure( Of course I have done the excercise lol)

  • @diveshkumar8025
    @diveshkumar8025 3 роки тому

    Please Make Some More Videos on Graph.

  • @Tombecs50
    @Tombecs50 10 місяців тому

    Did you ever cover weighted graphs?

  • @qaisahm8144
    @qaisahm8144 3 роки тому +1

    amazing explanation, thank you very much.

  • @noornaddour8290
    @noornaddour8290 Рік тому

    Have you made a graph algorithems specific course (in python)?

  • @rajubjc6349
    @rajubjc6349 4 роки тому +1

    Hi, For the shortest path, can we just call get_paths(start, end) and return the one with the shortest length among those?

  • @mathesh5346
    @mathesh5346 3 роки тому +1

    One Doubt Sir because I am absolutely a beginner in this. Why we are creating our data in tuples first and then migrating to a dictionary. Why can't we directly declare our values in a dictionary?

  • @puneethv4138
    @puneethv4138 3 роки тому

    Pls Continue with Weighted graphs , DFS and BFS in Graphs

  • @priyankmadhur2990
    @priyankmadhur2990 4 роки тому +2

    Hi, just wanted to know that for getting the shortest path, can I just call get_path method and return the list with minimum length. And great videos very nicely explained.

    • @sabarikrishnam1485
      @sabarikrishnam1485 4 роки тому

      Yes I was thinking the same as well.

    • @mohammadkareem1187
      @mohammadkareem1187 2 роки тому

      The question is which way is more computation intense. Do you happen to find an answer to this?

  • @akshendoke450
    @akshendoke450 4 роки тому

    Excellent tutorial! good explanation very easy to understand! Thanks for creating this.

  • @younesizeria4375
    @younesizeria4375 2 роки тому

    Have a look to my code, I tried to implement it before seeing yours, then it worked then checked yours and found it hard to understand haha :
    def get_paths(self, start, end, path=[ ]):
    path = path + [start]
    if start == end:
    return [path]
    if start not in self.dict_graph:
    return [ ]
    paths = [ ]
    for node in self.dict_graph[start]:
    paths += self.get_paths(node, end, path)
    return paths
    I think mine looks clear ...

  • @RohitOturkar
    @RohitOturkar 3 місяці тому

    for weighted graphs can we just sort out the values by the weights in descending and then visit them one by one giving the highest weight the priority??

  • @dgmusicsongs
    @dgmusicsongs 4 роки тому

    love your video and waiting for more

  • @sezermezgil9304
    @sezermezgil9304 3 роки тому

    Thx for tutorial and are you going to add new videos about graph ?

  • @anirbanc88
    @anirbanc88 2 роки тому

    I was hoping for the exercise! Anyways, thank you for all your efforts, learnt a lot from you and specially those exercises, thank you sir!

  • @vidhanrathore5954
    @vidhanrathore5954 2 роки тому

    Please reply to me if you have made more videos on graph.
    I didn't find them

  • @daniel280187
    @daniel280187 4 роки тому

    What a great tutorial!! Thanks a lot for another excellent video. I've subscribed to your channel due to the quality of the content and for creating such great visualisations to help us understand these topics. Thanks for sharing.

  • @judeleon8485
    @judeleon8485 4 роки тому

    You are doing a great job. Thanks so much

  • @manishkrsingh7684
    @manishkrsingh7684 Рік тому

    It was very well explained and I liked it very much..... Well Explained
    Is there any video on BFS and DFS???

  • @soumyavats6596
    @soumyavats6596 3 роки тому

    hello sir loved your video, please let me know when the series on weighted graph and algo will come

  • @abhishekkumaryadav3647
    @abhishekkumaryadav3647 4 роки тому

    thanku sir keep uploading such videos ....loved your effort

  • @pinguzkitchen3669
    @pinguzkitchen3669 4 роки тому

    sir your series is great and you are doing such a good work for students like us :) God Bless you immensely.

    • @codebasics
      @codebasics  4 роки тому

      I am happy this was helpful to you.

  • @Gokul-eq4wm
    @Gokul-eq4wm Рік тому

    In recursion,
    For loop goes to index 1 in grap_dict, after append mum, par, dub, ny
    ...Beauty...

  • @e.w.6470
    @e.w.6470 6 місяців тому

    It's really about recursion. If you understand recursion well it's not difficult to understand otherwise it's a struggle.

  • @ramapatipatra5384
    @ramapatipatra5384 2 роки тому

    very nice

  • @danielwang4917
    @danielwang4917 3 роки тому

    Thanks for the clear video

  • @zedor1553
    @zedor1553 Рік тому

    is there any chance you could extend by adding visualization of these graphs?

  • @priyanshupurohit5431
    @priyanshupurohit5431 2 роки тому

    is it convinient to find shortest_path by first finding list of all possible paths and then fetch the element which has lowest length

  • @siddhantapuvenkatabhuvanch7597
    @siddhantapuvenkatabhuvanch7597 4 роки тому

    Missed the excericse for this Video :( Waiting for future videos on Graphs

  • @dipannita7436
    @dipannita7436 4 роки тому

    Sir please make a video on artificial intelligence coding.........
    Only for u I have understood machine learning from ur video...❤️❤️❤️🔥

  • @ayushshukla2449
    @ayushshukla2449 2 роки тому

    Thank you for your efforts. Great help!

  • @ArunKumar-yb2jn
    @ArunKumar-yb2jn 3 роки тому

    4:23 Mumbai --> Boston ---> Hartford ---> New York should be 5300, not 5120. Correct?

  • @WeakCoder
    @WeakCoder 4 роки тому

    Hey Dhaval, I hope your health's great now. Great vid, could've done with a little more theory though. cheers!

    • @codebasics
      @codebasics  4 роки тому +11

      I will upload probably 10, more tutorials on graph alone. There are many concepts to cover such graph traversal, dijikstra's algo, graph representation etc, wanted to start with something simple and cover advanced topics as we go

    • @ulrikisdahl7555
      @ulrikisdahl7555 4 роки тому

      @@codebasics Great!

  • @sameerplaynicals8790
    @sameerplaynicals8790 2 роки тому

    Can you make a Java algorithm playlist? Java is my first language that's why it's easier for me understand.

  • @QVL75
    @QVL75 2 роки тому

    Great video. Thanks!

  • @jameshuang582
    @jameshuang582 3 роки тому

    Hi I have an issue at time 11.41min of the video as I am unable to run the code on my code editor which is visual studio code. I end up getting:
    ValueError: too many values to unpack (expected 2)

  • @soumalyadas1123
    @soumalyadas1123 Рік тому

    nice one!

  • @mohammadpatel2315
    @mohammadpatel2315 3 роки тому

    When will we see more videos on graphs?

  • @meralmaradia4774
    @meralmaradia4774 2 роки тому

    Hello Sir, can you please create a video developing of project using only DSA ?

  • @pallavisrivastava2187
    @pallavisrivastava2187 3 роки тому

    Hi Dhaval, I am wondering if it is possible for you to make a Breath first search video for graph. I watched many videos on this but they don’t explain as well as you.

  • @ratulaggarwal6724
    @ratulaggarwal6724 4 роки тому +2

    Hi.. This is amazing.. Thank you for making these videos.. I just wanted to crosscheck something with you. In the get_shortest_path() method, will it be a good idea to call the get_paths() method, sort the returned list, and print the paths that have the least length?.. Or will it have any downside to it, which I might be missing..

    • @mohammadkareem1187
      @mohammadkareem1187 2 роки тому

      I have same question as well. Did you find the answer?

  • @Anilkumar-zs1hz
    @Anilkumar-zs1hz 3 роки тому +1

    Can anyone tell me the software sir used for compiling the code and debugging it? Plzs ,TThanks

    • @codebasics
      @codebasics  3 роки тому +1

      pycharm community edition. You can download it for free.. just google it

    • @carzycults6119
      @carzycults6119 3 роки тому

      @@codebasics Thanks sir!!!

  • @softsolutions6668
    @softsolutions6668 2 роки тому

    is it ok if we get shortest path using getpaths method. LIke after getting list of all paths, can I take a list which is having lesser cities

  • @anythingit2399
    @anythingit2399 2 роки тому +1

    Can anyone please explain me how shortest_path is working out here ? Unable to understand that

  • @Lynn-ye4sk
    @Lynn-ye4sk 2 роки тому

    very good!

  • @muhammedcanozdemir6447
    @muhammedcanozdemir6447 3 місяці тому

    can anyone tell me why ı do not get the correct output when I remove for loop and write "return path" instead of "return [path]" and directly append new_path

  • @chilukanand
    @chilukanand 3 роки тому

    Hey nice video buddy, thank you very much for the video!

  • @JJohnny224
    @JJohnny224 3 роки тому

    That was helpful! Thank you!

  • @siddhantpathak9405
    @siddhantpathak9405 3 роки тому

    Maaan !!! Recursion is a hard concept to wrap your head around. Please suggest some source to practice this skill.
    Thank You :>

  • @dantedt3931
    @dantedt3931 3 роки тому

    This is good.Thanks.

  • @leopromatchshows7479
    @leopromatchshows7479 4 роки тому

    Hey, It is a great tutorial. But I'm wondering why necessarily we have to create a method to find the shortest path when we can easily find it using an instance variable. For example, we could create self.shortest_path and set it to None. Then in the get_paths method, we could update it by simply finding the smallest length of the list inside the paths list. This way it would return both the paths like Mumbai-Paris_NewYork and Mumbai-Dubai-NewYork because their length is three. Also, it would make the coding a lot easier as well.

    • @austinscott1407
      @austinscott1407 3 роки тому

      self in this case is the entire graph of all nodes. To find the shortest path between two specific nodes within that graph, I don't think it makes too much sense to have an attribute self.shortest_path as you'd want to figure out the shortest path between two nodes within the graph, not the shortest path on the entire graph (Which will always be len == 1).
      But I agree that this would have been easily done by just using the get_paths method, though I'd guess he wanted to show another example of recursion for educational reasons.

  • @jiakai7254
    @jiakai7254 Рік тому

    if u nest path=[ ] within get_paths wouldnt it get reset for each recursive call?

  • @ranganathnarasappa4680
    @ranganathnarasappa4680 4 роки тому

    Hi, Nice video...do we really require "if sp:" condition to find shortest path? i tried without using that condition and i get the correct output

  • @learnerlifelong6455
    @learnerlifelong6455 4 роки тому

    Wow...looks interesting. I must be related to PERT -CPM methods of scheduling [from mathematics/Operations research]
    similarly, I found Tree data structure analogous to decision tree in ML

  • @KunalAggarwal
    @KunalAggarwal 4 роки тому

    Sir when will you complete this series of Graph ?

    • @codebasics
      @codebasics  4 роки тому +1

      It will take some time but I am on it.

  • @kamaleshmohapatra700
    @kamaleshmohapatra700 4 роки тому

    Sir how many videos will be there in this series!??