コード例 #1
0
ファイル: graph.c プロジェクト: Huntaz/Reseplaneraren
distance_label_t *graph_find_path(graph_t *g,char *time, void *from, void *to)
{
    assert(graph_has_node(g, from) && graph_has_node(g, to));
    list_t *visited = list_new();
    list_t *distanceLabels = list_new();
    iter_t *it;
    for (it = iter(g->nodes); !iter_done(it); iter_next(it))
        {
            distance_label_t *dl = calloc(1, sizeof(distance_label_t));
            dl->dist = -1;
            dl->label = iter_get(it);
            dl->path = NULL;
	    dl->path_edges = NULL;
	    dl->arrival_time = time;
            list_add(distanceLabels, dl);
        }
    iter_free(it);
    get_distance_label(distanceLabels, from, g->comp)->path = list_new();
    get_distance_label(distanceLabels, from, g->comp)->path_edges = list_new();
    dijkstra(g, from, to, visited, distanceLabels);
    distance_label_t *best = get_distance_label(distanceLabels, to, g->comp);
    assert(best);
    free_distancelabels(g->comp,distanceLabels,best);
    list_free(visited);

    graph_print_trip(g,time,from,best);
    
    return best;
}
コード例 #2
0
ファイル: graph.c プロジェクト: Huntaz/Reseplaneraren
void graph_add_timetable(graph_t *g,char* start,int line,char* time) //Egen Funktion
{
  if(graph_has_node(g, start))
    {
      assert(g);
      assert(start);
      assert(line);
      assert(time);
      list_add_timetable(g, g->nodes, start, line, time);
    }  
}
コード例 #3
0
ファイル: graph_test.c プロジェクト: JohanWindahl/ioopm15
void testHASNODE()
{
    graph_t *g = mkGraphABCDE();
    CU_ASSERT(graph_has_node(g, "A"));
    freeGraphABCDE(g);
}