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

In this video we will go over the introduction of graph data structure in python. There are two types of graphs,
(1) Directed: There is a direction in the way two nodes are connected. Example is flight routes between two cities.
(2) Undirected: There is no direction to how two nodes in the graph are connected. Example is Facebook connections.
Other applications are google map, computer connections in internet or private network, amazon product recommendations etc.
Code: github.com/codebasics/data-st...
Do you want to learn technology from me? Check codebasics.io/?... for my affordable video courses.
Image credit attribution:
World wide web photo downloaded from freepik.com. Here is the attribution for it.
a href="www.freepik.com/vectors/business" Business vector created by macrovector - www.freepik.com
#graph #datastructures #algorithms #python
Next Video: • Binary Search - Data S...
Previous video: • Binary Tree Part 2 | B...
Complete playlist: • Data Structures And Al...
🌎 My Website For Video Courses: codebasics.io/?...
Need help building software or data analytics and AI solutions? My company www.atliq.com/ can help. Click on the Contact button on that website.
#️⃣ Social Media #️⃣
🔗 Discord: / discord
📸 Dhaval's Personal Instagram: / dhavalsays
📸 Instagram: / codebasicshub
🔊 Facebook: / codebasicshub
📝 Linkedin (Personal): / dhavalsays
📝 Linkedin (Codebasics): / codebasics
📱 Twitter: / codebasicshub
🔗 Patreon: www.patreon.com/codebasics?fa...

Пікірлер: 179

  • @codebasics
    @codebasics2 жыл бұрын

    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

  • @etorty_dev
    @etorty_dev3 жыл бұрын

    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.

  • @tusharpatne6863
    @tusharpatne68634 жыл бұрын

    Sir, please make a playlist on Algorithms with Python.

  • @Rahul_1.618
    @Rahul_1.6188 ай бұрын

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

  • @turjo119
    @turjo1193 жыл бұрын

    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.

  • @ultronhack8151

    @ultronhack8151

    3 жыл бұрын

    parben apni inshallah

  • @19_kartikaswal19
    @19_kartikaswal194 жыл бұрын

    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 жыл бұрын

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

  • @BcomingHIM
    @BcomingHIM4 жыл бұрын

    love this playlist. Keep continuing this!. Thank you

  • @sayantanisaha
    @sayantanisaha3 жыл бұрын

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

  • @awsomeslayer1
    @awsomeslayer13 жыл бұрын

    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.

  • @codebasics

    @codebasics

    3 жыл бұрын

    👍🙏

  • @entity5678
    @entity56785 ай бұрын

    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..

  • @aaronaaronaaron5922
    @aaronaaronaaron59223 жыл бұрын

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

  • @chiragmiskin7239
    @chiragmiskin72393 жыл бұрын

    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?

  • @pranavwarke1966
    @pranavwarke19663 жыл бұрын

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

  • @codebasics

    @codebasics

    3 жыл бұрын

    Glad it was helpful!

  • @rameshthamizhselvan2458
    @rameshthamizhselvan24583 жыл бұрын

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

  • @daniel280187
    @daniel2801873 жыл бұрын

    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.

  • @codebasics

    @codebasics

    3 жыл бұрын

    Thanks for the sub!

  • @judeleon8485
    @judeleon84853 жыл бұрын

    You are doing a great job. Thanks so much

  • @ayushshukla2449
    @ayushshukla24492 жыл бұрын

    Thank you for your efforts. Great help!

  • @MrJouH4
    @MrJouH42 жыл бұрын

    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.

  • @sagardhiman4337
    @sagardhiman433710 ай бұрын

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

  • @fahadreda3060
    @fahadreda30604 жыл бұрын

    Great video as usual,Thanks

  • @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)

  • @dgmusicsongs
    @dgmusicsongs4 жыл бұрын

    love your video and waiting for more

  • @abhishekkumaryadav3647
    @abhishekkumaryadav36474 жыл бұрын

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

  • @anirbanc88
    @anirbanc882 жыл бұрын

    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!

  • @akshendoke450
    @akshendoke4503 жыл бұрын

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

  • @codebasics

    @codebasics

    3 жыл бұрын

    😊👍

  • @QVL75
    @QVL75 Жыл бұрын

    Great video. Thanks!

  • @mr_californian
    @mr_californian Жыл бұрын

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

  • @kasrayazdani8628
    @kasrayazdani86282 жыл бұрын

    Nicely explained.

  • @deepikapatra1065
    @deepikapatra10653 жыл бұрын

    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

    3 жыл бұрын

    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! 👍

  • @ExplorerDheeraj9271
    @ExplorerDheeraj92713 жыл бұрын

    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...❤️❤️

  • @codebasics

    @codebasics

    3 жыл бұрын

    Thanks and welcome

  • @user-mq7xq1hi2q
    @user-mq7xq1hi2q2 жыл бұрын

    Thanks for tutorial!

  • @thammayyaarava2259
    @thammayyaarava22592 жыл бұрын

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

  • @codebasics

    @codebasics

    2 жыл бұрын

    Glad it was helpful!

  • @faisalabdulkadir9439

    @faisalabdulkadir9439

    2 жыл бұрын

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

  • @manideep6814
    @manideep68142 жыл бұрын

    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

    5 ай бұрын

    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

  • @pinguzkitchen3669
    @pinguzkitchen36693 жыл бұрын

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

  • @codebasics

    @codebasics

    3 жыл бұрын

    I am happy this was helpful to you.

  • @JJohnny224
    @JJohnny2242 жыл бұрын

    That was helpful! Thank you!

  • @codebasics

    @codebasics

    2 жыл бұрын

    Glad it was helpful!

  • @vishwasrchonu7134
    @vishwasrchonu71346 ай бұрын

    best DS tutorials 💯💯

  • @qaisahm8144
    @qaisahm81443 жыл бұрын

    amazing explanation, thank you very much.

  • @codebasics

    @codebasics

    3 жыл бұрын

    Glad it was helpful!

  • @ganesh.majety5260
    @ganesh.majety52603 жыл бұрын

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

  • @codebasics

    @codebasics

    3 жыл бұрын

    sure i will add algo videos

  • @vidhanrathore5954
    @vidhanrathore59542 жыл бұрын

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

  • @rajubjc6349
    @rajubjc63493 жыл бұрын

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

  • @danielwang4917
    @danielwang49173 жыл бұрын

    Thanks for the clear video

  • @codebasics

    @codebasics

    3 жыл бұрын

    Glad it was helpful!

  • @sachinmaurya3259
    @sachinmaurya32593 жыл бұрын

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

  • @samjebaraj24

    @samjebaraj24

    3 жыл бұрын

    Mauj kardi

  • @Lynn-ye4sk
    @Lynn-ye4sk Жыл бұрын

    very good!

  • @learningwithjuce
    @learningwithjuce3 жыл бұрын

    Thank you for breaking it all down clearly

  • @codebasics

    @codebasics

    3 жыл бұрын

    ☺️👍

  • @ujjwal4441
    @ujjwal44413 жыл бұрын

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

  • @manishkrsingh7684
    @manishkrsingh7684 Жыл бұрын

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

  • @soumalyadas1123
    @soumalyadas1123 Жыл бұрын

    nice one!

  • @chilukanand
    @chilukanand3 жыл бұрын

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

  • @codebasics

    @codebasics

    3 жыл бұрын

    Glad you liked it!

  • @learnerlifelong6455
    @learnerlifelong64553 жыл бұрын

    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

  • @dantedt3931
    @dantedt39312 жыл бұрын

    This is good.Thanks.

  • @codebasics

    @codebasics

    2 жыл бұрын

    Glad you like it!

  • @soumyavats6596
    @soumyavats65963 жыл бұрын

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

  • @ranganathnarasappa4680
    @ranganathnarasappa46803 жыл бұрын

    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

  • @siddhantapuvenkatabhuvanch7597
    @siddhantapuvenkatabhuvanch75973 жыл бұрын

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

  • @ileanawilson610
    @ileanawilson6103 жыл бұрын

    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

    3 жыл бұрын

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

  • @netraamrale3850
    @netraamrale3850 Жыл бұрын

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

  • @hassanmoussa4433
    @hassanmoussa4433 Жыл бұрын

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

  • @hshrestha2811
    @hshrestha28112 жыл бұрын

    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?

  • @Abhishek-jh9lz
    @Abhishek-jh9lz8 ай бұрын

    Great Educational content ❤

  • @codebasics

    @codebasics

    8 ай бұрын

    I am happy this was helpful to you.

  • @moviemania1021
    @moviemania10213 жыл бұрын

    Sir i'm new in your youtube channel and found your videos really helpful and informative... But sir i wanna a request to you that is i'm so much interested in competitive programming and solving algorithms so can you plz make a video on that it will be really helpful if you do Btw thanks for this awesome videos :)

  • @ExeArjuna
    @ExeArjuna3 жыл бұрын

    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?

  • @pushkargoyal4278
    @pushkargoyal42783 жыл бұрын

    you are great

  • @marcubale
    @marcubale3 жыл бұрын

    Nice explanation

  • @ramapatipatra5384
    @ramapatipatra53842 жыл бұрын

    very nice

  • @WeakCoder
    @WeakCoder4 жыл бұрын

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

  • @codebasics

    @codebasics

    4 жыл бұрын

    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

    3 жыл бұрын

    @@codebasics Great!

  • @mathesh5346
    @mathesh53463 жыл бұрын

    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?

  • @ratulaggarwal6724
    @ratulaggarwal67243 жыл бұрын

    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?

  • @priyanshupurohit5431
    @priyanshupurohit5431 Жыл бұрын

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

  • @ArunKumar-lb5jr
    @ArunKumar-lb5jr2 жыл бұрын

    thanks

  • @kavandalal
    @kavandalal2 жыл бұрын

    Waiting for more videos on graphs

  • @siddharthsinghh
    @siddharthsinghh2 жыл бұрын

    Sir please make all further videos related to the graph

  • @dipannita7436
    @dipannita74364 жыл бұрын

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

  • @vinospubgdairies235
    @vinospubgdairies2353 жыл бұрын

    I need one help from u sir, in this code I need to get all the shortest path from source to destination

  • @diveshkumar8025
    @diveshkumar80253 жыл бұрын

    Please Make Some More Videos on Graph.

  • @puneethv4138
    @puneethv41382 жыл бұрын

    Pls Continue with Weighted graphs , DFS and BFS in Graphs

  • @SENAPATIENTERTAINMENT
    @SENAPATIENTERTAINMENT2 жыл бұрын

    More graph videos please 🙏

  • @jiakai7254
    @jiakai7254 Жыл бұрын

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

  • @anythingit2399
    @anythingit23992 жыл бұрын

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

  • @softsolutions6668
    @softsolutions66682 жыл бұрын

    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

  • @zedor1553
    @zedor1553 Жыл бұрын

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

  • @gozdeyzgngl
    @gozdeyzgngl Жыл бұрын

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

  • @sezermezgil9304
    @sezermezgil93043 жыл бұрын

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

  • @noornaddour8290
    @noornaddour829011 ай бұрын

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

  • @meralmaradia4774
    @meralmaradia47742 жыл бұрын

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

  • @jiakai7254
    @jiakai7254 Жыл бұрын

    for shortest_path is it inefficient if u just use min(get_paths ... , key=len)

  • @sameerplaynicals8790
    @sameerplaynicals87902 жыл бұрын

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

  • @jameshuang582
    @jameshuang5822 жыл бұрын

    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)

  • @vidhanrathore5954
    @vidhanrathore59542 жыл бұрын

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

  • @ethanhunt8493
    @ethanhunt8493 Жыл бұрын

    Sir jald bhut sare problem ke saath bnaiye video

  • @afrozkhan.
    @afrozkhan.4 жыл бұрын

    Can you suggest me laptop confirmation for learning data analytics....

  • @Tombecs50
    @Tombecs505 ай бұрын

    Did you ever cover weighted graphs?

  • @priyankmadhur2990
    @priyankmadhur29903 жыл бұрын

    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

    3 жыл бұрын

    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?

  • @sarveshbagwe8194
    @sarveshbagwe81942 жыл бұрын

    Thank you for providing such useful content for Non-CS background learners. I want to suggest one edit in a code that is in the get_path() using for loop for appending p from new_paths to paths(list) can't we directly use paths = paths+new_paths and then return paths it might decrease the time complexity as there will be addition operation to list instead of nested for loops in get_path function reducing the time complexity.

  • @sarveshbagwe8194

    @sarveshbagwe8194

    2 жыл бұрын

    edit I tried to calculate the time required to execute both the codes: Actual code time = 0.000984668 Suggested code time = 0.0007658 P.S I am not criticizing just asking as I have learned about time complexity from your tutorials only.

  • @siddhantpathak9405
    @siddhantpathak94052 жыл бұрын

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

  • @mrbreeze9116
    @mrbreeze9116 Жыл бұрын

    Can I use djikstra algorithm with this format?

  • @kundantutorials4929
    @kundantutorials49294 жыл бұрын

    Can graph and tree can made without class

  • @kamaleshmohapatra700
    @kamaleshmohapatra7004 жыл бұрын

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

  • @e.w.6470
    @e.w.6470Ай бұрын

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

  • @younesizeria4375
    @younesizeria4375 Жыл бұрын

    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 ...

  • @prithvijali2629
    @prithvijali26292 жыл бұрын

    Hi Grate video. I think the code to getpaths needs one small change to accommodate paths between 'newyork' and 'torento'. path=path+[start] # if start not in self.graphs_dict: # return [] if start==end: return [path] paths=[] if start in self.graphs_dict: for node in self.graphs_dict[start]: if node not in path: new_paths=self.paths(node,end,path) for i in new_paths: paths.append(i) return paths Please correct me if am wrong. Thanks in advance

  • @vaibhavmathur6216
    @vaibhavmathur62163 жыл бұрын

    Sir, please complete this playlist.