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

Поділитися
Вставка
  • Опубліковано 27 вер 2021
  • 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

  • @nickbarnes9966
    @nickbarnes9966 Рік тому +3

    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!

  • @sumitbhosale3401
    @sumitbhosale3401 2 роки тому +15

    You Are The Most Genius Teacher I Ever Seen. Thank You For Video.

  • @shahqu5dohcoh9ri88
    @shahqu5dohcoh9ri88 Рік тому +2

    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.

  • @leokiller123able
    @leokiller123able 2 роки тому +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 роки тому +1

      Thanks for letting me know. It's always good to hear this is making a difference to somebody.

  • @AyushSharma-ny8bm
    @AyushSharma-ny8bm 2 роки тому +5

    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😊

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

    Awesome explanation ✨✨.

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

    The best channel for c++ lo lovers

  • @user-iv2ys6pz9u
    @user-iv2ys6pz9u Рік тому +1

    I'm from Algeria and i like your channel

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

    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?

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

    How did you output the arrow symbol when printing the graph...isit a kb shortcut in VSCode?

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

    That PDF hack is very interesting..

  • @Ironypencil
    @Ironypencil 2 роки тому +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?

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

    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 роки тому +1

      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.

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

    What is the code contained in the makefile?

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

  • @dipto100
    @dipto100 2 роки тому +5

    I was wondering if you had any plans to make a video for statemachines in c.

    • @JacobSorber
      @JacobSorber  2 роки тому +6

      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.

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

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

    Hey can you make a videos of a project on (both detection and use as mass Storage) USB devices on freeRTOS ?

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

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

    When you say you have a vid check this out can u add video cards

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

    🔥🔥🔥

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

    what is the font, being used here.

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

      ua-cam.com/video/5td9upDbkaU/v-deo.html

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

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

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

    hey, why don't u use clion, considering u know cmake?

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

  • @mr.mirror1213
    @mr.mirror1213 2 роки тому +1

    2nd comment , I hope u make the other implementation like adjecency list

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

      Me too. Thanks for being here.

  • @geezgus
    @geezgus 7 місяців тому

    where the other version tho

  • @afborro
    @afborro 2 роки тому +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.

  • @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 роки тому +1

    first cmt