find the single minimal weighted path
| 558 | |
| 559 | // find the single minimal weighted path |
| 560 | static void SPpaths_single_minimal |
| 561 | ( |
| 562 | SinglePairCtx *ctx |
| 563 | ) { |
| 564 | // initialize the result path to worst path |
| 565 | ctx->single.path = NULL; |
| 566 | ctx->single.weight = DBL_MAX; |
| 567 | ctx->single.cost = DBL_MAX; |
| 568 | |
| 569 | // get first path |
| 570 | WeightedPath p = {0}; |
| 571 | SPpaths_next(ctx, &p, DBL_MAX); |
| 572 | |
| 573 | // iterate over all paths |
| 574 | while (p.path != NULL) { |
| 575 | // if the current path is better replace it |
| 576 | if(p.weight < ctx->single.weight || |
| 577 | p.cost < ctx->single.cost || |
| 578 | (p.cost == ctx->single.cost && |
| 579 | Path_Len(p.path) < Path_Len(ctx->single.path))) { |
| 580 | if(ctx->single.path != NULL) { |
| 581 | Path_Free(ctx->single.path); |
| 582 | } |
| 583 | ctx->single.path = Path_Clone(p.path); |
| 584 | ctx->single.weight = p.weight; |
| 585 | ctx->single.cost = p.cost; |
| 586 | } |
| 587 | |
| 588 | // get next path where path weight is <= result weight |
| 589 | SPpaths_next(ctx, &p, ctx->single.weight); |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | static void inline _add_path |
| 594 | ( |
no test coverage detected