What is Graph and How it represents?



Suraj Said

+0 -0

A graph is a mathematical structure that is used to model relationships between objects or entities. It is a collection of vertices (or nodes) and edges that connect them. Each vertex represents an object or entity, and each edge represents a relationship between the two vertices it connects.
Graphs can be represented in different ways, the most common of which are:
Adjacency Matrix: is a two-dimensional matrix where each element represents the relationship between two vertices. If there is an edge between the vertices i and j, the element at the i-th row and j-th column of the matrix is set to 1, otherwise it is set to 0.
Adjacency List: is a list where each element represents a vertex and its associated edges. Each vertex is represented by a list of vertices it is connected to.
Incidence Matrix: is a two-dimensional matrix where each element represents the relationship between a vertex and an edge. If the vertex i is connected to the edge j, the element at the i-th row and j-th column of the matrix is set to 1, otherwise it is set to 0.



Submit Your Response