find the single minimal weighted path
| 549 | |
| 550 | // find the single minimal weighted path |
| 551 | static void SSpaths_single_minimal |
| 552 | ( |
| 553 | SingleSourceCtx *ctx |
| 554 | ) { |
| 555 | // initialize the result path to worst path |
| 556 | ctx->single.path = NULL; |
| 557 | ctx->single.weight = DBL_MAX; |
| 558 | ctx->single.cost = DBL_MAX; |
| 559 | |
| 560 | // get first path |
| 561 | WeightedPath p = {0}; |
| 562 | SSpaths_next(ctx, &p, DBL_MAX); |
| 563 | |
| 564 | // iterate over all paths |
| 565 | while (p.path != NULL) { |
| 566 | // if the current path is better replace it |
| 567 | if(p.weight < ctx->single.weight || |
| 568 | p.cost < ctx->single.cost || |
| 569 | (p.cost == ctx->single.cost && |
| 570 | Path_Len(p.path) < Path_Len(ctx->single.path))) { |
| 571 | if(ctx->single.path != NULL) { |
| 572 | Path_Free(ctx->single.path); |
| 573 | } |
| 574 | ctx->single.path = Path_Clone(p.path); |
| 575 | ctx->single.weight = p.weight; |
| 576 | ctx->single.cost = p.cost; |
| 577 | } |
| 578 | |
| 579 | // get next path where path weight is <= result weight |
| 580 | SSpaths_next(ctx, &p, ctx->single.weight); |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | static void inline _add_path |
| 585 | ( |
no test coverage detected