Day 31: Tree vs Graph

Hello Dear Students, 
Hope you all are doing good.

Aaj hum basic topic tree vs graph ko study karenge which is an important topic to understand. 

Let's get started....
  • Graph is diagram or drawing which is collection of nodes and edges. 
  • Tree is also a collection of nodes and edges. 
  • But graph and tree mein yeh difference hai ki tree mein cycles nahi hote and graph has cycles. 
  • Tree with cycles is known as Graph or a Graph without cycles is known as tree.
  • Cycle means the path in which the starting and ending vertex is same. 
  • For example, ek tree hai, uski nodes ka path only from parent node to child node hi hota hai, ek chlid node cycle form nahi kar sakti, for example,tree
  • In above tree, agar hum B to B path find karenge, then it is not possible in tree because, hum B to B path define nahi kr sakte, means it is not cycle.Hum only B to A, B to D, B to E, path ko hi define kar sakte hain. Agar hume B to B path chahiye, then B to D and then D to E and then E to B hoga, but D and E mein edge hi nahi hai connect karne ke liye, so it cannot make cycle. 
graph
  • Ab agar hum above graph mein kisi bhi node ka path find karenge then wo cycle ki form mein hoga. For example, agar hum B to B path find karenge then it form cycle and path is {B,<BC>,C,<CD>,D,<DB>,B} ab ye path define ho gya. 
  • So, it is very simple that agar cycle ban raha hai nodes mein, then it is graph otherwise it is tree. 

Next we will see the types of graphs,

Best of Luck Students,
Do visit our website regularly for more content and for daily tests.

Regards,
UGC NET EXPERTS