Make labelled_successors return labels directly
Currently, the code pattern for accessing graph labels is cumbersome, e.g.:
for (succ, labels) in graph.labelled_successors(ori) {
for label in labels {
if let EdgeLabel::Visit(visit) =
label.for_edge_type(props.node_type(ori), props.node_type(succ), false)?
{
if visit.status() != VisitStatus::Full {
continue;
}
// ...
Also, the inner loop on labels
is pointless, as there is always exactly one label.
Given the current situation, we should be able to simplify things significantly by making labelled_successors
(or an equivalent method, if that one must remain) return directly the label, relying on the current source node type, the successor node type, and assuming the graph is not transposed (or, if need be, exposes the is transposed parameter as an additional flag). Doing so would allow writing the above code much more succinctly, like this:
for (succ, label) in graph.labelled_successors(ori) {
if let EdgeLabel::Visit(visit) = label {
if visit.status() != VisitStatus::Full {
continue;
}
// ...
Questions:
- Main one: anything wrong with this idea?
- How likely is the invariant that we only have one label per arc to remain true in the long run?