How To Implement a Graph in C. (adjacency matrix version)

  Рет қаралды 45,520

Jacob Sorber

Jacob Sorber

2 жыл бұрын

Patreon ➤ / jacobsorber
Courses ➤ jacobsorber.thinkific.com
Website ➤ www.jacobsorber.com
---
How To Implement a Graph in C. (adjacency matrix version) // It's another data structure video, following on that last graphs overview. Today let's get concrete and implement one. There are many ways to implement a graph. More to come, I'm sure, but today we're going to implement a graph using an adjacency matrix.
Related Videos:
Graphs Intro: • What is a Graph Data S...
2D Array/Matrix: • Working with a Matrix/...
***
Welcome! I post videos that help you learn to program and become a more confident software developer. I cover beginner-to-advanced systems topics ranging from network programming, threads, processes, operating systems, embedded systems and others. My goal is to help you get under-the-hood and better understand how computers work and how you can use them to become stronger students and more capable professional developers.
About me: I'm a computer scientist, electrical engineer, researcher, and teacher. I specialize in embedded systems, mobile computing, sensor networks, and the Internet of Things. I teach systems and networking courses at Clemson University, where I also lead the PERSIST research lab.
More about me and what I do:
www.jacobsorber.com
people.cs.clemson.edu/~jsorber/
persist.cs.clemson.edu/
To Support the Channel:
+ like, subscribe, spread the word
+ contribute via Patreon --- [ / jacobsorber ]
Source code is also available to Patreon supporters. --- [jsorber-youtube-source.heroku...]

