Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- void addEdge(vector<vector<int>> &adj, int u, int v)
- {
- adj[u][v]=1;
- adj[v][u]=1;
- }
- void printGraph(vector<vector<int>> &adj, int V)
- {
- for (int i = 0; i < V; ++i)
- {
- for(int j=0;j<V;j++)
- cout<<adj[i][j];
- cout<<endl;
- }
- }
- int main()
- {
- int V = 5;
- vector<vector<int>> adj(V,vector<int>(V,0));
- addEdge(adj, 0, 1);
- addEdge(adj, 0, 4);
- addEdge(adj, 1, 2);
- addEdge(adj, 1, 3);
- addEdge(adj, 1, 4);
- addEdge(adj, 2, 3);
- addEdge(adj, 3, 4);
- printGraph(adj, V);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement