int edge_search(Vertex t, Edge a){ if (edge_isempty(a)) return 0; else if ((a->targetp) == t) return a->weight; else return edge_search(t, a->next); }
void service_right_edge(GtkWidget *text, gpointer data) { (void)text; (void)data; if(GLOBALS->helpbox_is_active) { help_text_bold("\n\nFind Next Edge"); help_text( " moves the marker to the closest transition to the right of the marker" " of the first highlighted trace. If the marker is not nailed down, it starts from min time." ); return; } edge_search(STRACE_FORWARD); DEBUG(printf("Edge Right\n")); }
int main(){ String a = (char *)malloc(100); String b = (char *)malloc(100); String d = (char *)malloc(100); String e = (char *)malloc(100); int c; Vertex t = vertex_empty();/* 変数を入力*/ scanf("%99s",a); scanf("%99s", b); t = vertex_insert(a, t); t = vertex_insert(b, t); /* loading data */ /* tの初期設定 */ Vertex m; Vertex n; while (scanf("%99s", d) != EOF) { if (strcmp(d, "quit") == 0) break; scanf("%99s", e); scanf("%d", &c); if (vertex_search(d,t) == NULL) t = vertex_insert(d, t); if (vertex_search(e,t) == NULL) t = vertex_insert(e, t); m = vertex_search(d, t); n = vertex_search(e, t); m->adj = edge_cons(c, n, m->adj); n->adj = edge_cons(c, m, n->adj); } /* データをロード */ Edge S = sort((vertex_search(a, t))->adj); if (edge_isempty(S)) printf("%s", a); else printf("%s", (S->targetp)->name); Vertex U[1000]; int i = 0; for (i = 0; i < 1000; i++) U[i] = vertex_empty(); Vertex p; i = 0; while (((t->right)->finish == 0) || ((t->left)->finish == 0)){ p = searching(t); p->finish = 1; p->distance = edge_search(p, S); U[i] = p; if (p->distance != 0) heap_insert(U, i); i = i + 1; /* ヒープの作成。 */ } /* dijkstra start */ i--; Vertex w; while (i > -1){ w = U[0]; heap_delete(U,i); /*除外状態にないもので一番始点に近いものをとってくる */ /* ループ開始 */ dijkstra(U, w, i); w->finish = 2; i = i-1; /* 始点からの距離を更新 */ /* 元々の点を消して、新たに距離を更新した点をinsertする */ /* その際、爪あとをのこしておきたい */ } /* 爪あとを元にたどって完成 */ free_vertex(t); free(a); free(b); free(e); free(d); Vertex adfw = vertex_empty(); Edge fawe = edge_empty(); free(adfw); free(fawe); return 0; }