السلام عليكم ورحمة الله وبركاته..
الله يعطيكم العافية هذا حلي وما أعرف ليه يطلع لي خطأ..
#include <iostream>
#include <string>
using namespace std;
#include "Graph.h"
struct user
{
int Key;
string name;
void setdata()
{
cout<<"input user id ";
cin>>Key;
cout<<"\n\n input user name ";
cin>>name;
cout<<'\n';
}
void print()
{
cout<<"\n user id "<<Key;
cout<<"\n user name "<<name;
}
};
void print_user( Graph<user,int> facebook , int user)
{
facebook.depthFirst ((*process)( user));
}
void()
{
cout<<"\n====mnue=====\n";
cout<<" 1-Insert users\n";
cout<<"2- Insert the link to indicate that the two user are joined\n";
cout<<" 3- For a given user print the number of user who linked with [in-degree, outdegree]\n";
cout<<"4-Delete a certain user\n";
cout<<" 5- Delete a link between two users\n";
cout<<" 6-Print all users using depth-first traversal\n\n\n";
cout<<" 7- exit\n\n";
}
int main()
{
Graph<user,int> facebook;
user user1;
int choice;
do{
cout<<"input your choice from mnue ";
cin>>choice;
switch(choice)
{
case 1:
user1.setdata();
int facebook.add,insertVertex(user1);
if(add==1 )
cout<<"data added sucssfulay \n\n";
else
if(add==-1)
cout<<"cannot add memory full\n";
break;
//=============================================
case 2:
int fromKey,toKey;
cout<<"input first user ";
cin>>fromKey;
cout<<"\n\n input secound user ";
cin>>toKey;
int arc=facebook.insertArc (KTYPE fromKey, KTYPE toKey);
if (arc==1)
cout<<"succsefuly added arc between 2 user\n\n";
else
if(arc==-1)
cout<<""cannot add memory full\n";
else
if(arc==-2)
cout<<"the first user doesnot exist\n\n";
else
cout<<"the secound user doesnot exist\n\n";
break;
case 3:
break;
case 4:
int delkey;
cout<<"input key number to delete ";
cin>>delkey;
int result=facebook.deleteVertex(delkey);
if(rsult==1)
cout<<"user is deleted\n";
else
if(rsult==-1)
cout<<"user is connected with another user\n";
else
cout<<"delete user not found\n";
break;
/==========================================================
case 5:
int fromKey,toKey;
cout<<"input first user ";
cin>>fromKey;
cout<<"\n\n input secound user ";
cin>>toKey;
int arc=facebook.deletearc (KTYPE fromKey, KTYPE toKey);
if (arc==1)
cout<<"succsefuly delete arc between 2 user\n\n";
else
if(arc==-12)
cout<<"cannot delete ....the first user does not exist\n\n";
else
cout<<" cannot delete ....the secound user does not exist\n\n";
break;
case 6:
facebook.depthFirst ( (*process)(TYPE dataProc));
break;
case 7:
exit(1);
break;
}
}while(choice>=1 && choice<=6);return 0;
}
