void initializeGraph(std::string inputFile, uint32_t sourceId, uint32_t sinkId, Config *newApp) { if (inputFile.find(".gr.pfp") != inputFile.size() - strlen(".gr.pfp")) { std::string pfpName = inputFile + ".pfp"; std::ifstream pfpFile(pfpName.c_str()); if (!pfpFile.good()) { RawGraph raw; initializeRawGraph(inputFile, raw); std::cout << "Writing new output file: " << pfpName << "\n"; Galois::Graph::outputGraph(pfpName.c_str(), raw); } inputFile = pfpName; } newApp->graph.structureFromFile(inputFile.c_str()); Graph& g = newApp->graph; if (sourceId == sinkId || sourceId >= g.size() || sinkId >= g.size()) { std::cerr << "invalid source or sink id\n"; abort(); } uint32_t id = 0; for (Graph::iterator ii = g.begin(), ei = g.end(); ii != ei; ++ii, ++id) { if (id == sourceId) { newApp->source = *ii; g.getData(newApp->source).height = g.size(); } else if (id == sinkId) { newApp->sink = *ii; } g.getData(*ii).id = id; } }
void initializeGraph(std::string inputFile, uint32_t sourceId, uint32_t sinkId, Config *newApp) { if (useSymmetricDirectly) { Galois::Graph::readGraph(newApp->graph, inputFile); for (Graph::iterator ss = newApp->graph.begin(), es = newApp->graph.end(); ss != es; ++ss) { for (Graph::edge_iterator ii = newApp->graph.edge_begin(*ss), ei = newApp->graph.edge_end(*ss); ii != ei; ++ii) newApp->graph.getEdgeData(ii) = 1; } } else { if (inputFile.find(".gr.pfp") != inputFile.size() - strlen(".gr.pfp")) { std::string pfpName = inputFile + ".pfp"; std::ifstream pfpFile(pfpName.c_str()); if (!pfpFile.good()) { std::cout << "Writing new input file: " << pfpName << "\n"; writePfpGraph<Graph::edge_data_type>(inputFile, pfpName); } inputFile = pfpName; } Galois::Graph::readGraph(newApp->graph, inputFile); #ifdef HAVE_BIG_ENDIAN // Convert edge data to host ordering for (Graph::iterator ss = newApp->graph.begin(), es = newApp->graph.end(); ss != es; ++ss) { for (Graph::edge_iterator ii = newApp->graph.edge_begin(*ss), ei = newApp->graph.edge_end(*ss); ii != ei; ++ii) { Graph::edge_data_type& cap = newApp->graph.getEdgeData(ii); static_assert(sizeof(cap) == sizeof(uint32_t), "Unexpected edge data size"); cap = Galois::convert_le32(cap); } } #endif } Graph& g = newApp->graph; if (sourceId == sinkId || sourceId >= g.size() || sinkId >= g.size()) { std::cerr << "invalid source or sink id\n"; abort(); } uint32_t id = 0; for (Graph::iterator ii = g.begin(), ei = g.end(); ii != ei; ++ii, ++id) { if (id == sourceId) { newApp->source = *ii; g.getData(newApp->source).height = g.size(); } else if (id == sinkId) { newApp->sink = *ii; } g.getData(*ii).id = id; } }