-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate concerns in Path class #1727
Comments
100% |
Just in case you start on this: May I add something to the wish list? While looking into CH-Alternatives, I noticed that it can also be helpful to navigate the CH-Path itself. The real path through the CH-augmented graph. With un-unpacked shortcuts and all. Because I may want to analyze it without fully unpacking it, e.g. binary-search for a certain travelled distance by recursively going down. I think that's just a matter of doing less, namely not hide the non-unpacked |
that's a particularly bad example because we just removed distances from CH shortcuts: #1719. Or maybe you want something like unpack one shortcut but not another ? Anyway, I think I get it, you want for example the list of edge/shortcut ids before the shortcuts are unpacked ? Its good you say this, because at one point I was asking this myself (but could not really come up with a use-case for it). Will keep it this in mind. |
Yes.
Oh, that's fine. Yes, it was just an example. I think not even the real one. |
Refactoring |
Almost done I think. Remaining issues I'm having:
|
The fundamental ugliness (to me) is that, to process it as a data type, you basically have to pattern-match:
And that isn't immediately obvious. |
Sounds like Path should be an abstract class than? e.g the list of edges doesn't make any sense for the first two use cases |
Nah, list of edges + list of nodes with the invariant that they form a path is okay as representation. So if this is a Graph:
this is a Path: [], [] So is this: [3], [] and this: [3,2], [e2] and this: [2,3], [e2] My question is more how best to consume / pattern-match this. Maybe just give up on this, let it just be a pure tuple of edge ids and node ids, remove the back-pointer to Graph, and let the consumer figure out what to do with it? |
Your solution would be a solution to that, of course. I like it because it's |
Let's remember the history of this class: It originally served all of these purposes:
We've come a long way since then. |
If it's going to be immutable, i'd go for the abstract class approach as it's the most natural one from the OOP perspective:
|
A simple marker interface would also be an option if the AbstractPath boilds down to a "shared nothing" |
Another issue I am having with the
Yes, as far as I am concerned they can be removed and added to something that is built from a
Maybe this problem is solved if we make
Hm, but checking for
Is this really such a problem? In cases where one wants to iterate over all edges and the edge list is empty it makes sense that we iterate over an empty list? And if one wants to iterate over the nodes of a path or get the start/end node this can be done by storing the start/end nodes with tldr: I have not tried it yet, but I think /**
* Result type used by the routing algorithms. Additional information about the shortest path like time, distance, details and instructions can be calculated in a post-processing step
*/
public class Path {
private IntArrayList edgeKeys;
private int startNode;
private int endNode;
private double weight;
} |
But don't you have to do a minimum amount of pattern matching anyway when you check if the path is 'valid' (points are connected) or not (connection not found)? And if you do (and the path is valid) you already know that all paths with no edges are one-node paths? I would like to stop 'automatically' calculating the distance and time when running the algorithms, because:
Ideally, I would even like to support running Can we agree on this:
? Note that the Path contains the edge keys here, and I think there should be a |
This issue is very similar to #1110, but since that one addresses so many things I am opening a new one here.
The
Path
class really does too many thing and it leads to too much coupling between not necessarily related things. I took a look and so far I thinkPath
should be split into three parts:Path
as the result type of the routing algorithms. This should be a data-only class consisting ofweight/distance/time/edges/nodes
(and maybe adebugString
). How this data/result is obtained should be entirely up to the algorithms.The path extraction (producing a result type
Path
from one (or two)SPTEntry
s) that is currently done withinPath
(and leads to thePath
class having multiple subclasses as well, making things even more complicated) is really a part of the routing algorithm(s) and therefore should be moved into the algorithm classes. It might be worth to move it into some Helper class that the algorithms can use instead of using inheritance.Any kind of path post processing (extracting
EdgeIteratorState
s, instructions details etc.) should be moved into a separate class as well, maybe this can be achieved using some static methods.The text was updated successfully, but these errors were encountered: