REPRESENTATION OF GRAPHS - DATA STRUCTURES

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello friends welcome back to our Channel so in the previous session we have seen the introduction to graphs and also we have seen the graph terminology and also we have seen different types of graphs available in data structure now in this session we'll go with one more concept that is how to represent a graph so representation of graphs so girls can be represented in two ways so first one is using multi-dimensional array another one using list concept using the least convinced so we'll see how a graph can be represented by using multi-dimensional array how a graph can be represented by using the list first we'll go with the multi-dimensional and so let us take an example for this graph and then we apply the representations we can see the presentation so we will take the similar example which we have considered in the previous session so this is a graph let us take this Jews exam and we have to represent this in a Muslims from there so here we have to represent in two-dimensional so these are the rows and these are the nodes again so rows and columns represents the nodes and now we have to fill this multi-dimensional array with zeros and ones so if an edge between the two vertices is available then that that will be filled with one otherwise it will be filled with you now yeah and here so here and here there is no edge so there is a possibility to have an edge between a in da right there's a self-loop self-loop is also available in a graph right so you can have a self-loop so in this example it does not have any self self loop so yeh doesn't have a load from way to gauge so filled with zero yet to be yes it is having an edge so one you have to see there is no edge 0y a 2d yes so there will be two yay yes so this is not this is an undirected graph so there it is a bi-directional so a + b is equal to b ng right so similarly we can also have an edge from B to a so brittle a 1 so B to B there is no self loop B to C this is a H B to D there is a voyage so now you see - a Norwich C to B there is a one edge C to D so C to C no loop C to D 1 D 2 a 1 H D to B 0 D to C 1 H and D to B there is no self so this is how we can represent a graph in adjacency matrix the visibility dimensional and by using the multi-dimensional area we can represent any graph here so if the same example see if it is having if it is having adapted RAF directed graph so this is a unidirectional so let us see the Maddux see a - yay no here to be this one edge yet to see zero inch yet 2d yes this is an edge it's a unidirectional right so a 2d is also one similar will be 2 J 0 because here yet to be is not equal to beta J because there is a directed graph directed edge right so the direction is sewer za to be not forgetting it so Britain is 0 so next b2 b0 b2 c1 bring to D so let me see - yay 0 C to be again it's a unidirectional and that edge is for me to Z naught from C to B C to C 0 C to D 1 D 2 J in secular direction 0 D to B 0 D to C 0 this will be 0 so this is a matrix represented for this deck it there it's an undirected graph and this is a directed graph right so hope you understood this how to represent a graph using multi-directional right now we will see the another type of representation by using list this is also similar another every node will be having two fields one is the data field another one is a header speed so for example consider a considered a so yeah is having two roots one is from B on to be so so we can represent like this so B again points to right so a can be having n modes connectivity for B and D similarly having to the big these also having two roots so what are the two rows here we say MC so a connecting two see so even though there is no caption these having to adjust that twitches can be represented in in this similar way and the see see is also having tools B and D so B and D and D is also having C let us have this one okay now these having teams yeah B and C all these things so yeah see see in such a way we have to represent a graph using linkedlist so this implies yeah is having enrolled to be and to D D is also having an edge from yay and to see C is having an edge for B and D is also having an edge for a and B and C coming to this so this is a null right this isn't right how many do this one coming to this directed graph so how do you represent here yeah is having curves BND the d and come to the north b b is having only voyage towards the sea sea sea is having only h4 d and it b it is having holy voyage from D to B so this is how we have to represent graph I mean you see list littlest so in some references you can find for a there is having B and D and here be some having a and C naught J and C and C is having some notes B and E and E is having note C a comma B comma C and similarly for this also you can observe a is having a link between B and the D and B is having a link to c c is having unique 2 and it is having nothing to so you can find it two ways so in different ways we can represent the graph using list so this is how we can represent any graph using multi-dimensional arrays by using the adjacency matrix and as well as the list concept right so hope you understood this session so if you are having any doubts regarding this representation so feel free to post your jobs in the comment section so that I will definitely try to clarify how you adults and if you are my sessions like my sessions share my sessions with your friends and don't forget to subscribe to our channel thanks for watching thank you very much
Info
Channel: Sundeep Saradhi Kanthety
Views: 27,484
Rating: 4.939394 out of 5
Keywords: sundeep, saradhi, kanthety, data structures, arrays, lists, stacks, queues, trees, graphs, primitive, non primitive, linear, non linear, linked lists, ds fundamentals, ds basics, nodes, interview, placements, cse, edge, connection, leaf node, internal, depth, height, level, path, degree, root node, GRAPH TERMINOLOGY, graps, weighted graph, cyclic graph, directed graph, vertices, edges, undirected, acyclic, unweighted, types of graps, kinds of graphs, GRAPH REPRESENTATION
Id: JONnqF-oCDo
Channel Id: undefined
Length: 10min 15sec (615 seconds)
Published: Mon Aug 12 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.