Пікірлер: 51
@sumitbhosale3401
@sumitbhosale3401 2 жыл бұрын
You Are The Most Genius Teacher I Ever Seen. Thank You For Video.
@JacobSorber
@JacobSorber 2 жыл бұрын
You're very welcome.
@nickbarnes9966
@nickbarnes9966 Жыл бұрын
Thank you so much for going over the dot format! I went through DSA 1 and DSA 2 using C without having a way to visualize graphs. It was absolute hell. I'm glad there is a tool like this we can use in C!
@shahqu5dohcoh9ri88
@shahqu5dohcoh9ri88 Жыл бұрын
I love all your videos, in particular those about data structures! They really help. Even the embedded systems videos and those about operating systems features are great. This channel is without any doubt the best channel about C programming out there.
@AyushSharma-ny8bm
@AyushSharma-ny8bm 2 жыл бұрын
Hi Jacob, lots of love for you!🤗 Please make a tutorial for the Adjacency List version too!(for graphs) and please cover some important graph based algorithms also😊
@leokiller123able
@leokiller123able 2 жыл бұрын
Hello, I just wanted to say thank you, your videos truly helped me improve the way I code and understand some hard C topics, you're awesome 💪
@JacobSorber
@JacobSorber 2 жыл бұрын
Thanks for letting me know. It's always good to hear this is making a difference to somebody.
@namantam1
@namantam1 2 жыл бұрын
Awesome explanation ✨✨.
@growwithanshuman
@growwithanshuman 2 жыл бұрын
The best channel for c++ lo lovers
@user-iv2ys6pz9u
@user-iv2ys6pz9u Жыл бұрын
I'm from Algeria and i like your channel
@laurenharrison8909
@laurenharrison8909 2 жыл бұрын
Your video has been so helpful thank you! I was just wondering how you would get it to turn information from a textfile that contains letters and numbers into a graph? Thank you
@Shivnaren
@Shivnaren Жыл бұрын
Hi Jacob, big fan-many thanks for all the videos and knowledge. One suggestion/feedback-minimizing the terminal and collapsing the File explorer when they're not in use would increase screen space significantly. I know we use the terminal a lot, but there are keybindings to toggle UI elements, so we could probably toggle them when needed?
@Ironypencil
@Ironypencil 2 жыл бұрын
Hey, I've seen some of your videos and your plosive sounds (s, t, ch etc.) sometimes sound really harsh. Do you use a pop filter?
@gerdsfargen6687
@gerdsfargen6687 Жыл бұрын
How did you output the arrow symbol when printing the graph...isit a kb shortcut in VSCode?
@echoptic775
@echoptic775 2 жыл бұрын
Hello, i love watching your videos, i watched all of them :), and im wondering what do u think about rust? Did u hear about it? Also what languages do u use? Is it only c?
@judedavis92
@judedavis92 2 жыл бұрын
Lol another rust fanboy
@Anubis10110
@Anubis10110 2 жыл бұрын
That PDF hack is very interesting..
@dipto100
@dipto100 2 жыл бұрын
I was wondering if you had any plans to make a video for statemachines in c.
@JacobSorber
@JacobSorber 2 жыл бұрын
Well, I do now. 😀I'll add it to the list and see what I can come up with.
@dipto100
@dipto100 2 жыл бұрын
@@JacobSorber That would be so awesome. Thanks for these great tutorials.
@dariokartal9453
@dariokartal9453 2 жыл бұрын
I too am itching to see that.
@cprogramming5640
@cprogramming5640 2 жыл бұрын
What is the conventional use of asserts? You mentioned that they are useful ways to catch bugs early, which makes sense, but I am wondering if they are removed or left in a release version of software? Thank you for an interesting video. Love your not equal to symbol.
@benjaminshinar9509
@benjaminshinar9509 2 жыл бұрын
asserts only run in -DEBUG relase, they aren't present in release modes, this is handled by the compiler. when i was learning C, i made aa habit of sticking asserts at the start of each function, the more the better. it helps you be sure that the object is in the state you think it is. and it also helps catching off by one bugs.
@deepakkkumarvctdept4726
@deepakkkumarvctdept4726 Жыл бұрын
🔥🔥🔥
@visyuvi
@visyuvi Жыл бұрын
Hey can you make a videos of a project on (both detection and use as mass Storage) USB devices on freeRTOS ?
@bolvarsdad3825
@bolvarsdad3825 Жыл бұрын
The Calloc specification says it takes two size_t, one of which is satisfied when you pass sizeof(...) to it but the other element you're passing is of type int from the graph->numnodes. Does this not matter? I know size_t is unsigned so I feel some issues might arise when you give a signed datatype from your graph struct to a function that expects an unsigned.
@dameck9570
@dameck9570 Жыл бұрын
It will not be a Problem since the binary representation of positive number in two's-complement (signed) and unsigned binary is identical. If you were to pass a negative number you are most likely to allocate a lot of memory
@mariusiordan5421
@mariusiordan5421 Жыл бұрын
What is the code contained in the makefile?
@chesster5981
@chesster5981 Жыл бұрын
When you say you have a vid check this out can u add video cards
@dibyojyotibhattacherjee4279
@dibyojyotibhattacherjee4279 2 жыл бұрын
what is the font, being used here.
@ncooprider
@ncooprider 2 жыл бұрын
kzbin.info/www/bejne/a6XHaqimeceel7c
@flamendless
@flamendless 2 жыл бұрын
Where can i find that dot tool?
@JacobSorber
@JacobSorber 2 жыл бұрын
It's part of the graphviz package. A quick web search should find it.
@ChrisBNisbet
@ChrisBNisbet 2 жыл бұрын
FYI - no need to check if ptr != NULL before calling free, as free() deals with NULL ptr itself. From the manpage for free... "If ptr is NULL, no operation is performed".
@mr.mirror1213
@mr.mirror1213 2 жыл бұрын
2nd comment , I hope u make the other implementation like adjecency list
@JacobSorber
@JacobSorber 2 жыл бұрын
Me too. Thanks for being here.
@dibyojyotibhattacherjee4279
@dibyojyotibhattacherjee4279 2 жыл бұрын
hey, why don't u use clion, considering u know cmake?
@abdullahalattar5642
@abdullahalattar5642 2 жыл бұрын
Why would he use it
@Tawre007
@Tawre007 2 жыл бұрын
In this way it's more accessible to everyone, clion is great but not free software.
@dibyojyotibhattacherjee4279
@dibyojyotibhattacherjee4279 2 жыл бұрын
@@Tawre007 Thanks man, I understood my mistake
@VinayagaMotorsTsy
@VinayagaMotorsTsy 2 жыл бұрын
Bro can we add the weight of edges
@JacobSorber
@JacobSorber 2 жыл бұрын
Of course. Add all of the weights you like
@VinayagaMotorsTsy
@VinayagaMotorsTsy 2 жыл бұрын
@@JacobSorber how to add weight sir which function
@geezgus
@geezgus 7 ай бұрын
where the other version tho
@afborro
@afborro 2 жыл бұрын
boost libraries FTW do all this to a much more sophisticated level. An art in programming is not to reinvent the wheel and create all the bugs that were create before. okay, kinda facetious, but true ;) This is why we love the rich libraries in C++. These kind of constructs are a mine field in plain C with mallocs and frees all over the place. Been there, done that. Never again. I've enjoyed the series to remind me why I moved on from C to C++, let it be a reminder to anyone else. I see so much/too much reinvented code in C libraries all the time. People shouldn't have to write trees, linked lists 10 times over. Do it once as a learning exercise in C and than never again; This is why I have an aversion to C these days, because of it's "at first apparent simplicity",in the long run it'll bite you, because everything takes ages, so I realised the learning curve for C++ was well worth it. The difference is huge. It took many years to be convinced though.
@gerdsfargen6687
@gerdsfargen6687 Жыл бұрын
get your hand off it bro.
@zach990il4
@zach990il4 2 жыл бұрын
12:50 but you do the opposite of what you say arent you ? you free each row and then you free the matrix I DONT GET IT!!!
@sverkeren
@sverkeren Жыл бұрын
Ha said "before you free" but must have meant "after you free".
@ismaelgalvez1453
@ismaelgalvez1453 Ай бұрын
ok but with librarys zzzz
@shrek1412
@shrek1412 2 жыл бұрын
first cmt
How Memory Usage Slows Down Your Programs
9:17
Jacob Sorber
Рет қаралды 19 М.
What's the Best Way to Copy a Struct in C and C++?
13:44
Jacob Sorber
Рет қаралды 33 М.
THE POLICE TAKES ME! feat @PANDAGIRLOFFICIAL #shorts
00:31
PANDA BOI
Рет қаралды 24 МЛН
Learn Adjacency Matrix in 10 minutes ⬜
9:52
Bro Code
Рет қаралды 48 М.
How to Implement a Tree in C
14:39
Jacob Sorber
Рет қаралды 92 М.
Data structures: Introduction to graphs
16:43
mycodeschool
Рет қаралды 958 М.
Make your Data Type more Abstract with Opaque Types in C
13:41
Jacob Sorber
Рет қаралды 48 М.
Should you learn C++?? | Prime Reacts
20:29
ThePrimeTime
Рет қаралды 329 М.
4 things people with mental illness do without thinking
16:49
Dr. Scott Eilers
Рет қаралды 32 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 617 М.
Making variables atomic in C
11:12
Jacob Sorber
Рет қаралды 35 М.