android/guava/src/com/google/common/graph/Graphs.java
public static <N, V> MutableValueGraph<N, V> copyOf(ValueGraph<N, V> graph) {
    MutableValueGraph<N, V> copy =
        ValueGraphBuilder.from(graph).expectedNodeCount(graph.nodes().size()).build();
    for (N node : graph.nodes()) {
      copy.addNode(node);
    }
    for (EndpointPair<N> edge : graph.edges()) {
      copy.putEdgeValue(
          edge.nodeU(), edge.nodeV(), graph.edgeValueOrDefault(edge.nodeU(), edge.nodeV(), null));
    }
    return copy;
  }
public static <N, V> MutableValueGraph<N, V> copyOf(ValueGraph<N, V> graph) {
    MutableValueGraph<N, V> copy =
        ValueGraphBuilder.from(graph).expectedNodeCount(graph.nodes().size()).build();
    for (N node : graph.nodes()) {
      copy.addNode(node);
    }
    for (EndpointPair<N> edge : graph.edges()) {
      copy.putEdgeValue(
          edge.nodeU(), edge.nodeV(), graph.edgeValueOrDefault(edge.nodeU(), edge.nodeV(), null));
    }
    return copy;
  }
public static < N , V > MutableValueGraph < N , V > copyOf ( ValueGraph < N , V > graph ) { MutableValueGraph < N , V > copy = ValueGraphBuilder . from ( graph ) . expectedNodeCount ( graph . nodes ( ) . size ( ) ) . build ( ) ; for ( N node : graph . nodes ( ) ) { copy . addNode ( node ) ; } for ( EndpointPair < N > edge : graph . edges ( ) ) { copy . putEdgeValue ( edge . nodeU ( ) , edge . nodeV ( ) , graph . edgeValueOrDefault ( edge . nodeU ( ) , edge . nodeV ( ) , null ) ) ; } return copy ; }
Creates a mutable copy of {@code graph} with the same nodes, edges, and edge values.
Creates a mutable copy of {