Advertisement
Guest User

Untitled

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