d93e591b42ecb40dca715489eede523d7b531a89
3 #include "sources/dijkstra.h"
5 // Dijkstra from index start : return vector of distances to every other vertex
6 // NOTE [space VS perf]: passing neighborhoods infos would be enough, but
7 // require extra computation to translate R list argument
13 SEXP dim
= getAttrib(distances_
, R_DimSymbol
);
14 int n
= INTEGER(dim
)[0];
15 double* pDistsIn
= REAL(distances_
);
16 int start
= INTEGER_VALUE(start_
) - 1; // R indices start at 1
18 // Main call to core algorithm
19 double* distances
= dijkstra_core(pDistsIn
, start
, n
);
21 // allocate vector output and obtain R vector object
23 PROTECT(distsOut
= allocVector(REALSXP
, n
));
24 double* pDistsOut
= NUMERIC_POINTER(distsOut
);
25 for (int i
=0; i
<n
; i
++)
26 pDistsOut
[i
] = distances
[i
];