Verify expected order in a graph.
$graph: A graph array processed by Drupal\Component\Graph\Graph::searchAndSort().
$expected_orders: An array containing lists of vertices in their expected order.
function assertWeights($graph, $expected_orders) {
  foreach ($expected_orders as $order) {
    $previous_vertex = array_shift($order);
    foreach ($order as $vertex) {
      $this
        ->assertTrue($graph[$previous_vertex]['weight'] < $graph[$vertex]['weight'], format_string('Weights of @previous-vertex and @vertex are correct relative to each other', array(
        '@previous-vertex' => $previous_vertex,
        '@vertex' => $vertex,
      )));
    }
  }
}