#include "graph3.h" #include "apstring.h" #include #include int main(){ // Define variables for storing information read from the input char command; apstring str1, str2; // Define variables for storing the graph, a node, and an edge graph G; while(cin.peek() != EOF){ cin >> command; cin >> str1; switch(command){ case 'A': if(cin.peek() != '\n'){ cin >> str2; edge x(str1, str2); G += x; } else{ node x(str1); G += x; } break; case 'D': if(cin.peek() != '\n'){ cin >> str2; edge x(str1, str2); G -= x; } else{ node x(str1); G -= x; } break; case 'P': apvector neighbors = G.get_neighbors(node(str1)); cout << str1 <<": "; for(int i = 0; i < neighbors.length(); i++) cout << neighbors[i].getName() << " "; cout << endl; break; } if(cin.peek() != EOF) cin.ignore(); } return EXIT_SUCCESS; }