Exemplo n.º 1
0
void build_gcsa_lcp(const HandleGraph& graph,
                    gcsa::GCSA*& gcsa,
                    gcsa::LCPArray*& lcp,
                    int kmer_size,
                    size_t doubling_steps,
                    size_t size_limit,
                    const string& base_file_name) {
    
    // Add an overlay with the source and sink nodes for GCSA
    SourceSinkOverlay overlay(&graph, kmer_size);
    gcsa::ConstructionParameters params;
    params.setSteps(doubling_steps);
    params.setLimit(size_limit);

    // Generate the kmers and reduce the size limit by their size.
    size_t kmer_bytes = params.getLimitBytes();
    string tmpfile = write_gcsa_kmers_to_tmpfile(overlay, kmer_size,
                                                 kmer_bytes,
                                                 overlay.get_id(overlay.get_source_handle()),
                                                 overlay.get_id(overlay.get_sink_handle()),
                                                 base_file_name);
    params.reduceLimit(kmer_bytes);

    // set up the input graph using the kmers
    gcsa::InputGraph input_graph({ tmpfile }, true);
    // run the GCSA construction
    gcsa = new gcsa::GCSA(input_graph, params);
    // and the LCP array construction
    lcp = new gcsa::LCPArray(input_graph, params);
    // delete the temporary debruijn graph file
    temp_file::remove(tmpfile);
    // results returned by reference
}
Exemplo n.º 2
0
void main()
{
	int src,dest,predecessor[MAXNODES],d,i;
	//initialize predecessor
	for(i=0;i<MAXNODES;i++)
		predecessor[i] = -1; //no shortest path found thus no predecessor at starting

	printf("Input graph\n");
	input_graph(w_graph);
	printf("input source and destination node\n");
	scanf("%d%d",&src,&dest);
	shortpath(w_graph,src,dest,&d,predecessor);
	printf("distance = %d\n",d);
	printf("path \n");
	for(i=0;i<MAXNODES;i++)
		printf("%d\t",predecessor[i]);
	printf("\n");
}
Exemplo n.º 3
0
int main(int argn, char **argv) {
    MPI_Init(&argn, &argv);

    int rank, size;
    MPI_Comm communicator = MPI_COMM_WORLD;
    MPI_Comm_rank(communicator, &rank);
    MPI_Comm_size(communicator, &size);

    PPartitionConfig partition_config;
    DspacConfig dspac_config;
    std::string graph_filename;

    int ret_code = parse_dspac_parameters(argn, argv, partition_config, dspac_config, graph_filename);

    if (ret_code) {
        MPI_Finalize();
        return 0;
    }
    if (rank == ROOT) {
        std::cout << "graph: " << graph_filename << "\n"
                  << "infinity edge weight: " << dspac_config.infinity << "\n"
                  << "seed: " << partition_config.seed << "\n"
                  << "k: " << partition_config.k << "\n"
                  << "ncores: " << size << std::endl;
    }

    timer t;
    MPI_Barrier(MPI_COMM_WORLD);
    {
        t.restart();
        if (rank == ROOT) std::cout << "running collective dummy operations ";
        dummy_operations dop;
        dop.run_collective_dummy_operations();
    }
    MPI_Barrier(MPI_COMM_WORLD);

    if (rank == ROOT) {
        std::cout << "took " << t.elapsed() << std::endl;
    }

    // load input graph
    t.restart();
    parallel_graph_access input_graph(communicator);
    edge_balanced_graph_io::read_binary_graph_edge_balanced(input_graph, graph_filename, partition_config, rank, size);
    if (rank == ROOT) {
        std::cout << "input IO took " << t.elapsed() << "\n"
                  << "n(input): " << input_graph.number_of_global_nodes() << "\n"
                  << "m(input): " << input_graph.number_of_global_edges() << std::endl;
    }
    MPI_Barrier(communicator);

    // construct split graph
    t.restart();
    parallel_graph_access split_graph(communicator);
    dspac splitter(input_graph, communicator, dspac_config.infinity);
    splitter.construct(split_graph);
    if (rank == ROOT) {
        std::cout << "split graph construction took " << t.elapsed() << "\n"
                  << "n(split): " << split_graph.number_of_global_nodes() << "\n"
                  << "m(split): " << split_graph.number_of_global_edges() << std::endl;
    }

    // partition split graph
    t.restart();
    executeParhip(split_graph, partition_config);
    if (rank == ROOT) {
        std::cout << "parhip took " << t.elapsed() << std::endl;
    }

    // evaluate edge partition
    t.restart();
    splitter.fix_cut_dominant_edges(split_graph);
    std::vector<PartitionID> edge_partition = splitter.project_partition(split_graph);
    EdgeWeight vertex_cut = splitter.calculate_vertex_cut(partition_config.k, edge_partition);
    if (rank == ROOT) {
        std::cout << "evaluation took " << t.elapsed() << "\n"
                  << "vertex cut: " << vertex_cut << std::endl;
    }

    if( partition_config.save_partition ) {
            parallel_vector_io pvio;
            std::string filename("tmpedgepartition.txtp");
            pvio.writePartitionSimpleParallel(split_graph, filename);
    }

    if( partition_config.save_partition_binary ) {
            parallel_vector_io pvio;
            std::string filename("tmpedgepartition.binp");
            pvio.writePartitionBinaryParallelPosix(partition_config, split_graph, filename);
    }

    MPI_Barrier(MPI_COMM_WORLD);
    MPI_Finalize();
}
Exemplo n.º 4
0
int 
main (void)
{
    extern int Using_Main;	/* is main routine being called? */
    extern char *Graph_File_Name;	/* name of graph input file */
    extern char *Geometry_File_Name;	/* name of coordinate input file */
    extern char *Assign_In_File_Name;	/* name of assignment input input file */
    extern char *PARAMS_FILENAME;	/* name of file with parameter updates */
    extern double EIGEN_TOLERANCE;	/* tolerance for eigen calculations */
    extern int OUTPUT_ASSIGN;	/* whether to write assignment to file */
    extern int DEBUG_MEMORY;	/* debug memory allocation and freeing? */
    extern int DEBUG_TRACE;	/* trace main execution path */
    extern int DEBUG_PARAMS;	/* debug flag for reading parameters */
    extern long RANDOM_SEED;	/* seed for random number generators */
    extern int ECHO;		/* controls amount of output */
    extern int PROMPT;		/* prompt for input or not? */
    extern int PRINT_HEADERS;	/* print lines for output sections? */
    extern int MATCH_TYPE;      /* matching routine to call */
    extern double input_time;	/* times data file input */
    extern double start_time;	/* time partitioning starts */
    FILE     *fin;		/* input file */
    FILE     *fingeom;		/* geometry input file (for inertial method) */
    FILE     *finassign;	/* assignment file if reading in */
    FILE     *params_file;	/* file with parameter value updates */
    double   *goal;		/* desired set sizes */
    float    *x, *y, *z;	/* coordinates for inertial method */
    int      *start;		/* start of edge list for each vertex */
    int      *adjacency;	/* edge list data */
    float    *ewgts;		/* weights for all edges */
    int      *vwgts;		/* weights for all vertices */
    int       global_method;	/* global partitioning method */
    int       local_method;	/* local partitioning method */
    int    *assignment;	/* set number of each vtx (length nvtxs+1) */
    double    eigtol;		/* tolerance in eigenvector calculation */
    int       nvtxs;		/* number of vertices in graph */
    int       ndims;		/* dimension of recursive partitioning */
    int       architecture;	/* 0 => hypercube, d => d-dimensional mesh */
    int       ndims_tot;	/* total number of cube dimensions to divide */
    int       mesh_dims[3];	/* dimensions of mesh of processors */
    long      seed;		/* for random graph mutations */
    int       rqi_flag;		/* use RQI/Symmlq eigensolver? */
    int       vmax;		/* if so, how many vertices to coarsen down to? */
    int       igeom;		/* geometry dimension if inertial method */
    char      graphname[NAME_LENGTH];	/* name of graph input file */
    char      geomname[NAME_LENGTH];	/* name of geometry input file */
    char      inassignname[NAME_LENGTH];	/* assignment input file name */
    char      outassignname[NAME_LENGTH];	/* assignment output file name */
    char      outfilename[NAME_LENGTH];	/* name of output file */
    char     *outassignptr;	/* name or null pointer for output assignment */
    char     *outfileptr;	/* name or null pointer for output file */
    int       another;		/* run another problem? */
    double    time;		/* timing marker */
    int       flag;		/* return code from input routines */
    double    seconds();	/* returns elapsed time in seconds */
    int       affirm();
    int       input_graph(), input_geom();
    void      input_queries(), read_params(), clear_timing();

/*malloc_debug(2);*/

    if (DEBUG_TRACE > 0) {
	printf("<Entering main>\n");
    }

    if (PRINT_HEADERS) {
        printf("\n                    Chaco 2.0\n");
        printf("          Sandia National Laboratories\n\n");
    }

    Using_Main = TRUE;
    another = TRUE;
    params_file = fopen(PARAMS_FILENAME, "r");
    if (params_file == NULL && DEBUG_PARAMS > 1) {
	printf("Parameter file `%s' not found; using default parameters.\n",
	       PARAMS_FILENAME);
    }

    while (another) {

	start_time = time = seconds();

	x = y = z = NULL;
	goal = NULL;
	assignment = NULL;

	read_params(params_file);

	input_queries(&fin, &fingeom, &finassign, graphname, geomname, inassignname,
		      outassignname, outfilename,
		      &architecture, &ndims_tot, mesh_dims,
		      &global_method, &local_method, &rqi_flag, &vmax, &ndims);

	if (global_method == 7)
	    Assign_In_File_Name = inassignname;
	else
	    Assign_In_File_Name = NULL;

	if (OUTPUT_ASSIGN > 0)
	    outassignptr = outassignname;
	else
	    outassignptr = NULL;

	if (ECHO < 0)
	    outfileptr = outfilename;
	else
	    outfileptr = NULL;

	flag = input_graph(fin, graphname, &start, &adjacency, &nvtxs, &vwgts, &ewgts);
	if (flag) {
	    sfree(ewgts);
	    sfree(vwgts);
	    sfree(adjacency);
	    sfree(start);
	    goto skip;
	}

	Graph_File_Name = graphname;

	assignment = smalloc(nvtxs * sizeof(int));
	if (global_method == 7) {
	    flag = input_assign(finassign, inassignname, nvtxs, assignment);
	    if (flag)
		goto skip;
	    Assign_In_File_Name = inassignname;
	}

	if (global_method == 3 ||
	    (MATCH_TYPE == 5 && (global_method == 1 || 
				 (global_method == 2 && rqi_flag)))) {
	    /* Read in geometry data. */
	    flag = input_geom(fingeom, geomname, nvtxs, &igeom, &x, &y, &z);
	    if (flag)
		goto skip;
	    Geometry_File_Name = geomname;
	}
	else {
	    x = y = z = NULL;
	}

	input_time += seconds() - time;

	eigtol = EIGEN_TOLERANCE;
	seed = RANDOM_SEED;

	interface(nvtxs, start, adjacency, vwgts, ewgts, x, y, z,
		  outassignptr, outfileptr,
		  assignment,
		  architecture, ndims_tot, mesh_dims, goal,
		  global_method, local_method, rqi_flag, vmax, ndims,
		  eigtol, seed);

skip:
	if (global_method == 3) {
	    if (z != NULL)
		sfree(z);
	    if (y != NULL)
		sfree(y);
	    if (x != NULL)
		sfree(x);
	}
	sfree(assignment);

	if (DEBUG_MEMORY > 0) {
	    printf("\n");
	}

	if (PROMPT) {
	    another = affirm("\nRun Another Problem");
	}
	else {
	    another = affirm("");
	}
	if (another) {
	    clear_timing();
	    printf("\n------------------------------------------------\n\n");
	    fflush(stdout);
	}
    }
    if (params_file != NULL)
	fclose(params_file);

    if (DEBUG_TRACE > 1) {
	printf("<Leaving main>\n");
    }
    
    return(0);
}