The following map shows towns (in purple) and the number of presents at each town (also in purple). The towns are connecting by roads (in orange) and the length of those roads is shown in orange (the units let’s say are miles). If you can only travel on those roads in a car which can travel at most $70$ miles, what is the maximum number of presents you can collect (assuming you can go back along roads you have already been on, can start at any town, but once the presents have been collected from a town, you cannot get more).
I am not necessarily interested in the actual answer, but I am wondering if there is a method of calculating the answer. I have just made up the numbers for this question, but am wondering if there is a general method (after asking a few people, they seem to say that this problem is made difficult by the fact that you can start and end anywhere).
Many thanks.


The fact that you can start anywhere really only makes the problem $11$ times harder to solve, which is relatively minor. The real hassle is that you can retrace your steps. But we've got this.
Let $T$ be the set of towns. Let $p_x$ represent the number of presents at each town $x$ and $d_{xy}=d_{yx}$ represent the length of the road between towns $x$ and $y$ (with $d_{xy}=\infty$ if there is no direct road between $x$ and $y$).
Let us refer to a $\underline{\text{state}}$ of the solution as a list $(w,x,y,Z)$, where $w\in\mathbb N$ represents the number of miles left in your trip, $x\in T$ represents the town you are at, $y\in\mathbb N$ represents the number of presents you have, and $Z\subset T$ represents the list of towns you have visited in order. The initial states that we start with (assuming you can automatically pick up the presents from your initial town) will be $$\{(70, x,p_x,(x))\mid x\in T\} $$
Let $\mathcal U$ represent the set of all unanalyzed states, which initially consists of the initial states. Given $(w,x,y,Z)\in\mathcal U$, we will analyze it as follows. For each $t\in T$ such that $d_{xt}\leq w$, add $$\begin{cases} (w-d_{xt},t,y,Z+t), & \text{if $t\in Z$} \\ (w-d_{xt},t,y+p_t,Z+t), & \text{otherwise} \end{cases}$$ to $\mathcal U$ (where $Z+t$ represents appending $t$ to the end of list $Z$). Once you've fully analyzed a state, remove it from $\mathcal U$. When $\mathcal U$ is empty, the largest value of $y$ among all analyzed states is the greatest number of presents achievable and the $Z$ for that state is the list of towns you visited to get that total.
This algorithm has to end eventually, since every new state analyzed will decrease the number of miles you are still allowed to travel. There are any number of ways to speed up the algorithm, since the optimal trip will have little if any backtracking and this algorithm will happily count up a whole lot of trips that revisit towns over and over. But this algorithm shouldn't be out of line for a modern computer.