/** * @brief This constructor creates the BGL graph from the map graph. * @param shm_segment the shared memory object name * * This constructor creates the BGL graph from the map graph that * is placed in the shared memory segment. */ MyShmClient ( const char * shm_segment, std::string teamname ) : ShmClient ( shm_segment ), m_teamname ( teamname ) { nr_graph = bgl_graph(); #ifdef DEBUG print_vertices ( 10 ); print_edges ( 10 ); std::fstream graph_log( teamname+".dot" , std::ios_base::out ); boost::write_graphviz(graph_log, *nr_graph); #endif }
void AStarSearch::printBestPath(int start, int end){ int val = end; vector<Edge>*final_path = new vector<Edge>(); for (size_t i = this->edges.size(); i > 0; i--) { if(this->edges[i-1].getDstNode()->getValue() == val){ final_path->push_back(this->edges[i-1]); val = this->edges[i-1].getOrgNode()->getValue(); } } print_edges(*final_path); print_edges_word(*final_path); }
int main() { igraph_t graph; igraph_integer_t prufer1[] = {2, 3, 2, 3}; igraph_integer_t prufer2[] = {0, 2, 4, 1, 1, 0}; igraph_vector_int_t prufer; igraph_bool_t tree; igraph_vector_int_view(&prufer, prufer1, sizeof(prufer1) / sizeof(igraph_integer_t)); igraph_from_prufer(&graph, &prufer); igraph_is_tree(&graph, &tree, NULL, IGRAPH_ALL); assert(tree); print_edges(&graph); igraph_destroy(&graph); igraph_vector_int_view(&prufer, prufer2, sizeof(prufer2) / sizeof(igraph_integer_t)); igraph_from_prufer(&graph, &prufer); igraph_is_tree(&graph, &tree, NULL, IGRAPH_ALL); assert(tree); print_edges(&graph); igraph_destroy(&graph); return 0; }
void search( long int arra[100000][2], int weight[100][100], int V) { int i,u,v,start; printf("enter the starting node of player A:"); scanf("%d",&u); printf("\n"); printf("enter the starting node of player B:"); scanf("%d",&v); for(i=0;i<V;i++) { if(arra[i][0]==u && arra[i][1]==v) { start=i; break; } } printf("%d",start); print_edges(arra, weight,V,start) ; return; }
void print_header() { char header[]="\ digraph g {\n\ rankdir=TB;\n\ size=\"11,11\";\n\ graph [fontname = \"consolas\"];\n\ node [fontname = \"consolas\"];\n\ edge [fontname = \"consolas\"];\n\ node [shape = ellipse];\n"; fprintf(ofp, "%s \n", header); } void print_body(int argc, char *argv[]) { print_node_decs(argc,argv); /* print files in current dir */ print_edges(argc,argv); /* print edges of all files found when parsing */ /* problem: files found in parsing are not in current dir and therefore do not have node decls */ }
struct Edge dijs_serial(struct Edge* edges,int edgen,int destna,int print_flag) { struct Edge temp_edge; int i,j; int* cluster = (int*)malloc(sizeof(int)*destna+1); init_array(cluster,destna+1); int cluster_size = 0; struct Edge* found_edges = malloc(sizeof(struct Edge)*edgen); int found_edge_size = 0; int* next_list = malloc(sizeof(int)*destna+1); int next_list_size = 0; init_array(next_list,destna+1); int min = 1000000; int temp_weight = 0; cluster[cluster_size] = 0; cluster_size++; while(!checkifinside(cluster,destna,cluster_size)) { next_list_size = 0; init_array(next_list,destna+1); //check next avalable ndoes; for(i = 0;i<cluster_size;i++) { for(j = 0;j<=destna;j++) { if(checkconnfsource(edges,edgen,cluster[i],j) && !checkifinside(cluster,j,cluster_size) && !checkifinside(next_list,j,next_list_size)) { next_list[next_list_size] = j; next_list_size++; } } } //trace back; min = 1000000; for(i=0;i<next_list_size;i++) { if(next_list[i]<0) { printf("size error!\n"); return temp_edge; } for(j=0;j<=destna;j++) { if(next_list[i] == j) { continue; } if(checkconnfsource(edges,edgen,j,next_list[i]) && checkifinside(cluster,j,cluster_size)) { temp_weight = 0; temp_weight += get_weight(edges,edgen,j,next_list[i]); if(j!=0) { temp_weight += get_weight(found_edges,found_edge_size,0,j); } if(temp_weight < min) { min = temp_weight; temp_edge.source = 0; temp_edge.dest = next_list[i]; temp_edge.weight = temp_weight; } } } } found_edges[found_edge_size] = temp_edge; found_edge_size++; cluster[cluster_size] = temp_edge.dest; cluster_size++; } if(print_flag) { printf("Cluster Array: "); print_array(cluster,cluster_size); printf("Found Edges: \n"); print_edges(found_edges,found_edge_size); } printf("Total steps: %d\n",cluster_size); return temp_edge; }