Files
dijkstra-runtime-analysis/latex/main.tex
T
2026-08-23 23:20:03 +09:00

436 lines
29 KiB
TeX
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
\documentclass{article}
\usepackage{float}
\usepackage{hyperref}
\hypersetup{
pdfborder={0 0 0}
}
\usepackage{graphicx}
\graphicspath{
{images/}
{../codes/results/synthetic_data/derived/20260421_031740/}
{../codes/results/real_data/derived/}
}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{geometry}
\geometry{margin=2.5cm}
\usepackage[style=apa,backend=biber]{biblatex}
\addbibresource{references.bib}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0.6em}
\linespread{1.08}
\title{Predicting Dijkstra Runtime from Graph Properties:\\
An Operation-Decomposed Model with Binary Heap}
% \author{Seungjun Lee}
% \date{May 2026}
\begin{document}
% \maketitle
\begin{titlepage}
\centering
\vspace*{2cm}
{\large\scshape Extended Essay\par}
\vspace{0.4cm}
{\large\scshape Subject: Computer Science\par}
\vspace{2.5cm}
{\LARGE\bfseries Predicting Dijkstra Runtime from Graph Properties:\par}
\vspace{0.3cm}
{\LARGE\bfseries An Operation-Decomposed Model with Binary Heap\par}
\vspace{2cm}
{\large\itshape Research Question\par}
\vspace{0.4cm}
\begin{minipage}{0.8\textwidth}
\centering
{\large Can the runtime of Dijkstra's algorithm with a binary heap\\
be predicted from observable graph properties alone?\par}
\end{minipage}
\vfill
{\large Word Count: 2{,}759\par}
\vspace{1.5cm}
\end{titlepage}
% \begin{abstract}
% This paper proposes an empirical model for predicting the wall-clock runtime of binary-heap-accelerated Dijkstra's algorithm using only three graph properties: node count $N$, edge density $d$, and the log-scale standard deviation of edge weights $\sigma$. The runtime is decomposed into four operation classes (add, extract-min, relax-attempt, decrease-key), each modeled separately. The relax-success ratio (RSR) --- the fraction of edge relaxations that trigger a decrease-key --- exhibits a sharp phase transition at average degree $\overline{k} = 1$, consistent with ErdősRényi percolation theory. Above this threshold, RSR is well described by $\mathrm{RSR} = (\sigma^2)^{a}(b\ln\overline{k} + c)$, achieving $R^2 = 0.9947$ on synthetic graphs. Operation unit costs are modeled as functions of $N$, capturing empirically observed cache effects. The integrated prediction attains $R^2 = 0.9691$, RMSE $= 57.6$~ms, and MAPE $= 30.9\%$ on the synthetic test set. Validation on DIMACS USA road-network benchmarks shows accurate decrease-key count predictions (relative error $\approx 12\%$), although total runtime is overestimated by roughly a factor of two, attributed to memory-hierarchy differences between training and validation environments.
% \end{abstract}
\newpage
\tableofcontents
\newpage
% ---------------------------------------------------------------
\section{Introduction}
% ---------------------------------------------------------------
Shortest-path computation is fundamental to a broad class of real-world applications. Autonomous navigation in robotic systems relies on optimal path planning as a core primitive \parencite{Waga2025}, and intelligent transportation systems require fast, accurate routing for in-vehicle guidance and automated vehicle dispatch \parencite{FU20063324}. As graph sizes grow, the tension between solution quality and computation time becomes critical: exact algorithms guarantee optimality but scale poorly, while heuristic methods such as A* \parencite{4082128} sacrifice optimality for speed.
Dijkstra's algorithm \parencite{Dijkstra1959} remains the canonical exact method for single-source shortest paths on non-negative-weight graphs. Despite its theoretical guarantees, practical deployment is hindered by the difficulty of predicting its runtime before execution. When graphs are large, memory consumption and processing time can be prohibitive \parencite{5359145}, yet practitioners must decide in advance whether Dijkstra is feasible for a given instance. Heuristic approaches such as A* are therefore preferred in many transportation applications \parencite{FU20063324}, even when the optimality guarantee of Dijkstra would be desirable.
This asymmetry motivates a different question: rather than replacing Dijkstra, can its runtime be predicted from observable graph properties alone, enabling informed pre-execution decisions? If so, practitioners could determine whether Dijkstra is viable for a specific instance before committing computational resources.
This study addresses the following research question:
\begin{quote}
\textit{Can the wall-clock runtime of binary-heap Dijkstra be predicted using only $N$ (node count), $d$ (edge density), and $\sigma$ (log-scale standard deviation of edge weights)?}
\end{quote}
The proposed model decomposes runtime into distinct operation categories, models each component as a function of graph properties or $N$, and combines them into a closed-form prediction formula. A critical structural discovery is a phase transition at average degree $\overline{k} = 1$ that defines two fundamentally different operating regimes.
% ---------------------------------------------------------------
\section{Background}
% ---------------------------------------------------------------
\subsection{Dijkstra's Algorithm}
Dijkstra's algorithm \parencite{Dijkstra1959} solves the single-source shortest-path problem on a directed weighted graph $G = (V, E)$ with non-negative edge weights. Starting from a source vertex, it maintains a priority queue of tentative distances and iteratively extracts the minimum-distance vertex, relaxing all outgoing edges. An edge relaxation succeeds --- triggering an update --- when a shorter path to the neighbor is discovered.
\subsubsection{Time Complexity}
In its original array-based form, the algorithm requires $O(V^2)$ time. The bottleneck is the repeated minimum extraction, which costs $O(V)$ per iteration over $V$ iterations \parencite{Dijkstra1959}.
\subsection{Priority Queue}
Replacing the linear scan with a priority queue reduces the cost of minimum extraction. Two well-studied options are the binary heap \parencite{williams1964algorithm} and the Fibonacci heap. Although Fibonacci heaps achieve superior asymptotic complexity for decrease-key ($O(1)$ amortised versus $O(\log V)$), empirical benchmarks consistently show that binary heaps outperform Fibonacci heaps in practice due to lower constant factors and better cache behaviour \parencite{Idowu2025Comparative}. This study therefore uses a binary heap implementation.
\subsubsection{Time Complexity}
With a binary heap, the standard complexity analysis yields $O((V + E)\log V)$. More precisely: each of the $V$ vertices is added once ($O(\log V)$ per add), extracted once ($O(\log V)$ per extraction), and each of the $E$ edges is relaxed. Each successful relaxation triggers a decrease-key at $O(\log V)$. Assuming every relaxation succeeds and counting $V$ decrease-keys yields $O((V + E)\log V)$.
\subsection{Runtime Model}
The standard $O((V+E)\log V)$ bound conflates four operationally distinct contributions, omits the fraction of relax attempts that actually succeed, and absorbs all constants. This study proposes the following additive decomposition:
\begin{equation}
\mathrm{Runtime} = V \cdot \mathrm{UC}_1 + E \cdot \mathrm{UC}_2 + \alpha \cdot \mathrm{UC}_3
\label{eq:runtime}
\end{equation}
where:
\begin{itemize}
\item $\mathrm{UC}_1 = (k_1 + k_2)\log V$: combined unit cost of one add and one extract-min (each called exactly $V$ times);
\item $\mathrm{UC}_2 = k_3$: unit cost per relax-attempt iteration (called exactly $E$ times);
\item $\mathrm{UC}_3 = k_4 \log V$: unit cost per decrease-key call;
\item $\alpha = E \times \mathrm{RSR}$: total number of decrease-key calls, where $\mathrm{RSR} \in [0,1]$ is the relax-success ratio.
\end{itemize}
The quantities $\mathrm{RSR}$ and the three unit costs are unknowns to be estimated from data. Unlike the asymptotic bound, this model explicitly accounts for the fact that not every relax attempt triggers a decrease-key, and treats per-operation costs as functions of $N$ to capture empirical hardware effects.
% ---------------------------------------------------------------
\section{Methodology}
% ---------------------------------------------------------------
\subsection{Research Hypotheses}
Three hierarchical hypotheses guide the analysis:
\begin{description}
\item[H1] The relax-success ratio RSR is a deterministic function of $(N, d, \sigma)$.
\item[H2] Operation unit costs are functions of $N$ alone.
\item[H3] Combining the RSR model and the unit-cost models yields accurate runtime predictions.
\end{description}
\subsection{Experimental Environment}
All experiments were conducted on a Debian virtual machine with four CPU cores and 8~GB RAM. Dijkstra's algorithm and the binary heap were implemented from scratch in Python~3.12 to avoid library-level optimisations that would obscure per-operation costs. Wall-clock time was measured for the complete execution of each Dijkstra call.
\subsection{Real Data}
The DIMACS USA road-distance benchmark \parencite{SINGH2025130901} provides eleven road-network graphs ranging from 264,346 nodes (New York) to 23,947,347 nodes (full USA). These graphs served as a validation target representing real-world conditions.
Edge-weight distributions were characterised for each graph. As shown in Figure~\ref{fig:hist_log}, the log-transformed weights closely follow a normal distribution, confirming lognormal structure \parencite{SINGH2025130901}. The Q--Q plot in Figure~\ref{fig:qq_log} corroborates this finding. Summary statistics across graphs yield a typical log-scale standard deviation $\sigma \approx 0.75$--$1.12$ and density $d \approx 10^{-7}$--$10^{-5}$, parameters that fall within the synthetic training range.
\begin{figure}[H]
\centering
\begin{minipage}{0.45\textwidth}
\centering
\includegraphics[width=\linewidth]{hist_log.png}
\caption{Histogram of log-transformed edge weights for a representative DIMACS graph (BAY). The distribution closely follows a normal curve, confirming lognormal structure.}
\label{fig:hist_log}
\end{minipage}
\hfill
\begin{minipage}{0.45\textwidth}
\centering
\includegraphics[width=\linewidth]{Q-Q_log.png}
\caption{Q--Q plot of log-transformed weights against the normal quantiles. Points align tightly with the diagonal, further supporting lognormality.}
\label{fig:qq_log}
\end{minipage}
\end{figure}
\subsection{Synthetic Graph Generation}
Synthetic ErdősRényi random graphs were generated with the following parameter grid:
\begin{itemize}
\item $N \in \{2000, 4000, 6000, \ldots, 20000\}$ (10 levels);
\item $d \in \{10^{-7}, 3 \times 10^{-7}, 10^{-6}, \ldots, 0.03\}$ (12 levels, logarithmically spaced);
\item $\sigma \in \{0.32, 0.47, 0.61, 0.83, 1.01, 1.27, 1.45, 1.68, 1.84\}$ (9 levels, corresponding to raw-scale standard deviations $\{1000, 1700, 2000, 3000, 4000, 6000, 8000, 12000, 16000\}$ at mean~3000).
\end{itemize}
Edge weights were drawn from a lognormal distribution with the specified $\sigma$ and mean~3000. Each $(N, d, \sigma)$ combination was tested with 400 independent trials, yielding a total of 864,000 measurements. The parameter ranges were chosen to bracket the DIMACS graphs and cover both sparse and moderately dense regimes. Graphs with fewer than two connected components were retained to ensure Dijkstra visits a substantial fraction of vertices.
\subsection{Analysis Strategy}
\subsubsection{Decrease-Key Call Count ($\alpha$) Modelling}
The decrease-key call count $\alpha$ is decomposed as $\alpha = E \times \mathrm{RSR}$. Since $E = d \cdot N(N-1)$ is exactly determined by $d$ and $N$, the modelling task reduces to estimating RSR.
Plotting RSR against average degree $\overline{k} = (N-1) \cdot d$ reveals a sharp phase transition at $\overline{k} = 1$ (Figure~\ref{fig:phase_hist}): for $\overline{k} \ll 1$ (subcritical regime), graphs are nearly trees or disconnected, so almost every relaxation succeeds and RSR $\approx 1$; for $\overline{k} \gg 1$ (supercritical regime), the graph is well-connected and RSR decays with increasing density and edge-weight spread.
This transition corresponds directly to the ErdősRényi percolation threshold \parencite{erdos1960evolution}, where a giant connected component emerges at $\overline{k} = 1$.
In the supercritical regime ($\overline{k} \geq 1$), controlled experiments confirm that $\sigma$ and $\overline{k}$ act independently on RSR. Their effects are combined multiplicatively:
\begin{equation}
\mathrm{RSR} = (\sigma^2)^{a} \cdot (b \ln \overline{k} + c), \quad \overline{k} \geq 1
\label{eq:rsr}
\end{equation}
Nonlinear least-squares regression on the supercritical subset yields $R^2 = 0.9947$.
\subsubsection{Operation Unit Cost Modelling}
Fitting a single regression of Runtime on $V$, $E$, and $\alpha$ across all $N$ causes severe multicollinearity (VIF $> 10$) because $V$, $E$, and $\alpha$ are all functions of $N$. To circumvent this, a separate linear regression is fitted for each distinct $N$:
\begin{equation}
\mathrm{Runtime}(N) = \beta_0(N) + E \cdot k_3(N) + \alpha \cdot k_4(N)
\end{equation}
This extracts per-$N$ estimates of $k_3$ and $k_4$, verifying VIF $< 3.5$ within each stratum.
The extracted coefficients are then regressed against $N$:
\begin{itemize}
\item $k_3(N)$: the relax-attempt cost decreases with $N$ following an exponential-decay model $k_3 = a_3 e^{-N/N_0} + c_3$ ($R^2 = 0.953$), attributed to CPU cache effects at small $N$.
\item $k_4(N)$: the decrease-key cost grows with heap height as $k_4 \log V$, confirming the theoretical $O(\log V)$ scaling ($R^2 = 0.951$).
\item $\beta_0(N)$ (intercept capturing $V \cdot \mathrm{UC}_1$): noisy due to collinearity with $V$; a per-$N$ median is used as a constant.
\end{itemize}
\subsubsection{Integrated Prediction}
The final predictor combines Equations~\eqref{eq:runtime} and~\eqref{eq:rsr}:
\begin{equation}
\hat{t} = V \cdot \hat{\mathrm{UC}}_1 + E \cdot \hat{k}_3(N) + \hat{\alpha} \cdot \hat{k}_4(N) \cdot \log V
\end{equation}
where $\hat{\alpha} = E \times \widehat{\mathrm{RSR}}(N, d, \sigma)$ and each unit-cost function is evaluated at the query $N$.
\subsection{Validation Metrics}
Model performance is reported using four metrics: coefficient of determination ($R^2$), root mean squared error (RMSE), mean absolute error (MAE), and mean absolute percentage error (MAPE). MAPE is included because runtime values span several orders of magnitude across the parameter grid.
% ---------------------------------------------------------------
\section{Results}
% ---------------------------------------------------------------
\subsection{Real Data Properties}
Table~\ref{tab:dimacs} summarises key statistics for the DIMACS road graphs. All eleven graphs exhibit lognormal edge-weight distributions (Figures~\ref{fig:hist_log} and~\ref{fig:qq_log}). Log-scale standard deviations range from $\sigma = 0.75$ (New York) to $\sigma = 1.12$ (California), with densities $d \approx 10^{-7}$--$10^{-5}$. All graphs fall in the supercritical regime ($\overline{k} \gg 1$), making Equation~\eqref{eq:rsr} directly applicable.
\begin{table}[H]
\centering
\caption{Summary statistics for selected DIMACS road-network graphs.}
\label{tab:dimacs}
\begin{tabular}{lrrrr}
\toprule
Graph & $N$ & $d$ & $\sigma$ & $\overline{k}$ \\
\midrule
NY & 264,346 & $1.05 \times 10^{-5}$ & 0.75 & 2.78 \\
BAY & 321,270 & $7.75 \times 10^{-6}$ & 1.07 & 2.49 \\
COL & 435,666 & $5.57 \times 10^{-6}$ & 1.10 & 2.43 \\
FLA & 1,070,376 & $2.37 \times 10^{-6}$ & 1.05 & 2.53 \\
NE & 1,524,453 & $1.68 \times 10^{-6}$ & 0.93 & 2.56 \\
CAL & 1,890,815 & $1.30 \times 10^{-6}$ & 1.12 & 2.46 \\
\bottomrule
\end{tabular}
\end{table}
\subsection{Decrease-Key Call Number Prediction}
\textbf{Step 1: Phase transition.}
Figure~\ref{fig:phase_hist} shows the distribution of samples across the two regimes. The subcritical regime ($\overline{k} < 1$) comprises a minority of the experimental grid; most practically relevant graphs (including all DIMACS instances) are supercritical.
\begin{figure}[H]
\centering
\includegraphics[width=0.6\linewidth]{call_number_analysis/regime_distribution/phase_histogram.png}
\caption{Distribution of $(N, d, \sigma)$ samples across subcritical ($\overline{k} < 1$) and supercritical ($\overline{k} \geq 1$) regimes. The vertical dashed line marks the phase-transition threshold at $\overline{k} = 1$.}
\label{fig:phase_hist}
\end{figure}
\textbf{Step 2: $E$ as a function of $d$ and $N$.}
By construction, $E = d \cdot N(N-1)$, yielding $R^2 = 1.000$ (Figure~\ref{fig:e_relax}). No modelling is required for this component.
\begin{figure}[H]
\centering
\includegraphics[width=0.55\linewidth]{E_vs_relax_attempts.png}
\caption{Total edge count $E$ versus total relax attempts. The relationship is exact ($R^2 = 1.00$), confirming that every edge is relaxed exactly once.}
\label{fig:e_relax}
\end{figure}
\textbf{Step 3: RSR model.}
In the supercritical regime, RSR is modelled by Equation~\eqref{eq:rsr}. Figure~\ref{fig:rsr_model} compares predicted and observed RSR values. The nonlinear model captures $97\%$ of variance ($R^2 = 0.9947$), demonstrating that $\sigma$ and $\overline{k}$ together explain RSR with high fidelity.
\begin{figure}[H]
\centering
\includegraphics[width=0.6\linewidth]{call_number_analysis/nonlinear_regression/predicted_vs_actual.png}
\caption{Predicted versus actual RSR under the nonlinear model (Eq.~\ref{eq:rsr}). Points cluster tightly around the diagonal ($R^2 = 0.9947$).}
\label{fig:rsr_model}
\end{figure}
\textbf{Step 4: Sigma effect.}
Figure~\ref{fig:sigma_rsr} illustrates the monotone decrease of RSR with $\sigma$, holding $\overline{k}$ fixed: higher weight variance creates more opportunities for distance improvements, paradoxically resulting in fewer successful updates because early paths to most nodes are already near-optimal.
\begin{figure}[H]
\centering
\includegraphics[width=0.55\linewidth]{sigma_vs_relax_ratio.png}
\caption{RSR as a function of $\sigma$ (fixed $\overline{k}$). RSR decreases monotonically as $\sigma$ increases, consistent with the power-law component in Equation~\eqref{eq:rsr}.}
\label{fig:sigma_rsr}
\end{figure}
\subsection{Operation Unit Cost Analysis}
\textbf{Relax-attempt cost $k_3(N)$.}
Figure~\ref{fig:k3} shows $k_3$ estimates plotted against $N$. Despite the $O(1)$ theoretical prediction, $k_3$ decreases with $N$ and levels off, well described by the exponential-decay model ($R^2 = 0.953$). This counter-intuitive finding is interpreted as a cache warm-up effect: for small $N$ the heap fits entirely in L1/L2 cache, while for larger $N$ cache effects approach saturation, yielding a constant marginal cost.
\begin{figure}[H]
\centering
\includegraphics[width=0.55\linewidth]{processing_time_analysis/k3_vs_N.png}
\caption{Per-$N$ estimates of the relax-attempt unit cost $k_3$ with the fitted exponential-decay curve. The monotone decrease with $N$ is attributed to cache effects.}
\label{fig:k3}
\end{figure}
\textbf{Decrease-key cost $k_4(N)$.}
The decrease-key cost grows proportionally to $\log V$, as Figure~\ref{fig:k4} confirms ($R^2 = 0.951$). This is consistent with binary-heap theory: each decrease-key performs at most $\lceil \log_2 V \rceil$ comparisons and swaps.
\begin{figure}[H]
\centering
\includegraphics[width=0.55\linewidth]{processing_time_analysis/l_vs_N.png}
\caption{Decrease-key unit cost coefficient $k_4$ as a function of $N$, with the fitted $a \log V + b$ curve ($R^2 = 0.951$), consistent with the $O(\log V)$ theoretical prediction.}
\label{fig:k4}
\end{figure}
\textbf{Operation contribution.}
Figure~\ref{fig:contribution} decomposes total runtime into three components across $N$. The relax-attempt term $E \cdot k_3$ contributes 55--65\% of total runtime and dominates throughout. The decrease-key term $\alpha \cdot k_4 \log V$ contributes 22--44\%, increasing with $N$ as the heap height grows. The add-plus-extract term $V \cdot \mathrm{UC}_1$ contributes only 1--15\%.
\begin{figure}[H]
\centering
\includegraphics[width=0.6\linewidth]{processing_time_analysis/contribution_vs_N.png}
\caption{Fractional contribution of each operation class to total runtime as a function of $N$. The relax-attempt term dominates at all sizes.}
\label{fig:contribution}
\end{figure}
\subsection{Integrated Runtime Prediction}
\textbf{Synthetic validation.}
Figure~\ref{fig:synth_pred} plots predicted against measured runtimes for all synthetic test instances. The integrated model achieves $R^2 = 0.9691$, RMSE $= 57.6$~ms, MAE $= 35.1$~ms, and MAPE $= 30.9\%$. Predictions are reliable across most of the parameter space; the largest relative errors occur at very small $N$ (where the intercept term is least stable) and at the phase-transition boundary.
\begin{figure}[H]
\centering
\includegraphics[width=0.6\linewidth]{prediction_result/predicted_vs_real.png}
\caption{Predicted versus actual runtime (ms) on the synthetic test set ($R^2 = 0.9691$, RMSE $= 57.6$~ms). The dashed line is the ideal prediction ($\hat{t} = t$).}
\label{fig:synth_pred}
\end{figure}
\textbf{DIMACS validation.}
Table~\ref{tab:dimacs_pred} compares predicted and measured runtimes for DIMACS graphs. Decrease-key call counts are predicted with a relative error of approximately 12\% (mean across graphs), indicating that the RSR model generalises well beyond the training distribution. However, total runtime is overestimated by roughly a factor of two. Figure~\ref{fig:comparison} illustrates this systematic overestimation.
\begin{table}[H]
\centering
\caption{Runtime prediction on DIMACS validation graphs. Relax count relative error $\approx 12\%$; runtime overestimated by $\sim 2\times$.}
\label{tab:dimacs_pred}
\begin{tabular}{lrrrrr}
\toprule
Graph & $N$ & Actual $t$ (s) & Predicted $t$ (s) & Runtime rel.\ err. & Relax rel.\ err.\\
\midrule
NY & 264K & 1.23 & 2.70 & 1.20 & 0.08 \\
BAY & 321K & 1.45 & 3.37 & 1.33 & 0.12 \\
COL & 436K & 2.11 & 4.79 & 1.28 & 0.13 \\
FLA & 1.07M & 5.88 & 13.67 & 1.32 & 0.11 \\
NE & 1.52M & 9.24 & 20.36 & 1.20 & 0.11 \\
CAL & 1.89M & 11.77 & 26.03 & 1.21 & 0.12 \\
\bottomrule
\end{tabular}
\end{table}
\begin{figure}[H]
\centering
\includegraphics[width=0.6\linewidth]{comparison/comparison_plot.png}
\caption{Predicted versus actual runtime on DIMACS validation graphs. The model systematically overestimates by $\approx 2\times$, attributed to memory-hierarchy effects not captured in training.}
\label{fig:comparison}
\end{figure}
% ---------------------------------------------------------------
\section{Discussion}
% ---------------------------------------------------------------
\subsection{Phase Transition as Regime Boundary}
The discovery that $\overline{k} = 1$ separates two qualitatively different RSR behaviours is not accidental. Erdős and Rényi \parencite{erdos1960evolution} proved that random graphs undergo a structural phase transition at this threshold: below $\overline{k} = 1$ the graph consists of small isolated components, while above it a giant connected component of size $\Theta(N)$ emerges. In the subcritical regime, Dijkstra visits few vertices and almost every relaxation discovers a genuinely shorter path, so RSR $\approx 1$. In the supercritical regime, the algorithm traverses a large connected component and encounters many redundant relaxation attempts, driving RSR below 1.
This structural boundary has practical implications: a separate model is necessary for the subcritical regime. Road networks universally satisfy $\overline{k} > 1$ (typical values 2--3 as shown in Table~\ref{tab:dimacs}), so Equation~\eqref{eq:rsr} is directly applicable without regime detection.
\subsection{Cache Effects in Unit Cost}
The empirical finding that $k_3$ \textit{decreases} with $N$ contradicts the $O(1)$ asymptotic prediction. For small $N$, the heap is small enough to reside in CPU cache, enabling rapid access; however, the overhead of Python interpreter dispatch is proportionally larger relative to the actual heap work. As $N$ increases, per-element memory access costs stabilise, yielding a lower effective $k_3$. The exponential-decay fit captures this transition well ($R^2 = 0.953$), but the inferred curve is specific to the Python~3.12 interpreter and the 8~GB VM environment. In compiled languages or on machines with different cache hierarchies, $k_3$ would follow a different trajectory.
\subsection{Asymptotic vs Empirical Cost}
The standard complexity $O((V+E)\log V)$ implicitly assumes: (i) every relax attempt succeeds, (ii) all $V$ decrease-keys occur, and (iii) unit costs are constant. The results challenge all three assumptions. RSR can be as low as 0.05 in dense, high-variance graphs, reducing decrease-key calls by a factor of 20 relative to the pessimistic bound. Furthermore, both $k_3$ and $k_4$ vary with $N$, reflecting hardware-level phenomena absent from asymptotic analysis. The decomposed model in Equation~\eqref{eq:runtime} captures these realities and achieves substantially better predictive accuracy than the asymptotic formula alone would permit.
\subsection{Limitations}
Several limitations constrain the generalisability of the results:
\textbf{Language and environment.} All measurements were obtained with a Python~3.12 implementation on a single Debian VM. The unit-cost coefficients $k_3$ and $k_4$ are environment-specific. The RSR model (Equation~\ref{eq:rsr}) is implementation-independent and should transfer across languages, but the runtime prediction requires re-fitting unit costs in any new environment.
\textbf{Node-count range.} Training was conducted for $N \leq 20{,}000$, while DIMACS graphs contain up to 23 million nodes. Extrapolation of the unit-cost curves beyond the training range introduces systematic bias, as evidenced by the $\approx 2\times$ overestimation on DIMACS.
\textbf{Memory hierarchy.} Training graphs fit comfortably in RAM with no paging, while large DIMACS graphs may trigger memory pressure effects. The training unit costs therefore underestimate real hardware costs at scale, resulting in overestimated predicted runtimes when the unit-cost model infers lower cost per operation than actually observed.
\textbf{Graph model.} Synthetic graphs follow the ErdősRényi random model. Real road networks possess spatial embedding, planarity, and degree-distribution properties \parencite{SINGH2025130901} that the random model does not capture. The RSR model nonetheless generalises well to DIMACS, suggesting robustness to structural differences at this level.
% ---------------------------------------------------------------
\section{Conclusion}
% ---------------------------------------------------------------
\subsection{Summary of Contributions}
This study demonstrates that the wall-clock runtime of binary-heap Dijkstra can be predicted from three graph properties $(N, d, \sigma)$ through an operation-decomposed model. Three main findings emerge:
\begin{enumerate}
\item \textbf{Phase transition as structural boundary.} Average degree $\overline{k} = 1$ determines the operating regime of RSR, consistent with ErdősRényi percolation theory. This boundary must be respected by any runtime model.
\item \textbf{Accurate RSR prediction.} The multiplicative model $\mathrm{RSR} = (\sigma^2)^a(b\ln\overline{k} + c)$ achieves $R^2 = 0.9947$ on synthetic data and generalises to DIMACS road networks with approximately 12\% relative error on decrease-key counts.
\item \textbf{Empirically calibrated unit costs.} Per-operation costs deviate systematically from theoretical $O(1)$ predictions due to cache effects, necessitating environment-specific calibration.
\end{enumerate}
\subsection{Practical Implications}
The most practically transferable result is the RSR model. Because decrease-key call counts depend only on graph topology and weight distribution --- not on implementation language or hardware --- the model provides a portable tool for estimating algorithmic workload before execution. A practitioner with knowledge of $N$, $d$, and $\sigma$ can compute $\hat{\alpha}$ and assess whether Dijkstra is feasible, independent of the execution environment.
For environments where unit costs can be calibrated through short benchmark runs, the full integrated model offers runtime estimates with MAPE of approximately 31\% on the synthetic domain. While this precision may be insufficient for hard real-time scheduling, it is adequate for coarse feasibility assessment and resource allocation decisions.
\subsection{Future Work}
Four directions merit further investigation. First, extending the training range to $N > 100{,}000$ would allow direct calibration at scales relevant to real road networks, potentially closing the factor-of-two gap observed on DIMACS. Second, profiling cache-miss rates alongside runtime measurements would enable explicit modelling of memory-hierarchy effects, yielding hardware-portable cost functions. Third, the subcritical regime ($\overline{k} < 1$) requires a separate model; developing a unified formulation across both regimes would broaden applicability. Fourth, extending the framework to compiled implementations (C++, Java) would test whether the RSR model transfers while confirming that only unit costs require recalibration.
\newpage
\printbibliography
\end{document}