Graph Creation using Method -2 

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> #include<list> using namespace std; struct Edge{ int des; int weight; Edge(int des , int weight){ this->des = des; this->weight = weight; } }; int main() { int V = 7; list<pair<int,int>> *l = new list<pair<int,int>>[V]; l[0].push_back(make_pair(1,10)); l[0].push_back(make_pair(2,20)); l[1].push_back(make_pair(2,21)); l[1].push_back(make_pair(0,10)); l[2].push_back(make_pair(0,20)); l[2].push_back(make_pair(1,21)); for(int i=0; i<V; i++){ for(auto x:l[i]){ cout<<i<<"->"<<x.first<<"("<<"Weight: "<<x.second<<")"<<endl; } } }
Editor Settings
Theme
Key bindings
Full width
Lines