当前位置: 首页>>代码示例>>C++>>正文


C++ ListDigraph::id方法代码示例

本文整理汇总了C++中ListDigraph::id方法的典型用法代码示例。如果您正苦于以下问题:C++ ListDigraph::id方法的具体用法?C++ ListDigraph::id怎么用?C++ ListDigraph::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ListDigraph的用法示例。


在下文中一共展示了ListDigraph::id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: drawGraphToFileWithArcMap

void drawGraphToFileWithArcMap(ListDigraph& g, ListDigraph::ArcMap<int>& map){
	ofstream myfile;
	myfile.open("graph.dot");
	myfile << "digraph g {\n";
	for (ListDigraph::ArcIt a(g); a!= INVALID; ++a)
	{
		myfile << g.id(g.source(a)) << " -> " << g.id(g.target(a)) << " [label=\"" << map[a] << "\"] \n";
	}
	myfile << "}\n";
	myfile.close();
}
开发者ID:tobtobtob,项目名称:MC-MPC,代码行数:11,代码来源:test_utils.cpp

示例2: drawGraphToFile

void drawGraphToFile(ListDigraph& g){
	ofstream myfile;
	myfile.open("graph.dot");
	myfile << "digraph g {\n";
	for (ListDigraph::ArcIt a(g); a!= INVALID; ++a)
	{
		myfile << g.id(g.source(a)) << " -> " << g.id(g.target(a)) <<  "\n";
	}
	myfile << "}\n";
	myfile.close();
}
开发者ID:tobtobtob,项目名称:MC-MPC,代码行数:11,代码来源:test_utils.cpp

示例3: main

int main(int argc, char* argv[]){
  tMax = 600;
  int verbose = 0;
  std::string input_file;
  int option, i_f = 0;
  if ( argc == 1 ){
    show_usage();
    return 0;
  }
  while ((option = getopt(argc, argv, "t:i:v"))!=-1)
    switch(option){
      case 't':
        tMax=atoi(optarg);
        break;
      case 'i':
        i_f = 1;
        input_file.assign(optarg);
        break;
      case 'v':
        verbose=1;
        break;
      default:
        break;
    }

  if ( i_f == 0 ){
    std::cout << "-i  mandatory argument" << std::endl;
    return 1;
  }

  if ( !read_pcpath(input_file) ) return 1;

  for ( ListDigraph::NodeIt u(g); u!=INVALID; ++u ){
    if ( node_names[u].compare("s")==0 )
      s=u;
    if ( node_names[u].compare("t")==0 )
      t=u;
  }

  //if ( verbose )
  //  show_input();

  prize_collecting_st_path_pli(g, prizes, costs, s, t, path, UB, LB, tMax);
  if ( verbose ){
    //make_eps_graph(path, "sol");
    //set_pdfreader("okular");
    //set_pdfreader("open");
    //set_pdfreader("xpdf");
    show_graph_mygraphlib(input_file);
  }

  for ( int i=0; i<(int)path.size(); i++ )
    std::cout << g.id(path[i]) << " ";
  std::cout << std::endl;
  return 0;
}
开发者ID:andrenbrandao,项目名称:mc658_lab05,代码行数:56,代码来源:prizecollectingpath.cpp

示例4: main

int main(){


    string a = "88\t567 999\t444 555\n22\t777 666\t111 000";
    string  file, line;
    int     out1, out2;
    
    istringstream   mStream( a );
//    ifstream mStream( "/Users/sonneundasche/Dropbox/FLI/04_HIT_Transform/_node size/Schwein_BL_07_time_tmpArcIDs_amountOnArc.txt" );
//    getline( mStream, file, '\n');
    
    while(getline( mStream, file, '\n')){
        istringstream lineStream( file );
        lineStream  >> out1;
        cout << "time: " << out1 << "\n";
        getline( lineStream, line, '\t');
        
        while( getline( lineStream, line, '\t') ){
            istringstream pairStream( line );
            pairStream >> out1;
            pairStream >> out2;
            cout << out1 << " : " << out2 << "\n";
            }
        }
    
//    
    vector< int >  activeTimes;
    ListDigraph   mGraph;
    digraphReader( mGraph, "/Users/sonneundasche/Dropbox/FLI/04_HIT_Transform/_node size/Schwein_BL_07.lgf")
    .run();

    
    map< int,  vector< pair <ListDigraph::Arc, int > > >  activeArcsAndWeight;
    
    activeTimes = tempGR::readTemporalArcListWeighted(mGraph, activeArcsAndWeight, "/Users/sonneundasche/Dropbox/FLI/04_HIT_Transform/_node size/Schwein_BL_07_time_tmpArcIDs_amountOnArc.txt");
    
    for (auto i : activeArcsAndWeight[2486]) {
        cout << mGraph.id( activeArcsAndWeight[2492][0].first ) << " : " << i.second << "\n";
    }

    cout << mGraph.id( activeArcsAndWeight[2492][0].first ) << " : " << activeArcsAndWeight[2492][0].second << endl;
    
}
开发者ID:BildPeter,项目名称:DynamicNetSim,代码行数:43,代码来源:StringStream.cpp

