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


C++ graph::GraphCreatorFile类代码示例

本文整理汇总了C++中graph::GraphCreatorFile的典型用法代码示例。如果您正苦于以下问题:C++ GraphCreatorFile类的具体用法?C++ GraphCreatorFile怎么用?C++ GraphCreatorFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: parmetis_with_metmmd

void parmetis_with_metmmd(){
    DEBUG("########## Testing Function : %s #################\n", __FUNCTION__);
    int size, rank;
    MPI_Comm comm;
    Graph::GraphEOUtil eoutil;
    Graph::VertexWeightedGraph *wmg;
    Graph::GraphCreatorFile creator;

    int output[] =
    {
        102,58,128,121,86,64,96,112,103,117,120,87,124,126,127,63,95,108,110,111,91,107,109,119,123,125,115,59,61,62,90,93,122,114,106,118,32,116,55,100,16,79,84,78,24,48,52,56,44,54,60,80,28,30,31,40,46,47,72,76,88,92,94,104,8,101,1,42,4,25,97,81,6,7,3,2,73,49,13,5,9,11,17,33,65,66,67,69,10,18,19,21,34,35,37,41,113,15,68,105,77,50,14,43,20,57,12,70,53,51,23,22,36,38,82,83,98,99,74,26,27,29,39,45,71,75,85,89
    };

    MPI_Comm_dup(MPI_COMM_WORLD, &comm);
    MPI_Comm_size(MPI_COMM_WORLD, &size);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);

    creator.set_file_name("data/1dc.128.txt");
    creator.set_graph_type("DIMACS");
    wmg = creator.create_weighted_mutable_graph();

    vector<int> ordering(wmg->get_num_nodes(), -1);
    eoutil.parmetis_elimination_ordering(wmg, ordering, GD_METIS_MMD, false, comm);
    if(rank == 0){
        int n = wmg->get_num_nodes();
        for(int i = 0; i < n; i++){
            assert (output[i] == ordering[i]);
        }
        cout << "Parmetis Test " << ++testcount << " : Passed" << endl;
    }
} // parmetis_with_metmmd
开发者ID:MattBBaker,项目名称:INDDGO-survey,代码行数:31,代码来源:ParmetisTest.cpp

示例2: main

int main(int argc, char **argv){
    if((argc != 2) || (strcmp(argv[1],"-h") == 0) || (strcmp(argv[1],"--help") == 0) ){
        usage(argv[0]);
    }

    Graph::VertexWeightedGraph *G;

    Graph::GraphCreatorFile creator;
    creator.set_file_name(argv[1]);
    creator.set_graph_type("DIMACS");
    G = creator.create_weighted_mutable_graph();
    G->complement();
    Graph::GraphWriter writer;

    char comp_DIMACS_file[200];
    char normalized_comp_DIMACS_file[200];
    sprintf(comp_DIMACS_file,"%s.comp",argv[1]);
    writer.write_graph(G,comp_DIMACS_file,"DIMACS",true,false);
    // Now normalize it
    sprintf(normalized_comp_DIMACS_file,"%s.norm",comp_DIMACS_file);
    normalize_DIMACS_file(comp_DIMACS_file,normalized_comp_DIMACS_file);
    fprintf(stderr,"Complement graph of %s written to %s in normalized DIMACS form\n",
            argv[1],normalized_comp_DIMACS_file);

    delete G;
    return 1;
} // main
开发者ID:MattBBaker,项目名称:INDDGO-survey,代码行数:27,代码来源:complement.cpp

示例3: find_elim_ordering


//.........这里部分代码省略.........
        }
        xadj.push_back(j);
    }

    if (METIS_OK != ParMETIS_V3_NodeND(&vtxdist.front(), &xadj.front(), &adjncy.front(), &numflag, options, &ordering.front(), &sizes.front(), &comm))
    {
        FERROR("error occured while processing parmetis, aborting\n");
        MPI_Abort(MPI_COMM_WORLD, -1);
    }

    DEBUG("output from ParMETIS\n");
    double parmet_time = MPI_Wtime() - xtime;

    vector<int> recvbuf;
    n = G->get_num_nodes();
    if (wr == 0)
    {
        recvbuf = vector<int>(n, 0);
    }

    if (MPI_SUCCESS !=
        MPI_Gatherv((void *)&ordering.front(), recvcnt[wr], MPI_INT,
                    (void *)&recvbuf.front(), &recvcnt.front(), &displ.front(), MPI_INT,
                    0, comm))
    {
        FERROR("MPI error occured at Gatherv, Abort!\n");
        MPI_Abort(comm, -1);
    }

    vector<int> eo(n, 0);
    if (wr == 0)
    {
        for (int i = 0; i < n; i++)
        {
            eo[recvbuf[i]] = i;
        }

        FILE *f = fopen(eoname_other, "w");
        for (int i = 0; i < n; i++)
            fprintf(f, "%d\n", eo[i] + 1);
        fclose(f);
        DEBUG("ParMetis NodeND elimination ordering is in : %s\n", eoname_other);
    }

    ordering.clear();
    ordering.resize(recvcnt[wr], 0);

    if (MPI_SUCCESS !=
        MPI_Scatterv ((void *)&eo.front(), &recvcnt.front(), &displ.front(), MPI_INT,
                      (void *)&ordering.front(), recvcnt[wr], MPI_INT,
                      0, comm))
    {
        FERROR("MPI error occured at Scatterv, Abort! \n");
        MPI_Abort(comm, -1);
    }

    DEBUG("Scatterv completed\n");

    Graph::GraphCreatorFile gf;
    Graph::VertexWeightedGraph *wg;
    Graph::GraphEOUtil eoutil;
    Graph::GraphProperties prop;
    list<int>members(ordering.begin(), ordering.end());

    wg = gf.create_component(G, &members, false);
    prop.make_canonical(wg);

    vector<int> ord(recvcnt[wr], 0);
    vector<int> ordsend(recvcnt[wr, 0]);
    double xxtime = MPI_Wtime();
    eoutil.find_elimination_ordering(wg, &ord, GD_AMD, false);
    DEBUG("eo time : %f\n", MPI_Wtime() - xxtime);
    
    int sz = recvcnt[wr];

    for (int i = 0; i < sz; i++)
        ordsend[i] = wg->get_node(ord[i])->get_label();


    recvbuf.assign(n, -1);
    if (MPI_SUCCESS !=
        MPI_Gatherv((void *)&ordsend.front(), recvcnt[wr], MPI_INT, (void *)&recvbuf.front(), &recvcnt.front(), &displ.front(), MPI_INT, 0, comm))
    {
        FERROR("MPI error occured at Gatherv, Abort!\n");
        MPI_Abort(comm, -1);
    }

    double p_amd_time = MPI_Wtime() - xtime;
    if (wr == 0)
    {
        FILE *f = fopen(eoname, "w");
        for (int i = 0; i < n && wr == 0; i++)
            fprintf(f, "%d\n", recvbuf[i]);
        fclose(f);
    } 
    DEBUG("ordering is written into %s\n", eoname);
    DEBUG("%f,%f\n", parmet_time, p_amd_time);

    return 0;
}
开发者ID:MattBBaker,项目名称:INDDGO-survey,代码行数:101,代码来源:ORD.cpp

示例4: main

