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
|
#include <iostream>
#include <vector>
#include <ctime>
#include <set>
#include <fstream>
#include <string>
#include <unordered_set>
#include <cstdlib>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/graph/adjacency_list.hpp>
using namespace std;
using namespace boost;
using namespace boost::algorithm;
/*********************************************/
//vertex
struct VertexProperties
{
int id;
int label;
VertexProperties(){}
VertexProperties(unsigned i, unsigned l) : id(i), label(l) {}
};
//edge
struct EdgeProperties
{
unsigned id;
unsigned label;
EdgeProperties(){}
EdgeProperties(unsigned i, unsigned l) : id(i), label(l) {}
};
//Graph
struct GraphProperties
{
unsigned id;
unsigned label;
GraphProperties() {}
GraphProperties(unsigned i, unsigned l) : id(i), label(l) {}
};
//adjency list
typedef boost::adjacency_list<
boost::vecS, boost::vecS, boost::directedS,
VertexProperties,
EdgeProperties,
GraphProperties
> Graph;
//descriptors
typedef boost::graph_traits<Graph>::vertex_descriptor vertex_t;
typedef std::pair<boost::graph_traits<Graph>::edge_descriptor, bool> edge_t;
//iterators
typedef graph_traits<Graph>::vertex_iterator vertex_iter;
typedef graph_traits<Graph>::edge_iterator edge_iter;
/****************************************************************************/
//le seuil int seuil;
std::vector<std::string> tokens;
/*
programme principal
*/
int main()
{
vector<Graph> dataG; // vector<graphes> * pointsdataG;
ifstream * file_reader= new ifstream("5.txt" ); //flux d'entrée pour opérer sur les fichiers.
while (!file_reader->eof())
{
string line;
file_reader->sync(); //Synchronise le tampon d'entree avec la source de donnees associee.
getline(*file_reader, line); //lire les caracteres a partir du flux d'entree (file_reader) et les place dans une chaine: (line)
if(line[0]=='t') // ligne de transaction(graphe)
{
split(tokens, line, is_any_of(" "));
int gid=atoi(tokens[2].c_str());
Graph g(GraphProperties(gid,gid));
cout<<gid<<endl;
dataG.push_back(g);
}
}
std::cout << "myvector contains:";
for (std::vector<Graph>::iterator it = myvector.begin() ; it != myvector.end(); ++it)
{
std::cout << ' ' << (*it).label;
std::cout << '\n';
}
} |
Partager