Monday 18 February 2019

Graph Representation

There are in total a few different graph representation + implicit representation :

Implicit Representation : For some graphs,the graph itself does not have to be stored.

Edge List : List of pairs of vertices.
Ex : (1,3),(2,3),(3,3),(5,3),(4,5),(2,4),(1,2)

Adjacency Matrix : This is a N* (N array). N is the number of vertices. If node i is connected to node j then adj[i][j] = 1 else adj[i][j]=0. Ex :
Image result for directed graph programming
Sometimes a grid can also be a good representation.

Adjacent List : Keep track all the edges incident to a given vertex and do this for all vertex. Ex :

1 : 3,2
2 : 3,4
3 : 3
4 : 5
5 : 3
A graph making website: https://csacademy.com/app/graph_editor/

No comments:

Post a Comment

std::next_permutation(arr.begin(),arr.end());

What is next_permutation(a.begin(),a.end()) ? Next permutation is like what its name says, finds the next permutation of a and assigns ...