summaryrefslogtreecommitdiff
path: root/includes/graph.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/graph.inc')
-rw-r--r--includes/graph.inc16
1 files changed, 10 insertions, 6 deletions
diff --git a/includes/graph.inc b/includes/graph.inc
index 38b2abb1c..e9fffc587 100644
--- a/includes/graph.inc
+++ b/includes/graph.inc
@@ -121,19 +121,23 @@ function _drupal_depth_first_search(&$graph, &$state, $start, &$component = NULL
unset($state['components'][$component]);
$component = $new_component;
}
+ // Only visit existing vertices.
+ if (isset($graph[$end])) {
+ // Visit the connected vertex.
+ _drupal_depth_first_search($graph, $state, $end, $component);
- // Visit the connected vertex.
- _drupal_depth_first_search($graph, $state, $end, $component);
-
- // All vertices reachable by $end are also reachable by $start.
- $graph[$start]['paths'] += $graph[$end]['paths'];
+ // All vertices reachable by $end are also reachable by $start.
+ $graph[$start]['paths'] += $graph[$end]['paths'];
+ }
}
}
// Now that any other subgraph has been explored, add $start to all reverse
// paths.
foreach ($graph[$start]['paths'] as $end => $v) {
- $graph[$end]['reverse_paths'][$start] = TRUE;
+ if (isset($graph[$end])) {
+ $graph[$end]['reverse_paths'][$start] = TRUE;
+ }
}
// Record the order of the last visit. This is the reverse of the