本文整理汇总了Java中com.google.common.graph.GraphConstants.Presence类的典型用法代码示例。如果您正苦于以下问题:Java Presence类的具体用法?Java Presence怎么用?Java Presence使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Presence类属于com.google.common.graph.GraphConstants包,在下文中一共展示了Presence类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyOf
import com.google.common.graph.GraphConstants.Presence; //导入依赖的package包/类
/** Returns an immutable copy of {@code graph}. */
public static <N> ImmutableGraph<N> copyOf(Graph<N> graph) {
return (graph instanceof ImmutableGraph)
? (ImmutableGraph<N>) graph
: new ImmutableGraph<N>(new ConfigurableValueGraph<N, Presence>(
GraphBuilder.from(graph), getNodeConnections(graph), graph.edges().size()));
}
示例2: getNodeConnections
import com.google.common.graph.GraphConstants.Presence; //导入依赖的package包/类
private static <N> ImmutableMap<N, GraphConnections<N, Presence>> getNodeConnections(
Graph<N> graph) {
// ImmutableMap.Builder maintains the order of the elements as inserted, so the map will have
// whatever ordering the graph's nodes do, so ImmutableSortedMap is unnecessary even if the
// input nodes are sorted.
ImmutableMap.Builder<N, GraphConnections<N, Presence>> nodeConnections = ImmutableMap.builder();
for (N node : graph.nodes()) {
nodeConnections.put(node, connectionsOf(graph, node));
}
return nodeConnections.build();
}
示例3: connectionsOf
import com.google.common.graph.GraphConstants.Presence; //导入依赖的package包/类
private static <N> GraphConnections<N, Presence> connectionsOf(Graph<N> graph, N node) {
Function<Object, Presence> edgeValueFn = Functions.constant(Presence.EDGE_EXISTS);
return graph.isDirected()
? DirectedGraphConnections.ofImmutable(
graph.predecessors(node), Maps.asMap(graph.successors(node), edgeValueFn))
: UndirectedGraphConnections.ofImmutable(
Maps.asMap(graph.adjacentNodes(node), edgeValueFn));
}
示例4: copyOf
import com.google.common.graph.GraphConstants.Presence; //导入依赖的package包/类
/** Returns an immutable copy of {@code graph}. */
public static <N> ImmutableGraph<N> copyOf(Graph<N> graph) {
return (graph instanceof ImmutableGraph)
? (ImmutableGraph<N>) graph
: new ImmutableGraph<N>(
new ConfigurableValueGraph<N, Presence>(
GraphBuilder.from(graph), getNodeConnections(graph), graph.edges().size()));
}
示例5: ConfigurableMutableGraph
import com.google.common.graph.GraphConstants.Presence; //导入依赖的package包/类
/** Constructs a {@link MutableGraph} with the properties specified in {@code builder}. */
ConfigurableMutableGraph(AbstractGraphBuilder<? super N> builder) {
this.backingValueGraph = new ConfigurableMutableValueGraph<N, Presence>(builder);
}
示例6: putEdge
import com.google.common.graph.GraphConstants.Presence; //导入依赖的package包/类
@Override
public boolean putEdge(N nodeU, N nodeV) {
return backingValueGraph.putEdgeValue(nodeU, nodeV, Presence.EDGE_EXISTS) == null;
}