Introduction to Graphs: Definitions, Traversal, Depth-First Search

Thanks for your positive feedback sir :slight_smile:

@admin , why does it say ā€œasked n days ago by kurumaā€ shouldnā€™t it rather say ā€œposted n days ago by kurumaā€ ? btw @Kuruma, really nice and helpful post :slight_smile:

1 Like

GALACTICK could be solved using Disjoint Sets data structure instead of DFS and BFS. This would have sped up the code by many times :slight_smile:

Thank you @v_akshay, Iā€™m glad you liked this :slight_smile: About the asked vs posted part, as this was a ā€œquestionā€, it says asked, but, I guess that is just how the forums work :slight_smile:

Nice work kurumaā€¦keep it up.It was written in a neat and crisp way.This tutorial was required by many newbies. One can expect people implementing this tutorialā€™s code from the next contests :slight_smile:

1 Like

Thank you very much for the positive feedback @re_hash! I hope I can implement all these ideas in next contests myself as well :smiley:

Awesome post !! Easy to understand and really good for a beginner . .

I tried my hand on implementing some of the graph algorithms in python and Iā€™ve uploaded it on github link , if someone wants to go through them , its available . It might be a bit messy though , Iā€™ve tried my best to make it look good and readable . Hope it helps !!

to ADMIN staff, pls pin algo tutorials like these on static algo tutorials page. topcoder has that

1 Like

Do we have a ā€œstatic algo tutorials pageā€ here on Discuss? The closest thing seems to be the tutorials and references posted at Codechef for Schools page, but, if we could pin a ā€œsub-forumā€ grouping all tutorials or even better all editorials on its own ā€œsub-forumsā€, that would be really useful

1 Like

@Kuruma
its really helpful thanks!!

I solved the problem first by Disjoint Sets and then by DFS. Learned a lot about DFS from GALACTIK that helped me in FEB14 in solving DRGHTS.

Have a look at this blog it contains nice stuff on graphs and treesā€¦

i am not getting what is sz_connct_compt is? could u please explain me?

The best Explanation of Graphs, I have seen so far.

I did not attempted the Graph Problems, as I was thinking that it was not my cup of cake, but now I will try it.

Thanks @kuruma

It tells that a particular friend has sz_connct_compt number of connected friends.

Means, if 1->2 and 2->3 and 3->5,6
so when we dfs(1) the sz_connct_compt will become 5, as there are 5 friends that will be liking to escape by same route.

I hope now you have understood. @amanjain7793

Tanq so much

@kuruma Could you explain how you calculate the number of ways to select the captains? I didnā€™t understand that part.

Nice tutorial, made DFS so clear as you used it to solve a problem, This is a great help for beginners please continue this kind of tutorials.

following link is be very useful for u to understand binary tree traversal(pre-order, in-order, post-order) in detail including graphs: