void BuildGraph(string file) { sae::io::GraphBuilder<int> b; b.AddVertexDataType("Vertex"); b.AddEdgeDataType("Edge"); int eid=0; string s; ifstream fin(env_inst.INPUT_DOC); vector<string> components; while(getline(fin,s)) { components=component_tokenize(s,"#"); int sid=atoi(components[2].c_str()); int rid=atoi(components[3].c_str()); b.AddVertex(sid,vertex_data(sid),"Vertex"); b.AddVertex(rid,vertex_data(rid),"Vertex"); b.AddEdge(sid,rid,edge_data(eid++),"Edge"); } cout<<"reading "<<eid<<" lines!"<<endl; fin.close(); system("mkdir /home/qicong/saedb/build/toolkit/influence/graph"); b.Save(file.c_str()); }
/** * Returns the data of vertex with vid. Return NULL if there is no vertex * data associated with vid in this shard. */ inline graph_row* vertex_data_by_id (const graph_vid_t& vid) { if (has_vertex(vid)) { return vertex_data(shard_impl.vertex_index.get_index(vid)); } else { return NULL; } }
bool init_values(std::string filename) { Parser vertex_data(filename); //load the file into the class instance if(vertex_data.test_file() == true) //if the file cannot be opened { int num_of_tags = vertex_data.init_tags(); vertex_data.load_tags(); vertex_data.load_data(); Tag_Data *tag_data = vertex_data.retrieve_data(); for(int i = 0; i < num_of_tags; i++) { if(tag_data[i].tag == "one") { values[0] = atof(tag_data[i].data.c_str()); } if(tag_data[i].tag == "two") { values[1] = atof(tag_data[i].data.c_str()); } if(tag_data[i].tag == "three") { values[2] = atof(tag_data[i].data.c_str()); } if(tag_data[i].tag == "four") { values[3] = atof(tag_data[i].data.c_str()); } if(tag_data[i].tag == "five") { values[4] = atof(tag_data[i].data.c_str()); } if(tag_data[i].tag == "six") { values[5] = atof(tag_data[i].data.c_str()); } if(tag_data[i].tag == "xrot") { xrot = atof(tag_data[i].data.c_str()); } if(tag_data[i].tag == "yrot") { yrot = atof(tag_data[i].data.c_str()); } if(tag_data[i].tag == "xrotStep") { xrotStep = atof(tag_data[i].data.c_str()); } if(tag_data[i].tag == "yrotStep") { yrotStep = atof(tag_data[i].data.c_str()); } if(tag_data[i].tag == "recPort") { portFromFile = tag_data[i].data; } } } else { return false; } return true; }