I have query related to graph . | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

I have query related to graph .

Now a days i am learning graph . I also got the concept but struggling with the different represention in different platforms and YouTube . That represention are : (1) vector <int> adj [n+1] (2) unordered_map<int , list<int>> adj (3) int adj [n+1][m+1] (4) vector<pair<int , int>> & edges (5) vector<int> adj [ ] Because of this solution also change . May you please tell me how to convert one from another . Or any other good technique, it will help me a lot . Thank you .

6th Dec 2022, 6:19 PM
Abhay mishra
Abhay mishra - avatar
1 Réponse
+ 1
You can represent a graph as an adjacency matrix (technically a 2d array) or an adjacency list. Both versions can be valid, and even in programming you can use different ways (array, vector, custom object) to build it. Just choose one that you are most comfortable with... https://www.sololearn.com/learn/656/?ref=app
6th Dec 2022, 7:44 PM
Tibor Santa
Tibor Santa - avatar