Data Structure in C++ Please help me on this... this is like my fifth time posti
ID: 3841057 • Letter: D
Question
Data Structure in C++
Please help me on this... this is like my fifth time posting this...
Please create and implement the commands to make that graph.. Thank you
Part 2: Commands Implement the following commands Command Description create nr Create a new empty graph in register n with nnodes Print some representation of the graph in r print r arc a br n the graph in register r create an arc from node ato b biarc a br Create a bidirectional arc from ato bin r bfs abr Perform a breadth-first search from a to b in r, printing the distance Write the register commands necessary to create the following graph: and place them in a comment in your source code. What is the distance fromnode 9 to node 6?Explanation / Answer
#include <iostream.h>
#include <sstream.h>
#include <string.h>
#include <list.h>
#include <algorithm.h>
#include <vector.h>
#include <functional.h>
#include <queue.h>
using namespace std;
class optional {
int jj;
list<int> *adjacnet;
public:
optional(int jj) {
this->jj = jj;
adjacnet = new list<int>[jj];
}
void make(int value, string register){
adjacnet[value].push_back(register);
}
void display(string register){
}
void argc(string xx9, string xc9, string res){
}
void bi_arc(string xx9, string xc9, string res){
}
void breadth_fs(string xx9, string xc9, string res){
}
};
int main(){
using std::cin;
using std::cout;
using std::endl;
string str8;
optional execute = optional();
while(true){
cout << "> ";
getline(cin,str8);
string wc;
std::stringstream ss(str8);
vector<string> words;
while (ss >> wc)
words.push_back(wc);
if(words[0] == "make"){
int value = atoi(words[1].c_str()); // Change string into$
execute.make(value, words[2]);
}
else if(words[0] == "display"){
execute.display(words[1]);
}
else if(words[0] == "argc"){ execute.argc(words[1], words[2], words[3]);
}
else if(words[0] == "bi_arc"){
execute.bi_arc(words[1], words[2], words[3]);
}
else if(words[0] == "breadth_fs"){
execute.breadth_fs(words[1], words[2], words[3]);
}
else if(words[0] == "stop"){
return 0;
}
else{
cout << "No such command exists." << endl;
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.