Can you make a header file for this main ?

I had to make a header for this on my exam (sadly I failed):


Make a program, which has the following usage:

$ prog source target [graph]

where the source and the target are strings.

for grade 2: The program is working
for grade 3: 2 + the program can count the edges
for grade 4: 3 + the program can find a path from the source to the target
for grade 5: 4 + the program can find the shortest path




#include <iostream>
#include "graph.h"

using namespace std;

int main()
{
int yourMark = 1;
/// for grade 2
Graph<int, false> undir_graph;
Graph<int, true> dir_graph;

undir_graph.add(3);
undir_graph.add(7);
undir_graph.add(6);

undir_graph.add(3, 7);
undir_graph.add(6, 3);

dir_graph.add(1);
dir_graph.add(2);
dir_graph.add(3);
dir_graph.add(4);
dir_graph.add(5);
dir_graph.add(1,3);
dir_graph.add(3,2);
dir_graph.add(4,2);
dir_graph.add(5,1);
dir_graph.add(5,5);
dir_graph.add(4,4);

const Graph<int, false> cug = undir_graph;

yourMark += (cug.is_directed() + dir_graph.is_directed());


/// for grade 3
undir_graph.remove(3, 6);

if (cug.has(7,3) &&
!dir_graph.has(3,1))
{
yourMark = cug.countNodes();
}


/// for grade 4
dir_graph.remove(3);
yourMark = dir_graph.countEdges();


/// for grade 5
Graph<int, false> a;
Graph<int, false> b;
a.add(2);
a.add(4);
a.add(5);
a.add(2,4);
a.add(5,4);
b.add(2);
b.add(4);
b.add(7);
b.add(6);
b.add(4,2);
b.add(7,6);
Graph<int, false> c = a + b;

Graph<int, true> d;
d.add(3);
d.add(5);
d.add(3,5);
Graph<int, true> e;
e.add(7);
e.add(3);
e.add(3,7);
Graph<int, true> f = d + e;

if (3 == f.countNodes() && 2 == f.countEdges())
yourMark = c.countNodes();

std::cout << "Your mark is " << yourMark << std::endl;
return 0;
}





My biggest problem is i don't understand what is Graph<int, false>
please at least explain this part of the task if u dont have time for the whole thing.

Thank you very much for any advice and help.
I guess that template<class T, bool directed> class graph;
then yuo use the `directed' parameter in the `add_edge()' function to add both directions.


By the way, $ prog source target [graph], you must use the arguments of main
int main(int argc, char **argv)
Topic archived. No new replies allowed.