We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ffe2828 commit f876cabCopy full SHA for f876cab
Graph/a.out
33.8 KB
Graph/adjacencyList.cpp
@@ -0,0 +1,36 @@
1
+/*
2
+author:gulshan yadav
3
+email: gulshany01@gmail.com
4
+date: 21-July-2021
5
+*/
6
+#include<iostream>
7
+#include<bits/stdc++.h>
8
+using namespace std;
9
+
10
+void addEdge(vector<int> adj[], int u, int v){
11
+ adj[u].push_back(v);
12
+ adj[v].push_back(u);
13
+}
14
15
16
+void printGraph(vector<int> adj[], int v){
17
+ for(int i =0; i< v; i++){
18
+ for(int x: adj[i]){
19
+ cout << x<<" ";
20
21
+ }
22
+ cout << endl;
23
24
25
26
+int main(){
27
+ int v = 4;
28
+ vector<int> adj[v];
29
+ addEdge(adj, 0, 1);
30
+ addEdge(adj, 0, 2);
31
+ addEdge(adj, 1, 2);
32
+ addEdge(adj, 1, 3);
33
+ printGraph(adj, v);
34
+ return 0;
35
36
0 commit comments