 Hello and welcome to the lecture on Introduction to Graphs. In this lecture we will be discussing about graph data structure, its terminology. The learning outcome of this video lecture is that the student is able to explain graph data structure, need of graph, graph terminology and types of graphs. What is graph? Graph is a non-linear data structure that is used to implement the mathematical concept of graph. Graph is a collection of vertices, edges that connect these vertices. Here vertices are also referred as nodes. Need of graph, graph is used to represent the data where data are related to each other in pairs. There are several problems that are naturally graph problems such as networking problems, routing problems, sorry, route planning problems and transport network. For example, the city map can be represented as graph in which the location in the city can be represented as nodes and the roots connecting these locations can be represented as edges. In this graph the city connected to each other is represented in graph G where the node is represented in the city and the edges connecting is representing the root between the city. A graph G is defined as an order set of vertices and edges where V represents set of vertices and E represents the edges that connect the vertices. For example, as shown in this figure a graph G with vertices A, V, C, D, E and edges AB, VC, AD, PD, DE, CE. So here there are five nodes and six edges present in the graph G. Graph can be directed or undirected graph. In undirected graph the edges do not have any direction associated with them. If N H is drawn between the nodes A and B then the nodes can be traversed from A to B as well as from B to A. The given graph G is an example of undirected graph. G can be represented as set of vertices that is V is equal to A, B, C, D and set of edges E is equal to AB, VC, AD, BD, DE and CE. Graph G1 is an example of directed graph. In directed graph edges form an ordered pairs. If there is an edge from P to Q then there is a path from P to Q but not from Q to P. The edge PQ is set to initiate from node P and terminate at node Q. G1 can be represented as a set of vertices where V is equal to P, Q, R, ST that is a set of vertices and set of edges equal to PQ, PS, RQ, QS, ST and TR. Adjacent vertices or nodes or neighboring nodes in graph if two vertices are set to be adjacent if an edge directly connects them. In graph G vertex A and B are adjacent vertices whereas A and E are not adjacent vertices. In graph G the path from vertex A to E is represented as A, B, C, E which is one path and another path is A, B, D, E. Next one is closed path. Path is known as closed path if the H has the same end points that is if starting vertex is equal to the last vertex. In graph G path A, B, A, B, C, E, D, A is a closed path. Cycle. A path in which the first and last vertices are same. A cycle is a path of at least three vertices that starts and ends with the same vertex. A simple cycle has no repeated edges or vertices except first and last vertices. A cycle is a closed path that is we start and end at the same vertex in the middle we do not travel to any other any vertex twice. Loop. A loop is a special case of cycle in which a single arc begins and ends with the same node as shown here an edge that has an identical end points is called an a loop. Here the edge starts with the node A and ends with the node A. Degree of node. Degree of node is the total number of edges containing that particular node. In graph G degree of node is a 2 and degree of node B is 3. If degree of node A is equal to 0 it means that A does not belongs to any edge and such node is known as isolated node as shown in graph G1. Here is the time to reflect on the content what we have learned. State the following statement is true or false. A cycle is a path of at least three vertices that starts and ends with the same vertex. You can pause the video for a time and think on the answer for this question. The statement given is true yes a cycle is a path of at least three vertices that starts and ends with the same vertex. Connected graph. Two vertices are said to be connected if there is a path between them. A graph is said to be connected if there is a path from any vertex to any other vertex. In a connected graph there are no unreachable vertices. For example as shown in this diagram there is a path from any vertex to any other vertex. So this is the connected graph. In directed graph if there is a path from each vertex to every other vertex then it is strongly connected graph as shown in this diagram. A directed graph is a weakly connected if at least two vertices are not connected. So this is an example of weakly connected graph. So where you will find at least two vertices which are not connected. Complete graph. Complete graph has an edge between every pair of vertices that is there is a path from one node to every other node in the graph. As shown here it is an example of complete graph where the number of nodes are seven. So each node is connected to every other node in the graph. Weighted graph. A graph is said to be weighted graph if every edge in the graph is assigned some value. In weighted graph the edges of the graph are assigned some weight or length. The weight of edge is a positive value indicating the cost of traversing that edge. This diagram shows the weighted graph where value is assigned to each edge in the graph. Next is disjoint graph. A graph is disjoint graph if it is not connected. For example this graph is a disjoint graph where there is no edge between A, B, C, D vertices to F, G, H vertices. So this is an example of disjoint graph. Di-graph. A directed graph is called di-graph in which every edge has a direction assigned to it. An edge of directed graph is given as an order pair PQ for example of nodes in a graph. For example HPQ indicates that H begins at node P and terminates at node Q. Here P is the predecessor of Q and Q is the successor of node P. Nodes P and Q are adjacent to each other. The out-degree of a node is the number of edges that originates at that node. In this graph out-degree of node Q is one. The in-degree of a node is the number of edges that terminates at that node. So in this example in-degree of node Q is two. In-di-graph the degree of a node is the sum of in-degree and out-degree of that node. So in this graph degree of node Q is the sum of out-degree and in-degree of that node that is equal to three. A node is called as source node if it has a positive out-degree but its in-degree is equal to zero. So in this graph out-degree of a node P is two and in-degree is zero therefore P is a source node. A node is called as a sink if it has positive in-degree but its out-degree is zero. So in this example if we assume that there is no H from node T to R then T is an example of a sink node. Now this is time to reflect on the content what we have learned. Here graph G is given in this diagram identify this graph G is undirected or directed graph. In graph G is there a path from node A to node C? If yes then write the nodes visited in this path. Is there is a source node in this graph? If yes then specify. So you can pause the video for a time and write the answer for this question. So here is the answer for the given question. In graph G edges form are in pairs indicating direction therefore graph G is directed graph. Second question yes there is a path from node A to node C. One path is A, B, E, D, C and another path is A, E, D, C. Third question answer source node is a node which has a positive out-degree but its in-degree is equal to zero. Another node A is source node because node A is out-degree is two and in-degree is zero. Therefore there is no other node whose in-degree is zero. Thank you for watching this video.