diff options
author | Julian T <julian@jtle.dk> | 2019-11-22 11:06:21 +0100 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2019-11-22 11:06:21 +0100 |
commit | 90999d01eff3b197001739ee3ee9ff6dd64217ce (patch) | |
tree | 0b407668c76cd5d06d3e233c631ff2105e41b4d4 /sem1/algo/workshop2/dfs/graph.c | |
parent | 4fd77927337b0243dac88ccb128af8268ea423f7 (diff) |
Added bench
Diffstat (limited to 'sem1/algo/workshop2/dfs/graph.c')
-rw-r--r-- | sem1/algo/workshop2/dfs/graph.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sem1/algo/workshop2/dfs/graph.c b/sem1/algo/workshop2/dfs/graph.c index 11ee07f..0f5048c 100644 --- a/sem1/algo/workshop2/dfs/graph.c +++ b/sem1/algo/workshop2/dfs/graph.c @@ -50,7 +50,7 @@ static vertex_t *create_vertex(char *ref) { vertex_t *v = malloc(sizeof(vertex_t)); // Set values - v->ref = ref; + v->ref = strdup(ref); v->color = COLOR_WHITE; v->next = NULL; v->adj = NULL; @@ -90,10 +90,13 @@ edge_t *edge_next(graph_t *g, edge_t *e) { // Find next vertex v = vertex_next(g, v); + while( v ) { + // Check if found + if( v->adj ) { + return v->adj; + } - // Check if found - if( v ) { - return v->adj; + v = vertex_next(g, v); } // No next vertex |