/* * Copyright (C) 2018 The Dagger Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package dagger.internal.codegen.extension; import static com.google.common.collect.Sets.difference; import static com.google.common.graph.Graphs.reachableNodes; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.graph.Graph; import com.google.common.graph.SuccessorsFunction; import java.util.ArrayDeque; import java.util.HashMap; import java.util.Map; import java.util.Queue; import java.util.Set; /** Utility methods for {@link com.google.common.graph} types. */ public final class DaggerGraphs { /** * Returns a shortest path from {@code nodeU} to {@code nodeV} in {@code graph} as a list of the * nodes visited in sequence, including both {@code nodeU} and {@code nodeV}. (Note that there may * be many possible shortest paths.) * *
If {@code nodeV} is not {@link
* com.google.common.graph.Graphs#reachableNodes(com.google.common.graph.Graph, Object) reachable}
* from {@code nodeU}, the list returned is empty.
*
* @throws IllegalArgumentException if {@code nodeU} or {@code nodeV} is not present in {@code
* graph}
*/
public static