Skip to content

Commit 42e7a53

Browse files
committed
refactor: shortest path method auto-selection now delegated to the C core
1 parent d9b43f9 commit 42e7a53

File tree

4 files changed

+18
-130
lines changed

4 files changed

+18
-130
lines changed

src/_igraph/graphobject.c

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "indexing.h"
3434
#include "memory.h"
3535
#include "pyhelpers.h"
36-
#include "utils.h"
3736
#include "vertexseqobject.h"
3837
#include <float.h>
3938

@@ -5571,14 +5570,14 @@ PyObject *igraphmodule_Graph_get_shortest_path(
55715570
return NULL;
55725571
}
55735572

5574-
if (algorithm == IGRAPHMODULE_SHORTEST_PATH_ALGORITHM_AUTO) {
5575-
algorithm = igraphmodule_select_shortest_path_algorithm(
5576-
&self->g, weights, NULL, mode, /* allow_johnson = */ false
5577-
);
5578-
}
5579-
55805573
/* Call the C function */
55815574
switch (algorithm) {
5575+
case IGRAPHMODULE_SHORTEST_PATH_ALGORITHM_AUTO:
5576+
retval = igraph_get_shortest_path(
5577+
&self->g, weights, use_edges ? NULL : &vec, use_edges ? &vec : NULL, from, to, mode
5578+
);
5579+
break;
5580+
55825581
case IGRAPHMODULE_SHORTEST_PATH_ALGORITHM_DIJKSTRA:
55835582
retval = igraph_get_shortest_path_dijkstra(
55845583
&self->g, use_edges ? NULL : &vec, use_edges ? &vec : NULL, from, to, weights, mode
@@ -5793,14 +5792,15 @@ PyObject *igraphmodule_Graph_get_shortest_paths(igraphmodule_GraphObject *
57935792
return NULL;
57945793
}
57955794

5796-
if (algorithm == IGRAPHMODULE_SHORTEST_PATH_ALGORITHM_AUTO) {
5797-
algorithm = igraphmodule_select_shortest_path_algorithm(
5798-
&self->g, weights, NULL, mode, /* allow_johnson = */ false
5799-
);
5800-
}
5801-
58025795
/* Call the C function */
58035796
switch (algorithm) {
5797+
case IGRAPHMODULE_SHORTEST_PATH_ALGORITHM_AUTO:
5798+
retval = igraph_get_shortest_paths(
5799+
&self->g, weights, use_edges ? NULL : &veclist, use_edges ? &veclist : NULL,
5800+
from, to, mode, NULL, NULL
5801+
);
5802+
break;
5803+
58045804
case IGRAPHMODULE_SHORTEST_PATH_ALGORITHM_DIJKSTRA:
58055805
retval = igraph_get_shortest_paths_dijkstra(
58065806
&self->g, use_edges ? NULL : &veclist, use_edges ? &veclist : NULL,
@@ -6619,14 +6619,12 @@ PyObject *igraphmodule_Graph_distances(
66196619
return igraphmodule_handle_igraph_error();
66206620
}
66216621

6622-
if (algorithm == IGRAPHMODULE_SHORTEST_PATH_ALGORITHM_AUTO) {
6623-
algorithm = igraphmodule_select_shortest_path_algorithm(
6624-
&self->g, weights, &from_vs, mode, /* allow_johnson = */ true
6625-
);
6626-
}
6627-
66286622
/* Call the C function */
66296623
switch (algorithm) {
6624+
case IGRAPHMODULE_SHORTEST_PATH_ALGORITHM_AUTO:
6625+
retval = igraph_distances(&self->g, weights, &res, from_vs, to_vs, mode);
6626+
break;
6627+
66306628
case IGRAPHMODULE_SHORTEST_PATH_ALGORITHM_DIJKSTRA:
66316629
retval = igraph_distances_dijkstra(&self->g, &res, from_vs, to_vs, weights, mode);
66326630
break;

src/_igraph/utils.c

Lines changed: 0 additions & 70 deletions
This file was deleted.

src/_igraph/utils.h

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)