6.11 Connected Components |How to find Connected Components in Graph | Graph Theory

Поделиться
HTML-код
  • Опубликовано: 26 дек 2024

Комментарии • 119

  • @RobertMacwan-nr8sb
    @RobertMacwan-nr8sb 7 месяцев назад +4

    thanks so much, cant thank you enough, i was struggeling with this problem for almost a whole day and now when you explained the whole algo it got so easy for me

  • @sandipanghosh4429
    @sandipanghosh4429 2 года назад +3

    Your videos are super cool. You are the one who makes things to understand easily.

  • @bhaskargg6018
    @bhaskargg6018 4 года назад +6

    Hi Madam, your explanation on the topic is crystal clear, thanks a lot for sharing your knowledge

  • @RahulKumar-tg5zb
    @RahulKumar-tg5zb 5 лет назад +8

    U nailed it .
    A big thumbs up for ur effort 👌🙏

  • @ShyamKumar-zy2ei
    @ShyamKumar-zy2ei 8 месяцев назад +2

    Very simple and effective explanation. Thanks

  • @tavwalt1973
    @tavwalt1973 Год назад +2

    Awesome work, your videos are so clear.

  • @swadhindas2208
    @swadhindas2208 3 года назад +7

    14:25 I have doubt. Every time, it is not the case; each connected component is in proper order. Let 3 connected components are {0,1,8,9};{2,3,7};{4,5,6} for 10 vertex. So, if v becomes 9 after the first component, how will it process the next two components?

  • @HemaChowdhury-i4v
    @HemaChowdhury-i4v Месяц назад +1

    Your class been made me to score full marks

  • @abhishekyadav7056
    @abhishekyadav7056 4 года назад +9

    Mam please explain what about v's value how is this incrementing on both sides because you have called dfs by calling it by value but not by reference

    • @aviroxi
      @aviroxi 3 года назад

      send it by reference then by using pointer

  • @manjulapriyadarshini886
    @manjulapriyadarshini886 4 года назад

    Mam the way u r teaching is really really amazing....mam keep doing the vedioes for us....thank u soo much for helping everyone like this....keep smiling mam🙂🙂🙂it tends u to look more beautiful..God bless u mam.I don't have any words to explain how amazing u are..

  • @sarthakjohnsonprasad3909
    @sarthakjohnsonprasad3909 5 лет назад +7

    Ma'am , your method works for undirected graphs,but we cant apply the same for directed ones.I think you should make a seperate video for it.

  • @stellinjohn3994
    @stellinjohn3994 Год назад +3

    I think there are some issues with the code, but I can understand the idea ma'am was try to tell.
    Since DFS is used the vertices will be stored in the form of stack and they will enter one by one and when retraced the DFS fuction will exit and go back to connected component function, where count will be incremented and give you the number of componets . another thing to note here is that the 'u' ma'am has used here in order to acces the next element in the stack(the adjacent vertex) the index has to increment so that should be included.

    • @raazkumawat4896
      @raazkumawat4896 Месяц назад

      You got the error in this code bro congratulations 🤗🤗

  • @saritakumari-oh8fs
    @saritakumari-oh8fs 4 года назад

    Best explanation of conditional loop

  • @abhitailor7325
    @abhitailor7325 4 года назад +5

    Ma'am please continue DBMS , operating systems playlist ....

  • @DrakeHDxgaming
    @DrakeHDxgaming 10 месяцев назад

    hit the nail on the head with the step by step process of explaining how the code works .Might i say, is that code snippet java or c++ ?

  • @taihatranduc8613
    @taihatranduc8613 4 года назад

    Thank you a lot. Your video is worth 6 hours of mine reading documents

  • @VinodGaming15
    @VinodGaming15 5 лет назад +6

    Mam make a video on strongly connected components

  • @reetaindal9367
    @reetaindal9367 4 года назад

    Mam ur all videos are awesome and very useful . Plz make videos on computer networking ..

  • @azadalishah2966
    @azadalishah2966 4 года назад +27

    🧐When DFS() calls return back v is never increased as v was passed as local variable. Still it shud work but u shud make flag as global or pass as reference

    • @YogeshKumar-bs9cd
      @YogeshKumar-bs9cd 3 года назад

      yes

    • @diptamoy12
      @diptamoy12 2 года назад +1

      Pls provide code

    • @prakharsinha6915
      @prakharsinha6915 2 года назад +1

      True...I also realised the same, v should be declared globally then or it must be static in DFS function...or we can do one thing
      We can declare some variable say x globally and with each call of DFS we can store this value of v in this x
      and obviously in connected components function we have to initiate loop with x=0;

  • @dheerajnemalikanti3703
    @dheerajnemalikanti3703 5 лет назад +1

    very clear explanation didi. Also make videos on competitive programming

  • @rahulchouhan9696
    @rahulchouhan9696 5 лет назад +1

    Good Explanations, love it but you should make another video foe directed graphs 😍

  • @Thammudu_____
    @Thammudu_____ 3 года назад

    Mam u r explanation is super but we r not able to concentrate on topic because of u r beauty

  • @sneh9817
    @sneh9817 5 лет назад +20

    If Jenna Fischer was indian

  • @kumaraustin316
    @kumaraustin316 5 лет назад +3

    Hello mam. Just a question? How will v directly be 4 after calling dfs for 1st component?
    When the control again passes to the for loop of connected function , wont it have a separate value of v (0 here )? as methods will maintain a separate copy of v? So wont it be initialised to 1?
    Then from v = 1 to 3 as the value of flag[v] = 1 it wont call dfs and for v = 4, as flag[v] = -1 , it will call dfs(4,-1) ?

    • @JennyslecturesCSIT
      @JennyslecturesCSIT  5 лет назад +3

      when control passes to for loop again then it will go to v++ not v=0.... that is working of for loop.....
      for(initialization; condition; increment/decrement).. here firstly control go to initialization part then check the condition and if the condition is true then control will go within for loop and after executing all the statements written within for loop body the control will go to increment/decrement part...(not again to initialization part)..

    • @kumaraustin316
      @kumaraustin316 5 лет назад

      @@JennyslecturesCSIT thank you mam

    • @piyush460
      @piyush460 4 года назад

      @@JennyslecturesCSIT mam but won't the value of v in the connected comments function be different to the one in DFS function?

    • @rupeshchamon
      @rupeshchamon 3 года назад

      @@JennyslecturesCSIT How can we access the variable v value which Is inside the DFS function directly from the for loop without returning it? From the video it seemed the for loop is going to iterate just 3 times...which should not be the case...I beleive it will iterate 9 times... but DFS function will be called just 3 times

    • @rupeshchamon
      @rupeshchamon 3 года назад +1

      @@JennyslecturesCSIT One more point is will the same code be working for vertices having any random integer value? Is the prerequisite is that the vertices has to start from 0 and gets incremented by 1

  • @pulkitsingh2724
    @pulkitsingh2724 2 года назад +1

    Lv u mam ❤️

  • @souravkumardas8905
    @souravkumardas8905 5 лет назад +1

    Thank you so much. So helpful video.😊

  • @subham-raj
    @subham-raj 5 лет назад +3

    In the first DFS recursive call when 0 is root then DFS(1,flag) and DFS(3,flag) will be in call stack and you only showed DFS(1,flag) :)

  • @csedepartment236
    @csedepartment236 2 года назад

    Thank You Ma'am

  • @oalidjunayed
    @oalidjunayed 5 лет назад

    Loved it, helped me for one of my assignment, nicely explained
    ❤️❤️

  • @NoobMaster-ub5ls
    @NoobMaster-ub5ls 3 года назад

    14:09 ma'am vo uske parent function m kaise update ho jayega. Vo sirf locally hi update hoga na. Ye bolo ki flag[v] ne 3 tak sabki value -1 kar di isliye vo skip skip karke 4 par aa jayga.

  • @mayanksharma5920
    @mayanksharma5920 5 лет назад +1

    Very nice video, have you coms across competitive programming

  • @AsadullahFarooqi-w8v
    @AsadullahFarooqi-w8v 3 месяца назад

    mam in flag[u] we know that it is the adjacent vertex of v graphically but how can we write in program because u is unknown not even declared?

  • @ashutoshkumaranshu080
    @ashutoshkumaranshu080 5 лет назад +2

    But ma'am what if such graph given in which all nodes with each other then how to solve it

    • @omprakashsharma9767
      @omprakashsharma9767 4 года назад

      there is just one connected component that is called strongly connected component

  • @raazkumawat4896
    @raazkumawat4896 Месяц назад

    Mam what will happen if in dfs function there is if statement would be fail if one of adjacent flag value 1 then it will come out from the dfs function and increase count value by one but we know there is other adjacent that value is -1 it may be some error in code I think isn't mam?

  • @mrinalkumar3976
    @mrinalkumar3976 4 года назад

    Nicely Explained, Thanks a lot . Can you please upload Tarjen's Algo for directed graph also. It is difficult to understand.

  • @saisravani2625
    @saisravani2625 3 года назад

    pls make a video for directed graph also on this topic

  • @javaInBlood
    @javaInBlood 4 года назад +1

    'v' is local to the the for loop and and you are passing v by value not by reference so it make no how v value directly jump from 1 to 4.
    If you read this cmd plz rpy

    • @kudi-kon-nachdi
      @kudi-kon-nachdi 4 года назад

      Kumar Iyer's comment below. Read that dude

  • @rajeshprajapati4863
    @rajeshprajapati4863 2 года назад

    this algorithm will give strongly connected components ? i think it will give weakly connected components. Right ?

  • @adhirajchattopadhyay630
    @adhirajchattopadhyay630 3 года назад

    Ma'am, If I have doubts, do you have a separate Avenue( mail/ website) where I can doubts to you ?

  • @pavankolli4490
    @pavankolli4490 2 года назад

    What is the need to pass flag variable in DFS function

  • @dd9484
    @dd9484 3 года назад

    the global variable flag[u] = -1 at first? how does it take the adjacent vertices?

  • @deepikagoyal07
    @deepikagoyal07 2 года назад

    V is being passed by reference, that's why its getting updated in the calling function.

  • @saritakumari-oh8fs
    @saritakumari-oh8fs 4 года назад

    You are genious

  • @syedhassan9944
    @syedhassan9944 5 лет назад +1

    strongly connected component and connected component is the same thing, right?

  • @philipherweling3856
    @philipherweling3856 4 года назад

    could you use a for loop instead of a for each loop? and what would the for loop look like?

  • @TanguturiSrinivasulu
    @TanguturiSrinivasulu 3 месяца назад

    Can you explain about the biconnected component ma'am

  • @TonyTheCoder
    @TonyTheCoder Год назад

    EXCELLENT!!!

  • @asimabatool8787
    @asimabatool8787 3 года назад

    Thank you so much
    Love you from pakistan

  • @allyouinfotech7936
    @allyouinfotech7936 2 года назад

    but how the value of v is increased after returning from the dfs ,flag must ble declare globally

  • @OhhOmni
    @OhhOmni 5 лет назад +4

    Can someone please explain how I can find each adjacent node? Would an adjacency list be required?

    • @yashgupta2080
      @yashgupta2080 4 года назад +1

      Look we need to maintain adjacency matrix or list for that. For an adjacency matrix you need to find that row (which represents the node) and find if there's any available path from that node to any other node and if there's one we need to check whether that node is still unvisited. If both the conditions satisfy we return that number column stating that theres a path available from that row to that column.

  • @vamsiksk912
    @vamsiksk912 5 лет назад

    Did you pass "flag" as an array or as a variable

  • @__SHRAVANIPACHUNURI
    @__SHRAVANIPACHUNURI 3 года назад

    Mam is it necessary to have the values in ascending order..inorder to have connecting components..?

  • @rohitsai806
    @rohitsai806 5 лет назад

    Will this work if connected components are not in order?

  • @mohan4973
    @mohan4973 5 лет назад +1

    Will it work in directed graph!?

  • @lifehacks9450
    @lifehacks9450 4 года назад

    pls upload vedio on articulation points

  • @arunajagtap2834
    @arunajagtap2834 3 года назад

    Just awesome

  • @vanshikamehrotra8420
    @vanshikamehrotra8420 4 года назад

    Mam can you make video on strongly connected component

  • @shubhamshende626
    @shubhamshende626 4 года назад +7

    You declared variable V locally in for loop, it should be global.

    • @shubhamshende626
      @shubhamshende626 4 года назад

      @code fire still scope matters in pseudo code

  • @hometvfirestick
    @hometvfirestick 3 года назад

    very nice

  • @amrosherif203
    @amrosherif203 4 года назад

    what is the time complexty of this algorithm ?

  • @SujeetYadav-vw4lk
    @SujeetYadav-vw4lk 3 года назад +7

    Love you mam

  • @yuewu3888
    @yuewu3888 4 года назад

    Thank you

  • @prematulasi6821
    @prematulasi6821 5 лет назад

    hi mam nice video but i have a doubt since u have taken vertices number in ascending order algorithm is working but suppose if the vertices numbers are jumbled than will tis work

    • @prematulasi6821
      @prematulasi6821 5 лет назад

      mam iam waiting for ur r
      eply

    • @Ballsbla
      @Ballsbla 5 лет назад +1

      @@prematulasi6821 actually she explained wrong, if u use this same algo she wrote will be ok, the thing is she said v is updated as we backtrack, v=4 its not, cause we are not saving v=DFS(v,flag). we do not do it, so basically as backtracts, v=1-2-3-4(gets -1 enters loop)

    • @JennyslecturesCSIT
      @JennyslecturesCSIT  5 лет назад +2

      @@prematulasi6821 definitely....but here i have just explained the algorithm not proper code. to convert it into code you will have to work hard as it is not as simple as this algorithm looks like.

    • @teetanrobotics5363
      @teetanrobotics5363 5 лет назад

      @@Ballsbla Well said

    • @heystranger5866
      @heystranger5866 4 года назад

      @@JennyslecturesCSIT dhokha.... I shouldn't have seen this comment

  • @chandanverma5179
    @chandanverma5179 2 года назад

    What's going on ma'am in this DSA series i have been watching this from starting u didn't write code in any type of tree but in this u write and that is too in c++ what is this can anyone explain me..

  • @nareshkuruba5094
    @nareshkuruba5094 4 года назад

    madam make videos on gate questions on all topics

  • @sampath1215
    @sampath1215 5 лет назад

    at 9.15 it is flag array, not flag = -1(small correction).

  • @anurajyendhe5981
    @anurajyendhe5981 2 года назад

    How to find strongly connected components of the following graph

  • @-ShubhamBansal
    @-ShubhamBansal 4 года назад

    Thank

  • @harshsegyan
    @harshsegyan 2 месяца назад

    v apne dfs me update kar dia , apan ne pointer thodi pas kiya tha v one by one update hoga v=2,3 value par if ke andhar nahi jayega

    • @harshsegyan
      @harshsegyan 2 месяца назад

      but samaj a gay thank you mammm , love u mam

  • @kumbharaaftab555
    @kumbharaaftab555 3 года назад

    Aapk@ classes??

  • @kamalkishore1075
    @kamalkishore1075 4 года назад

    Hey , mam I just saw your video and raised a doubt . My doubt is that you have taken vertices as 1,2,3... And taken a for loop where the v++ is increasing . If we take vertices as a,b,c... Then how the for loop will be operated ...
    And one more doubt , if the node traversal you shown 1-2-3-4 and increased v to 5 in the loop will be like 1-4-3-2 then what will be the vertices after the loop executed ones ?

  • @samiulislamdurjoy
    @samiulislamdurjoy 4 года назад

    G 253

  • @akramsiddiqui4203
    @akramsiddiqui4203 5 лет назад +1

    look like an angel..

  • @WisdomIsAwesome
    @WisdomIsAwesome 4 года назад

    I think your code is correct but you explained it slightly wrong! The v value is not getting incremented globally in the DFS function as you are explaining in the video. You explanation would fail when the connected components do not have the vertices in a serialized order. Please review you explanation and edit the video if possible.

  • @fahyiensher8220
    @fahyiensher8220 5 лет назад

    Kitna bhi focus krraha hu lecture pr nhi ho paraha bar bar tumhe dekhne lagta hu

  • @vishnukumard5377
    @vishnukumard5377 3 года назад

    ❤️

  • @mdarifhasan9919
    @mdarifhasan9919 3 года назад +1

    Speed increase to 1.75x and thank me later :3

    • @su5182
      @su5182 8 месяцев назад +1

      Thanks bro

  • @laxmandeadpool8260
    @laxmandeadpool8260 5 лет назад

    👍👌

  • @htalkies
    @htalkies 5 лет назад

    this code will fail for an input like [1,0], where 1 and 0 are nodes, connected by an edge. The answer will be 2 instead of 1.

  • @Rahul.r.r_p
    @Rahul.r.r_p 11 месяцев назад

    Day 69

  • @omprakashsharma9767
    @omprakashsharma9767 4 года назад +2

    when you gonna smile :( :(

  • @Lalala_1701
    @Lalala_1701 Год назад

    Ma'am totally connected component kisko khete hai

  • @shubhampatel2873
    @shubhampatel2873 5 лет назад +1

    Love you Madam

  • @fahyiensher8220
    @fahyiensher8220 5 лет назад

    You are too cute.

  • @tanimkabir9582
    @tanimkabir9582 5 лет назад +1

    do you have any boyfriend?

  • @pravalikakadavergula6022
    @pravalikakadavergula6022 4 года назад

    Mam make a video on strongly connected components

  • @ak_tree5225
    @ak_tree5225 6 месяцев назад

    Thank you