示例5: main

int main( void ){
    
    /*
     --- Daten Anordnung ---
     From	To	Amount	Date
     560739	254569	7	2682
     913338	356536	1	3497
     */
        
    string edgeListSource   = "TradingData.txt";
    string lemonFileTmp     = "DataTMP.lgf";
    string lemonFileOut     = "DataProcessed.lgf";
    
    boost::unordered_set< unsigned int >                        uniqueNodes; // Mathematische Menge (set) der Knoten
    boost::unordered_set< pair< unsigned int, unsigned int > >  uniqueArcs;  // Menge der Kanten (set von Knoten-Paaren)
    
    ifstream    myEdgeListFile( edgeListSource );
    string      foo;  // kill first line, because it has the header
    getline(myEdgeListFile, foo);    
    
    unsigned int from, to, amount, day;
    
    // Einlesen der Werte in die Menge. Paar-Erstellung.
    while ( myEdgeListFile.good() ){
        
        myEdgeListFile >> from;
        myEdgeListFile >> to;
        myEdgeListFile >> amount;
        myEdgeListFile >> day;
        
        uniqueNodes.insert( from );
        uniqueNodes.insert( to );
        uniqueArcs.insert( make_pair( from, to ) );
    }
    cout << "Nodes: " << uniqueNodes.size() << " Arcs: " << uniqueArcs.size() << endl;;
    
    // ----------------------------------------------------------------------------------------
    // Schreiben der LFG durch eigene Routine
    // ----------------------------------------------------------------------------------------
    
    ofstream myLemonFile( lemonFileTmp );
    
    // ----- Nodes -----
    myLemonFile << "@nodes" << endl;
    myLemonFile << "label" << "\t" << "name" << endl;
    for (auto iter = uniqueNodes.begin(); iter != uniqueNodes.end(); iter++) {
        myLemonFile << *iter << "\t" 
        << *iter << endl;
    }
    
    myLemonFile << endl << endl << "@arcs" << endl;
    myLemonFile << "\t\tfrom\tto" << endl;
    for (auto iterArcs = uniqueArcs.begin(); iterArcs  != uniqueArcs.end(); iterArcs++ ){
        myLemonFile << (*iterArcs).first    << "\t"         // Erster  Paar-Eintrag für LEMON, damit es mit den Nodes übereinstimmt
        << (*iterArcs).second    << "\t"
        << (*iterArcs).first    << "\t"         // Zweiter Paar-Eintrag erhält die alten IDs, damit die Daten nicht beim Umwandeln verloren gehen
        << (*iterArcs).second   << endl;
    }
    
    // =========================================================================================
    // Create Graph and Format in a Lemon friendly way
    // Hier erhalten die Knoten und Kanten LEMON IDs
    ListDigraph myCulmiGraph;
    ListDigraph::NodeMap< unsigned int >    nameNodeMap( myCulmiGraph );
    ListDigraph::ArcMap< unsigned int >     fromNdArcMap( myCulmiGraph );
    ListDigraph::ArcMap< unsigned int>      toNdArcMap   ( myCulmiGraph );
    ListDigraph::ArcMap< bool >             activeArcsMap( myCulmiGraph );
    
    timeToActiveArcs    dayActivityArcIDs; //Menge an Zeitpunkten (int) und den dazu gehörigen aktiven Kanten (vec)
    
    boost::unordered_map< unsigned int, unsigned int >              origIDtoLemon;
    
    // Hier besitzen die Knoten & Kanten noch original IDs (name) 
    digraphReader( myCulmiGraph, lemonFileTmp)
    .nodeMap( "name", nameNodeMap )
    .arcMap( "from", fromNdArcMap )
    .arcMap( "to", toNdArcMap)
    .run();
    
    
    cout << "LEMON - Nodes: " << countNodes( myCulmiGraph ) << " Arcs: " << countArcs( myCulmiGraph ) << endl;
    
    // Ausgabe der neuen LEMON IDs für Knoten und Kanten
    digraphWriter( myCulmiGraph, lemonFileOut)
    .nodeMap( "name", nameNodeMap )
    .arcMap( "from", fromNdArcMap )
    .arcMap( "to" , toNdArcMap )
    .run();
    
    // =========================================================================================
    // Create HashMap of time and active arc pairs
    
    
    // Eine Map, die original KnotenIDs zu LEMON IDs zuweist (LemonMap Umkehr, statisch)
    // Nötig, da ich die orginalIDs aus der Ursprungsdatei einlese
    for (ListDigraph::NodeIt n( myCulmiGraph ) ; n!=INVALID; ++n) {
        origIDtoLemon[ nameNodeMap[ n ] ] = myCulmiGraph.id( n );
    }
        
    myEdgeListFile.close();
//.........这里部分代码省略.........
开发者ID:BildPeter,项目名称:DynamicNetSim,代码行数:101,代码来源:TemporalActiveArcs.cpp


注:本文中的ListDigraph::id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。