### Help with 1 function

I need a function which count and display nodes with maximum outgoing edges/arcs/ in graph

Here is the code, i have to add this function to it. Anyone?

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148`` ``````#include using namespace std; const int n=10; struct link { char key; link *next; } *g[n]; void print(link *g[n]) { link *p; { for(int i=0; ikey; p=p->next; } cout<key==c) flag=1; return flag; } int search_arc(char c1, char c2, link *g[n]) { int flag=0; if(search_node(c1,g) && (search_node(c2,g))) { int i=0; while(g[i]==NULL||g[i]->key!=c1)i++; link *p=g[i]->next; if(p) { while(p->key!=c2 && p->next) p=p->next; if(p->key==c2) flag=1; } } return flag; } void add_node(char c, link *g[n]) { if(search_node(c,g)) cout<<"In Exsitsing node: "; else {int i=0; while(g[i]&&ikey=c; g[i]->next=NULL; } else cout<<"Overflow"; } } void add_arc (char c1, char c2, link *g[n]) { if (search_arc(c1,c2,g)) { cout<<"In Existing arc";} else { if(!(search_node(c1,g))) add_node(c1,g); if(!(search_node(c2,g))) add_node(c2,g); int i=0; while(g[i]==NULL||g[i]->key!=c1) i++; link *p=new link; p->key=c2; p->next=g[i]->next; g[i]->next=p; } } int main() { char c,k; int m; do { cout<<"\n MENU "; cout<<"\n 1.Add node "; cout<<"\n 2.Add arc "; cout<<"\n 3.Print All "; cout<<"\n 4.End "; cout<<"\n Choice: "; cin>>m; switch(m) { case 1: { cout<<"\n Node: "; cin>>c; add_node(c, g); break; } case 2: { cout<<"\n First node"; cin>>c; cout<<"\n Second node"; cin>>k; add_arc(c, k, g); break; } case 3: { print(g); } } } while(m!=4); return 0; } ``````

Topic archived. No new replies allowed.