Tabnine Logo
com.google.common.graph
Code IndexAdd Tabnine to your IDE (free)

How to use com.google.common.graph

Best Java code snippets using com.google.common.graph (Showing top 20 results out of 315)

origin: google/guava

 private NetworkConnections<N, E> newConnections() {
  return isDirected()
    ? allowsParallelEdges()
      ? DirectedMultiNetworkConnections.<N, E>of()
      : DirectedNetworkConnections.<N, E>of()
    : allowsParallelEdges()
      ? UndirectedMultiNetworkConnections.<N, E>of()
      : UndirectedNetworkConnections.<N, E>of();
 }
}
origin: google/guava

@Override
public EndpointPair<N> incidentNodes(E edge) {
 N nodeU = checkedReferenceNode(edge);
 N nodeV = nodeConnections.get(nodeU).adjacentNode(edge);
 return EndpointPair.of(this, nodeU, nodeV);
}
origin: google/guava

 private GraphConnections<N, V> newConnections() {
  return isDirected()
    ? DirectedGraphConnections.<N, V>of()
    : UndirectedGraphConnections.<N, V>of();
 }
}
origin: google/guava

private static MutableGraph<Integer> buildDirectedGraph() {
 MutableGraph<Integer> directedGraph = GraphBuilder.directed().allowsSelfLoops(true).build();
 directedGraph.putEdge(N1, N1);
 directedGraph.putEdge(N1, N2);
 directedGraph.putEdge(N2, N1);
 return directedGraph;
}
origin: google/guava

private static <N> ImmutableGraph<N> graphWithNode(N node) {
 MutableGraph<N> graph = GraphBuilder.directed().build();
 graph.addNode(node);
 return ImmutableGraph.copyOf(graph);
}
origin: google/guava

/**
 * Returns a {@link GraphBuilder} initialized with all properties queryable from {@code graph}.
 *
 * <p>The "queryable" properties are those that are exposed through the {@link Graph} interface,
 * such as {@link Graph#isDirected()}. Other properties, such as {@link #expectedNodeCount(int)},
 * are not set in the new builder.
 */
public static <N> GraphBuilder<N> from(Graph<N> graph) {
 return new GraphBuilder<N>(graph.isDirected())
   .allowsSelfLoops(graph.allowsSelfLoops())
   .nodeOrder(graph.nodeOrder());
}
origin: google/guava

@Override
public EndpointPair<N> incidentNodes(E edge) {
 EndpointPair<N> endpointPair = delegate().incidentNodes(edge);
 return EndpointPair.of(network, endpointPair.nodeV(), endpointPair.nodeU()); // transpose
}
origin: google/guava

private static MutableGraph<Integer> buildUndirectedGraph() {
 MutableGraph<Integer> undirectedGraph = GraphBuilder.undirected().allowsSelfLoops(true).build();
 undirectedGraph.putEdge(N1, N1);
 undirectedGraph.putEdge(N1, N2);
 undirectedGraph.putEdge(N2, N1);
 return undirectedGraph;
}
origin: google/guava

protected boolean addEdge(EndpointPair<Integer> endpoints, String e) {
 network.addNode(endpoints.nodeU());
 network.addNode(endpoints.nodeV());
 return network.addEdge(endpoints, e);
}
origin: google/guava

 private static <N> ImmutableNetwork<N, N> networkWithNode(N node) {
  MutableNetwork<N, N> network = NetworkBuilder.directed().build();
  network.addNode(node);
  return ImmutableNetwork.copyOf(network);
 }
}
origin: google/guava

 @Override
 public V apply(EndpointPair<N> edge) {
  return graph.edgeValueOrDefault(edge.nodeU(), edge.nodeV(), null);
 }
};
origin: google/guava

@Override
public Set<E> edgesConnecting(EndpointPair<N> endpoints) {
 validateEndpoints(endpoints);
 return edgesConnecting(endpoints.nodeU(), endpoints.nodeV());
}
origin: google/guava

private static MutableValueGraph<Integer, String> buildUndirectedValueGraph() {
 MutableValueGraph<Integer, String> undirectedGraph =
   ValueGraphBuilder.undirected().allowsSelfLoops(true).build();
 undirectedGraph.putEdgeValue(N1, N1, E11);
 undirectedGraph.putEdgeValue(N1, N2, E12);
 undirectedGraph.putEdgeValue(N2, N1, E21); // overwrites E12
 return undirectedGraph;
}
origin: google/guava

@Override
public boolean putEdge(EndpointPair<N> endpoints) {
 validateEndpoints(endpoints);
 return putEdge(endpoints.nodeU(), endpoints.nodeV());
}
origin: google/guava

 @Override
 public N apply(E edge) {
  return network.incidentNodes(edge).target();
 }
};
origin: google/guava

 @Override
 public N apply(E edge) {
  return network.incidentNodes(edge).adjacentNode(node);
 }
};
origin: google/guava

 @Override
 public boolean hasEdgeConnecting(EndpointPair<N> endpoints) {
  return delegate().hasEdgeConnecting(transpose(endpoints));
 }
}
origin: google/guava

 @Override
 public boolean hasEdgeConnecting(EndpointPair<N> endpoints) {
  return delegate().hasEdgeConnecting(transpose(endpoints));
 }
}
origin: google/guava

 protected final V edgeValueOrDefault_internal(N nodeU, N nodeV, V defaultValue) {
  GraphConnections<N, V> connectionsU = nodeConnections.get(nodeU);
  V value = (connectionsU == null) ? null : connectionsU.value(nodeV);
  return value == null ? defaultValue : value;
 }
}
origin: google/guava

private static ImmutableGraph<Character> createSingleRootGraph() {
 MutableGraph<Character> graph = GraphBuilder.directed().build();
 graph.addNode('a');
 return ImmutableGraph.copyOf(graph);
}
com.google.common.graph

Most used classes

  • Traverser
    An object that can traverse the nodes that are reachable from a specified (set of) start node(s) usi
  • MutableGraph
    A subinterface of Graph which adds mutation methods. When mutation is not required, users should pre
  • EndpointPair
    An immutable pair representing the two endpoints of an edge in a graph. The EndpointPairof a directe
  • GraphBuilder
    A builder for constructing instances of MutableGraph with user-defined properties.A graph built by t
  • Graph
    An interface for graph [https://en.wikipedia.org/wiki/Graph_(discrete_mathematics)]-structured data,
  • NetworkBuilder,
  • Graphs,
  • Network,
  • ValueGraph,
  • MutableValueGraph,
  • ValueGraphBuilder,
  • ElementOrder,
  • ImmutableGraph,
  • ImmutableNetwork,
  • ImmutableValueGraph,
  • SuccessorsFunction,
  • MapIteratorCache,
  • MapRetrievalCache,
  • AbstractBaseGraph$IncidentEdgeSet$Directed
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now