#include<stdlib.h>
#include<string.h>
#include<time.h>
#include<math.h>
#include<float.h>
#include<stdbool.h>
#include<iostream>
using namespae std;
#define MAX_USERS 100
typedef struct User{
char ID[10];
char username[20];
char password[20];
int age;
}User;
//邻接矩阵
typedef struct Graph{
float adjMatrix[MAX_USERS][MAX_USERS];
int numUsers;
}Graph;
int main()
{
Graph g;
initGraph();
loaduser();
loadrealation();
int choice;
char str1[10],str2[10];//ID输入的两个变量
int i;
int k;
do
{
Printmenu();
printf("请输入:");
cin>>choice;
switch(choice)
{
case 1:
printUser(&g);
break;
case 2:
printMatrix(&g);
break;
case 3:
addUser(&g);
break;
case 4:
cout<<"请输入要删除的用户ID:";
cin>>str1;
i=findID(&g,str1);
if(i!=-1)
deleteUser(&g);
else
cout<<"用户ID不存在\n";
break;
case 5:
addFriend(&g);
break;
case 6:
deleteFriend(&g);
break;
case 7:
cout<<"请输入起点用户ID:";
cin>>str1;
i=findID(&g,str1);
if(i!=-1)
{
int visited[MAX_USERS]={0};
cout<<"DFS遍历结果:";
DFS(&g,i,visited);
cout<<"\n";
}
else
cout<<"用户ID不存在";
break;
case 8:
cout<<"请输入起点用户ID:";
cin>>str1;
i=findID(&g,str1);
if(i!=-1)
{
cout<<"BFS遍历结果:";
BFS(&g,i);
cout<<"\n";
}
else
cout<<"用户ID不存在";
break;
case 9:
cout<<"请输入起点用户ID:";
cin>>str1;
i=findID(&g,str1);
if(i!=-1)
{
cout<<"输入距离k:"
cin>>k;
findK(&g,i,k);
}
else
cout<<"用户ID不存在";
break;
case 10:
prim(&g);
break;
case 11:
floyd(&g);
break;
case 12:
}
}
}