Posts

Showing posts from October, 2019

introduction to Graph

Image
Graph Algorithm Graphs are mathematical structures that represent pairwise relationships between objects.   There two things to represent graph. 1) Node: Nodes are entities whose relationships are expressed using edges. 2) Edge:  Edges are the components that are used to represent the relationships between various nodes in a graph. Types of graphs Graph representation You can represent a graph in many ways. The two most common ways of representing a graph is as follows: Adjacency matrix An adjacency matrix is a  VxV  binary matrix  A . Element  A i , j  is 1 if there is an edge from vertex i to vertex j else  A i , j  is 0. The adjacency matrix of the following graph is: i/j  :  1  2   3   4 1  : 0 - 1 - 0 - 1 2  : 1 - 0 - 1 - 0 3  : 0 - 1 - 0 - 1 4  : 1 - 0 - 1 - 0 The adjacency matrix of the following graph is: i/j :  1   2   3   4 1  : 0 - 1 - 0 - 0 2  : 0 - 0 - 0 - 1 3  : 1 - 0 - 0 - 1 4  : 0 - 1 - 0 - 0 Code:-