1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
Put the code you need help with here.
There are actually first two files, that want to make 3 files by having a seperate file to contain the main().
1. GraphTest.cpp //calls functions defined in graph.hpp
# include "graph.hpp"
# include <iostream>
using namespace std;
int main()//want to rename it to: new_function(); //and shift main() in
//new main.cpp file
{
char aObjects1 = {'A', 'B', 'C', 'D' };
size_t aEdges1 = {0,1, 1,2, 2,3, 3,0 };
graph::Graph<char> g1(aObjects1, 4, aEdges1, 4);
g1.computeFundamentalCycles();
g1.computeAllCycles();
g1.dump(cout);
....
}
|
2. graph.hpp // has all (public/private) data members, functions //declared here
#ifndef __GRAPH_H__
#define __GRAPH_H__
# include <algorithm>
# include <iostream>
# include <memory>
# include <vector>
# include <random>
# include <stack>
# include <list>
# include <set>
# include <map>
//stating as in C header files:
int new_function();// is not helping
namespace graph
{
class HalfAdjacencyMatrix
{
...
}
template<class TObject>
class Graph
{
...
}
inline bool CreateRandomGraphIsConnected(const size_t& a, const size_t& b, const void * pEdgeProbabilty)
{
...
}
std::unique_ptr<Graph<size_t> > CreateRandomGraph(size_t nNodes, float fEdgeProbability)
{
...
}
}
#endif
-----------------
3. New main.cpp file that will just call the renamed function: new_function();
int main(int argc, char** argv)
{
new_function();
}
-----------------------------
------------------------------
Minimal example:
1. GraphTest.cpp //calls functions defined in graph.hpp
# include "graph.hpp"
# include <iostream>
using namespace std;
int main()//want to rename it to: new_function(); //and shift main() in
//new main.cpp file
{
char aObjects1 = {'A', 'B', 'C', 'D' };
size_t aEdges1 = {0,1, 1,2, 2,3, 3,0 };
graph::Graph<char> g1(aObjects1, 4, aEdges1, 4);
g1.computeFundamentalCycles();
g1.computeAllCycles();
g1.dump(cout);
....
}
---------------
2. graph.hpp // has all (public/private) data members, functions //declared here
#ifndef __GRAPH_H__
#define __GRAPH_H__
# include <algorithm>
# include <iostream>
# include <memory>
# include <vector>
# include <random>
# include <stack>
# include <list>
# include <set>
# include <map>
//stating as in C header files:
int new_function();// is not helping
namespace graph
{
class HalfAdjacencyMatrix
{
...
}
.....
}
-----------------
3. New main.cpp file that will just call the renamed function: new_function();
int main(int argc, char** argv)
{
new_function();
}
| |