# graph

## Tree vs Graph

A tree is a non-linear data structure that represents the hierarchy. A tree is a collection of nodes that are linked together to form a hierarchy. A graph is like a tree data structure is a collection of objects or entities known as nodes that are connected to each other through a set of edges. A tree follows some rule that determines the relationship between the nodes, whereas graph does not follow any rule that defines the relationship among the nodes. A graph contains a set of edges and nodes, and edges can connect the nodes in any possible way.