Introduction to Graph
What is a Graph?​
Graphs are mathematical structure used to represents relationship between the objects. A graph consist mainly two componenets : Nodes (Vertex) and Edges. Objects are represented by nodes (vertex) and relationship between them are represented by edges.
Types of nodes​
- Root Node: The root node is the ancestor of all other nodes in a graph. It does not have any ancestor. Each graph consists of exactly one root node which may vary acoording to your choice.
- Leaf Node: In a graph, leaf nodes represent the nodes that do not have any successors. These nodes only have ancestor nodes. They can have any number of incoming edges but they will not have any outgoing edges.
Types of edges​
- Directed Edge: When the relation between two nodes is unidirectional. Then the egde used to connected those two nodes is directed edge.
- Undirected Edge: When the relation between two nodes is bidirectional. Then the egde used to connected those two nodes is undirected edge.