///Bidirectional Graph
///Adjacency List
#include<bits/stdc++.h>
#define N 10020
using namespace std;
vector<int>direction[N];
int main()
{
int node, edge, i, j, u, v;
cout << "Enter Node Number :: ";
cin >> node;
cout << "Enter Edge Number :: ";
cin >> edge;
cout << "\nEnter Edges :: \n";
for(i=1;i<=edge;i++)
{
cin >> u >> v;
direction[u].push_back(v);
direction[v].push_back(u);
}
cout << "\nDegree Of Node Are :: ";
for(i=1;i<=node;i++)
{
cout << "Node " << i << "\n";
cout << "Indegree :: " << direction[i].size() << "\n";
cout << "Outdegree :: " << direction[i].size() << "\n\n";
}
return 0;
}
Comments
Post a Comment