JavaScript Graph Data Structure

Share this video with your friends

Send Tweet

A graph is a data structure comprised of a set of nodes, also known as vertices, and a set of edges. Each node in a graph may point to any other node in the graph. This is very useful for things like describing networks, creating related nonhierarchical data, and as we will see in the lesson, describing the relationships within one's family.

tsvika
tsvika
~ 6 years ago

Why don't you use es6 classes?

tsvika
tsvika
~ 6 years ago

Why don't you use es6 classes?

Kyle Shevlin
Kyle Shevlin(instructor)
~ 6 years ago

No reason. Just wanted to use factory functions. Use what sparks joy 😁.

Marwan
Marwan
~ 6 years ago

I really enjoy your videos, they're unique in the sort of things you present. Most, if not all, videos i've seen talk about the same thing one way or another. This is like crossing dimensions. Thank you

Christopher Ueda
Christopher Ueda
~ 6 years ago

Really enjoyed this lesson. I didn't know what a graph was until now! I did notice a discrepancy between the use of addChildren and addNeighbor functions in both the video, the codesandbox and the transcription. I usually watch the video once then go through the transcription a second time to make sure I understood everything. It would be nice if we could do a pull request to fix up any issues we find with the transcriptions. Thanks!

jen chan
jen chan
~ 5 years ago

Same, never heard of a graph in JS and also had to rewatch the part describing directed and undirected graphs. I got it with the example though.

Marcell Ciszek
Marcell Ciszek
~ 4 years ago

Awesome course Kyle! I really like that you using functions

luca leone
luca leone
~ 4 years ago

Kyle, in the transcript section, in the addEdge method definition, I think node2.addChild(node1) should be node2.addNeighbor(node1).

luca leone
luca leone
~ 4 years ago

...also, in the print definition, children should be neighbors

Lucas Minter
Lucas Minter
~ 3 years ago

Kyle, in the transcript section, in the addEdge method definition, I think node2.addChild(node1) should be node2.addNeighbor(node1).

You are correct Luca! I've gone ahead and gotten those fixed in the transcripts. Thank you for bringing this to our attention.