Skip to content

Bugs in node-based CH preparation heuristics #1810

Closed

Description

@easbar

So far there are two todos in NodeBasedNodeContractor, that refer to odd/false calculations regarding the CH preparation heuristics (also pointed out here: #1225 (comment)):

// todo: initializing meanDegree here instead of in initFromGraph() means that in the first round of calculating
// node priorities all shortcut searches are cancelled immediately and all possible shortcuts are counted because
// no witness path can be found. this is not really what we want, but changing it requires re-optimizing the
// graph contraction parameters, because it affects the node contraction order.
// when this is done there should be no need for this method any longer.
meanDegree = prepareGraph.getEdges() / prepareGraph.getNodes();

// todo: we return 0 here if meanDegree is < 1, which is not really what we want, but changing this changes
// the node contraction order and requires re-optimizing the parameters of the graph contraction
return (int) meanDegree * 100;

These are easy to fix, but fixing them probably requires re-optimizing the CH preparation parameters.

I think there is another one: One of the CH preparation heuristics counts the number of contracted neighbor nodes. Currently this is done like this:

int contractedNeighbors = 0;
int degree = 0;
CHEdgeIterator iter = remainingEdgeExplorer.setBaseNode(node);
while (iter.next()) {
degree++;
if (iter.isShortcut())
contractedNeighbors++;
}

with:

final EdgeFilter remainingNodesFilter = new LevelEdgeFilter(prepareGraph) {
@Override
public final boolean accept(EdgeIteratorState edgeState) {
return super.accept(edgeState) && allFilter.accept(edgeState);
}
};
remainingEdgeExplorer = prepareGraph.createEdgeExplorer(remainingNodesFilter);

and:

public boolean accept(EdgeIteratorState edgeIterState) {
int base = edgeIterState.getBaseNode();
int adj = edgeIterState.getAdjNode();
// always accept virtual edges, see #288
if (base >= maxNodes || adj >= maxNodes)
return true;
// minor performance improvement: shortcuts in wrong direction are disconnected, so no need to exclude them
if (((CHEdgeIteratorState) edgeIterState).isShortcut())
return true;
return graph.getLevel(base) <= graph.getLevel(adj);
}

A 'contracted neighbor' should be a node that is contracted already and connected to the current node via an edge or a shortcut. The super.accept(edgeState) in the remainingNodesFilter accepts all shortcuts and all edges that go to equal or higher CH level (we can ignore the maxNodes condition because there are no virtual edges during CH preparation). We increase the contractedNeighbors counter for every shortcut and do not increase it for non-shortcut edges. This seems wrong to me: there can be shortcuts leading to un-contracted nodes and there can be non-shortcuts leading to contracted nodes.

So it should be something like this:

// just an edge explorer using `DefaultEdgeFilter.allEdges`
EdgeIterator iter = allEdgeExplorer.setBaseNode(node);
while (iter.next()) {
     // we only calculate priorities for not yet contracted nodes
     assert chGraph.getLevel(iter.getBaseNode()) == maxLevel;
     if (chGraph.getLevel(iter.getAdjNode()) < maxLevel) {
          contractedNeighbors++;
     }
}

Another (probably minor/not important) thing to consider here is that there can be multiple edges/shortcuts going to the same node in which case we should not increase contractedNeighbors multiple times.

Activity

  1. changed the title [-]Counting contracted neighbors in node-based CH preparation seems odd[/-] [+]Bugs in node-based CH preparation heuristics[/+] on Nov 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions