Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Graphe.hpp"
- Graphe::Graphe(const string nom) : nombreSommets(0){
- ifstream fichier;
- int i = 0, max;
- fichier.open(nom.c_str());
- if (!fichier.fail()) {
- int nombre_de_successeurs = 0;
- fichier >> nombreSommets;
- v.resize(nombreSommets);
- for (int i = 0; i < nombreSommets; ++i) {
- fichier >> nombre_de_successeurs;
- v[i].resize(nombre_de_successeurs);
- for (int j = 0; j < nombre_de_successeurs; ++j) {
- fichier >> v[i][j];
- }
- }
- fichier.close();
- }
- }
- void Graphe::afficher(const string nomFichierDot) {
- // création fichier .dot
- string nom = nomFichierDot + ".dot";
- ofstream fichierDot(nom);
- if (fichierDot) {
- fichierDot << "digraph G {" << endl;
- for (int i=0; i<v.size(); ++i) {
- fichierDot << "/t'" << v[i][0] << "'";
- for (int j=1; j<v[i].size(); ++i) {
- fichierDot << " -> '" << v[i][j] << "'";
- }
- fichierDot << ";" << end;
- }
- fichierDot << "}";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement