get all minimal paths (all paths with the same weight)
| 513 | |
| 514 | // get all minimal paths (all paths with the same weight) |
| 515 | static void SSpaths_all_minimal |
| 516 | ( |
| 517 | SingleSourceCtx *ctx |
| 518 | ) { |
| 519 | // initialize array that contains the result |
| 520 | ctx->array = array_new(WeightedPath, 0); |
| 521 | |
| 522 | // get first path |
| 523 | WeightedPath p = {0}; |
| 524 | double max_weight = DBL_MAX; |
| 525 | SSpaths_next(ctx, &p, max_weight); |
| 526 | |
| 527 | // iterate over all paths |
| 528 | while (p.path != NULL) { |
| 529 | // if current path is better and the array is not empty clear it |
| 530 | uint count = array_len(ctx->array); |
| 531 | if(count > 0 && p.weight < ctx->array[0].weight) { |
| 532 | for (uint i = 0; i < array_len(ctx->array); i++) { |
| 533 | Path_Free(ctx->array[i].path); |
| 534 | } |
| 535 | array_clear(ctx->array); |
| 536 | } |
| 537 | |
| 538 | // add the path to the result array |
| 539 | p.path = Path_Clone(p.path); |
| 540 | array_append(ctx->array, p); |
| 541 | |
| 542 | // update max weight |
| 543 | max_weight = p.weight; |
| 544 | |
| 545 | // get next path where path weight is <= max_weight |
| 546 | SSpaths_next(ctx, &p, max_weight); |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | // find the single minimal weighted path |
| 551 | static void SSpaths_single_minimal |
no test coverage detected