int main(int argc, char **argv){
    // This is a utility to generate partial k-trees with specified parameters for use in other applications.

    // Check for a cry for help
    if((argc == 1) || ((argc == 2) && (strcmp(argv[1],"-h") == 0)) || ((argc == 2) && (strcmp(argv[1],"--help") == 0))
       || ((argc == 2) && (strcmp(argv[1],"--h") == 0) ) ){
        usage(argv[0]);
        exit(-1);
    }

    ORB_t t1=0, t2=0, t3=0;
    int i;
    int t = 1;
    int ktree_n = -1, ktree_k = -1, ktree_p = -1;
    int seed = 0;
    Graph::VertexWeightedGraph *G = NULL, *H = NULL;
    time_t start, stop;
    char filename[100];
    char *prefix = (char *)"pkt";
    string out_format = "DIMACS";

    bool random = false;
    bool timings = false;
    bool exact_filename = false;
    char lfname[100];
    char efname[100];
    sprintf(lfname, "genpkt.log");
    sprintf(efname, "genpkt.log");
    //0: debug, 5: critical
    LOG_INIT(lfname, efname, 0);

    // Parse arguments
    for(i = 0; i < argc; i++){
        if(strcmp(argv[i],"-t") == 0){
            t = atoi(argv[i + 1]);
        }
        if(strcmp(argv[i],"-k") == 0){
            ktree_k = atoi(argv[i + 1]);
        }
        if(strcmp(argv[i],"-n") == 0){
            ktree_n = atoi(argv[i + 1]);
        }
        if(strcmp(argv[i],"-p") == 0){
            ktree_p = atoi(argv[i + 1]);
        }
        if(strcmp(argv[i],"-o") == 0){
            out_format = string(argv[i + 1]);
        }
        if(strcmp(argv[i],"-s") == 0){
            seed = atoi(argv[i + 1]);
        }
        if(strcmp(argv[i],"-fn") == 0){
            prefix = argv[i + 1];
        }
        if(strcmp(argv[i],"-fe") == 0){
            prefix = argv[i + 1];
            exact_filename = true;
        }
        if(strcmp(argv[i],"-m") == 0){
            timings = true;
        }
        if(strcmp(argv[i],"-r") == 0){
            random = true;
        }
    }

    if((true == exact_filename) && (t != 1)){
        cerr << "Error: cannot specify both -t and -fe flags\n";
        exit(1);
    }

    if(("adjlist" != out_format) && ("dimacs" != out_format)){
        cerr << "Error: only allowed output formats are: adjlist, dimacs\n";
        exit(1);
    }

    // Spin the RNG seed times
    for(int ss = 0; ss < seed; ss++){
        Graph::lcgrand(0);
    }

    //Make sure we set all the parameters to viable values.
    if((ktree_k < 0) || (ktree_n < 0) || (ktree_p < 0)){
        fatal_error("Failed to input viable parameters for n, k, p (%d,%d,%d)\n",
                    ktree_k, ktree_n, ktree_p);
    }

    Graph::GraphCreatorFile creator;
    Graph::GraphProperties prop;
    Graph::GraphWriter writer;

    //ORB_calibrate();

    DEBUG("Graph generation loop\n");
    DEBUG("n : %d k: %d\n", ktree_n, ktree_p);
    for(i = 0; i < t; i++){
        // Create the Ktree
        //H = new Graph::Graph(ktree_n, ktree_k);
        cout << "Generating k-tree\n";
        H = creator.initialize_ktree(ktree_n, ktree_k);
//.........这里部分代码省略.........
开发者ID:cgroer,项目名称:INDDGO,代码行数:101,代码来源:gen_pkt.cpp

示例5: main

int main(int argc, char **argv)
{
    // This is a utility to generate partial k-trees with specified parameters for use in other applications.

    // Check for a cry for help
    if(argc==1 || (argc==2 && strcmp(argv[1],"-h")==0) || (argc==2 && strcmp(argv[1],"--help")==0) 
        || (argc==2 && strcmp(argv[1],"--h")==0) )
    {
        usage(argv[0]);
        exit(-1);
    }

    int i;
    int t = 1;
    int ktree_n=-1, ktree_k=-1, ktree_p=-1;
    int seed=0;
	Graph::WeightedMutableGraph *G=NULL, *H=NULL; 
    time_t start, stop;
    char filename[100];
    char *prefix= (char *)"pkt";
    
    bool random = false, write_scotch=false;
    char lfname[100];
    char efname[100];
    sprintf(lfname, "genpkt.log");
    sprintf(efname, "genpkt.log");
    //0: debug, 5: critical
    LOG_INIT(lfname, efname, 0);

    // Parse arguments
    for(i=0;i<argc;i++)
    {
        if(strcmp(argv[i],"-t")==0)
        {
            t=atoi(argv[i+1]);
        }
        if(strcmp(argv[i],"-k")==0)
        {
            ktree_k=atoi(argv[i+1]);
        }
        if(strcmp(argv[i],"-n")==0)
        {
            ktree_n=atoi(argv[i+1]);
        }
        if(strcmp(argv[i],"-p")==0)
        {
            ktree_p=atoi(argv[i+1]);
        }
        if(strcmp(argv[i],"-s")==0)
        {
            seed=atoi(argv[i+1]);
        }
        if(strcmp(argv[i],"-fn")==0)
            prefix = argv[i+1];
        if(strcmp(argv[i],"-r")==0)
            random = true;
        if(strcmp(argv[i],"-scotch")==0)
            write_scotch = true;
    }

    if(!seed)
        // Set the seed to a rand int in 0,2^24
        seed=Graph::rand_int(0,0xffffff);
    // Spin the RNG seed times
    for(int ss=0;ss<seed;ss++)
        Graph::lcgrand(0);

    //Make sure we set all the parameters to viable values. 
    if(ktree_k < 0 || ktree_n < 0 || ktree_p < 0)
	{
	    fatal_error("Failed to input viable parameters for n, k, p (%d,%d,%d)\n",
            ktree_k, ktree_n, ktree_p);
	}
    
    Graph::GraphCreatorFile creator;
    Graph::GraphWriter *writer;
    Graph::GraphReaderWriterFactory rwf;
    Graph::GraphProperties prop;

    writer = rwf.create_writer("DIMACS", "t");

    DEBUG("Graph generation loop\n");
    DEBUG("n : %d k: %d\n", ktree_n, ktree_p);
    for(i = 0; i < t; i++)
    {
	    // Create the Ktree
	    //H = new Graph::Graph(ktree_n, ktree_k);
        H = creator.initialize_ktree(ktree_n, ktree_k);
	    // Generate an n-node Graph G that is a partial k-tree derived from the k-tree
	    start=clock();
	    G= creator.create_random_edge_subgraph(H, ktree_p);
	    stop=clock();
	    fprintf(stderr,"Generated random partial k-tree (%d,%d) in %f sec.\n",
		   ktree_n, ktree_k, ((double)(stop-start))/CLOCKS_PER_SEC);
	    //write it to a file
	    sprintf(filename, "%s.%d.%d.%d_%d.dimacs", prefix, ktree_n,ktree_k,ktree_p, i);
        print_message(0,"Writing file %s\n",filename);

        writer->set_out_file_name(filename);

//.........这里部分代码省略.........
开发者ID:xydinesh,项目名称:INDDGO,代码行数:101,代码来源:gen_pkt.cpp

示例6: SetUp

virtual void SetUp(){
    //SetUp is called before every test
    LOG_INIT("test.log", NULL, 0);
    creator.set_file_name("data/1dc.128.txt");
    creator.set_graph_type("DIMACS");
    mg = creator.create_mutable_graph();
}
开发者ID:MattBBaker,项目名称:INDDGO-survey,代码行数:7,代码来源:GraphEOUtilTest.cpp

示例7: SetUp

virtual void SetUp(){
    LOG_INIT("test.log", NULL, 0);
    //creator.set_file_name("../data/1dc.128.txt");
    creator.set_file_name("data/1dc.128.txt");
    creator.set_graph_type("DIMACS");
    g = creator.create_graph();
    g_five = new Graph::Graph(5);
}
开发者ID:abitofalchemy,项目名称:INDDGO,代码行数:8,代码来源:GraphTest.cpp

示例8: SetUp

virtual void SetUp(){
    //SetUp is called before every test
    LOG_INIT("test.log", NULL, 0);
    creator.set_file_name("data/1dc.128.adj");
    creator.set_graph_type("adjmatrix");
    g = creator.create_graph();

    in_file = ("data/1dc.128.met");
}
开发者ID:MattBBaker,项目名称:INDDGO-survey,代码行数:9,代码来源:MetisGraphReaderTest.cpp

示例9: SetUp

	virtual void SetUp()
	{
		LOG_INIT("test.log", NULL, 0);
		gr = factory.create_reader("DIMACS");
		gr->read_graph("data/1dc.128.txt");

		creator.set_file_name("data/1dc.128.txt");
		creator.set_graph_type("DIMACS");
		g = creator.create_graph();
	}
开发者ID:zbhuang,项目名称:INDDGO,代码行数:10,代码来源:GraphReaderWriterFactoryTest.cpp

示例10: SetUp

	virtual void SetUp()
	{
		//SetUp is called before every test
		LOG_INIT("test.log", NULL, 0);
		creator.set_file_name("../data/1dc.128.adj");
		creator.set_graph_type("adjmatrix");
		g = creator.create_graph();

		string out_file("../data/1dc.128.out");
		dim_writer = new Graph::DIMACSGraphWriter(out_file);
	}
开发者ID:xydinesh,项目名称:INDDGO,代码行数:11,代码来源:DIMACSGraphWriterTest.cpp

示例11: SetUp

	virtual void SetUp()
	{
		//SetUp is called before every test
		LOG_INIT("test.log", NULL, 0);
		creator.set_file_name("data/1dc.128.adj");
		creator.set_graph_type("adjmatrix");
		g = creator.create_graph();

		string in_file("data/1dc.128.met");
		mr = new Graph::MetisGraphReader(in_file);
	}
开发者ID:zbhuang,项目名称:INDDGO,代码行数:11,代码来源:MetisGraphReaderTest.cpp


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