Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.55 KB | None | 0 0
  1. if(goodMemList.size() != 0){
  2.     // itero sulla lista per costruire i nodi
  3.     for (std::list<Mem>::iterator it = goodMemList.begin(),
  4.        end = goodMemList.end(); it != end; ++it) {
  5.       Node IntronMem;
  6.       IntronMem = IntronGraph.addNode();
  7.       it->setIntronNode(IntronMem);
  8.       IntronNodesMap[IntronMem] = *it;
  9.     }
  10.  
  11.     // calcolo numero nodi
  12.     int numberN = 0;
  13.     for (lemon::ListDigraph::NodeIt n(IntronGraph); n != lemon::INVALID; ++n){
  14.       numberN++;
  15.     }
  16.     // per ora archi con peso 0 tra ogni nodo e il suo consecutivo
  17.     // for (lemon::ListDigraph::NodeIt u(IntronGraph); u != lemon::INVALID; ++u){
  18.     //   for (lemon::ListDigraph::NodeIt v(IntronGraph); v != lemon::INVALID; ++v){
  19.     //     if (u < v) {
  20.     //  Arc arc = IntronGraph.addArc(u, v);
  21.     //  IntronEdgesMap[arc] = 0;
  22.     //     }
  23.     //   }
  24.     // }
  25.     for(int i = 0; i < numberN - 1; i++){
  26.       Arc arc = IntronGraph.addArc(IntronGraph.nodeFromId(i),
  27.                    IntronGraph.nodeFromId(i + 1));
  28.       IntronEdgesMap[arc] = 0;
  29.     }
  30.     // stampo numero di nodi, numero di archi e "stampo" il grafo
  31.  
  32.     if(numberN > 1 ){
  33.       std::cout << "Number of nodes: " << numberN << std::endl;  
  34.       int numberA = 0;
  35.       for (lemon::ListDigraph::ArcIt arc(IntronGraph);
  36.        arc != lemon::INVALID; ++arc){
  37.     numberA++;
  38.       }
  39.       std::cout << "Number of arcs: " << numberA << std::endl;
  40.       for (lemon::ListDigraph::ArcIt arc(IntronGraph);
  41.        arc != lemon::INVALID; ++arc){
  42.     auto idNodeS = IntronGraph.id(IntronGraph.source(arc));
  43.     auto idNodeT = IntronGraph.id(IntronGraph.target(arc));
  44.     auto idArc = IntronGraph.id(arc);
  45.     std::cout << "Arc " << idArc << " goes from node "
  46.           << IntronGraph.id(IntronGraph.source(arc)) << " ("
  47.           << IntronNodesMap[IntronGraph.nodeFromId(idNodeS)].t
  48.           << " "
  49.           << IntronNodesMap[IntronGraph.nodeFromId(idNodeS)].p
  50.           << " "
  51.           << IntronNodesMap[IntronGraph.nodeFromId(idNodeS)].l
  52.           << ") to node "
  53.           << IntronGraph.id(IntronGraph.target(arc)) << " ("
  54.           << IntronNodesMap[IntronGraph.nodeFromId(idNodeT)].t
  55.           << " "
  56.           << IntronNodesMap[IntronGraph.nodeFromId(idNodeT)].p
  57.           << " "
  58.           << IntronNodesMap[IntronGraph.nodeFromId(idNodeT)].l
  59.           << "), weight = " << IntronEdgesMap[arc] << std::endl;
  60.       }
  61.     }else if (numberN == 1){
  62.       std::cout << "one node: " <<  IntronNodesMap[IntronGraph.nodeFromId(0)].t
  63.         << " " << IntronNodesMap[IntronGraph.nodeFromId(0)].p << " "
  64.         << IntronNodesMap[IntronGraph.nodeFromId(0)].l << " "
  65.         << std::endl;
  66.     }else{
  67.       std::cout << "no node\n";
  68.     }
  69.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement