Graph Data Structure | Part 7 | Weighted Directed Graph | Code & Implementation

  Рет қаралды 1,114

Nikhil Lohia

Nikhil Lohia

Күн бұрын

Chapters:
00:00 - Intro
00:43 - A quick review
02:12 - The problem with current adjacency list
04:02 - Using the GraphEdge object
05:38 - Creating adjacency list with GraphEdge
08:00 - Dry-run of Code
12:04 - Final Thoughts
📚 Links to topics I talk about in the video:
Adjacency Matrix: • Graph Data Structure |...
Adjacency List: • Graph Data Structure |...
Types of Graphs: • Graph Data Structure |...
Graphs Introduction: • Graph Data Structure |...
Complete playlist: • Graphs
📘 A text based explanation is available at: studyalgorithms.com
Code on Github: github.com/nikoo28/java-solut...
📖 Reference Books:
Starting Learn to Code: amzn.to/3sJm8Wl
Favorite book to understand algorithms: amzn.to/4848xJH
Favorite book for data structures: amzn.to/3P96YBv
Get started for interview preparation: amzn.to/44Nn5du
🔗 To see more videos like this, you can show your support on: www.buymeacoffee.com/studyalg...
🎥 My Recording Gear:
Recording Light: amzn.to/3PdsViT
Microphone: amzn.to/3Exv83x
Recording Camera: amzn.to/3PwyN8e
Tablet to sketch and draw: amzn.to/3ZdKVy7
Sketching Tool: amzn.to/45XJEgY
Laptop to edit videos: amzn.to/460ofDu
💻 Get Social 💻
Follow on Facebook at: / studyalgos
Subscribe to RSS feeds: studyalgorithms.com/feed/
Join fan mail: eepurl.com/g9Dadv
#graphs #datastructures #interview

Пікірлер: 10
@kushagraagrawal7690
@kushagraagrawal7690 7 ай бұрын
Sir, i didn't understand that why we choose to create a new object for an edge? Same can be achieved by a modified linked list node with two values i.e egde and weight. Can u clear this pls.
@nikoo28
@nikoo28 7 ай бұрын
A very good question. yes, you can modify the ListNode structure. Your node now has weight, value, next pointer. The source will always be the head node. It will work yes...but if won't remain intuitive in my opinion. Think like this, a node "A" has two neighbors "B" and "C". The adjacency list looks like: A -> B -> C gives an impression that B and C share some connection too, but that is not the case. Also, when you create edge objects, you will have more advantages when implementing complex algorithms. Coming up Prim's and Kruskal's algorithm. We can also say that we are creating a linked list, or the next pointer un-necessarily, there is no such component in the graph. On the other hand, an edge does exist in the graph. So you get a lot of benefits: - semantic clarity and readability - better code organization (Graph, GraphEdge, Vertex)..having a list node seems unnatural - graph abstraction
@kushagraagrawal7690
@kushagraagrawal7690 7 ай бұрын
@@nikoo28 thanks sir for responding.
@ved_528
@ved_528 7 ай бұрын
Thank you sir Don't stop this series ❤
@jaydeepvasoya6243
@jaydeepvasoya6243 6 ай бұрын
Bro... Your explanation skill is awnsome.
@saurabhruikar1131
@saurabhruikar1131 6 ай бұрын
Asusal very detail explanation Nikhil, Kudos!!! In GraphEdge even if we drop source and only keep destination and weight that will also work as in adjacency arr every index itself is a source. It will save some memory.
@nikoo28
@nikoo28 5 ай бұрын
You can do it, but I made the structure of GraphEdge to be extendible. There can be many use cases. You will understand more on doing the Prim's and Kruskal's algorithm
@nandhakumarkr3147
@nandhakumarkr3147 4 ай бұрын
Nice one bro , Map adjList = new HashMap(); would make more clearer and continuity of your tutorial. But thank you bro , you are so selfless and perfection in explaining.
@nikoo28
@nikoo28 4 ай бұрын
i really wish there was a commonly accepted pattern to represent a graph (like a linked list has a defined structure..value and next pointer)...graphs are usually implemented on a case by case basis.
@nandhakumarkr3147
@nandhakumarkr3147 4 ай бұрын
Ok thank you
Learn Adjacency Lists in 8 minutes 📑
8:29
Bro Code
Рет қаралды 55 М.
Как бесплатно замутить iphone 15 pro max
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 8 МЛН
Это реально работает?!
00:33
БРУНО
Рет қаралды 4,2 МЛН
Викторина от МАМЫ 🆘 | WICSUR #shorts
00:58
Бискас
Рет қаралды 5 МЛН
How To Implement a Graph in C. (adjacency matrix version)
20:04
Jacob Sorber
Рет қаралды 46 М.
Intro to Directed Graphs | Digraph Theory
13:42
Wrath of Math
Рет қаралды 40 М.
Learn Graphs in 5 minutes 🌐
5:17
Bro Code
Рет қаралды 106 М.
Adjacency Matrix in Graph Data Structure | Graph Implementation
22:09
Simple Snippets
Рет қаралды 20 М.
Max Consecutive Ones (LeetCode 1004) | Full Solution w/ animations
14:41
Implementation Of Graph In Java Using Adjacency Matrix
13:15
Genie Ashwani
Рет қаралды 2 М.
Graph Algorithms Crash Course (with Java)
1:41:11
freeCodeCamp.org
Рет қаралды 95 М.
Как бесплатно замутить iphone 15 pro max
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 8 МЛН