com.google.common.graph.Network.nodes()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(157)

本文整理了Java中com.google.common.graph.Network.nodes()方法的一些代码示例,展示了Network.nodes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Network.nodes()方法的具体详情如下:
包路径:com.google.common.graph.Network
类名称:Network
方法名:nodes

Network.nodes介绍

[英]Returns all nodes in this network, in the order specified by #nodeOrder().
[中]按#nodeOrder()指定的顺序返回此网络中的所有节点。

代码示例

代码示例来源:origin: google/guava

private static <N, E> Map<N, NetworkConnections<N, E>> getNodeConnections(Network<N, E> network) {
 // ImmutableMap.Builder maintains the order of the elements as inserted, so the map will have
 // whatever ordering the network's nodes do, so ImmutableSortedMap is unnecessary even if the
 // input nodes are sorted.
 ImmutableMap.Builder<N, NetworkConnections<N, E>> nodeConnections = ImmutableMap.builder();
 for (N node : network.nodes()) {
  nodeConnections.put(node, connectionsOf(network, node));
 }
 return nodeConnections.build();
}

代码示例来源:origin: google/guava

@Override
public Set<N> nodes() {
 return delegate().nodes();
}

代码示例来源:origin: google/guava

@Override
public Set<N> nodes() {
 return network.nodes();
}

代码示例来源:origin: google/j2objc

private static <N, E> Map<N, NetworkConnections<N, E>> getNodeConnections(Network<N, E> network) {
 // ImmutableMap.Builder maintains the order of the elements as inserted, so the map will have
 // whatever ordering the network's nodes do, so ImmutableSortedMap is unnecessary even if the
 // input nodes are sorted.
 ImmutableMap.Builder<N, NetworkConnections<N, E>> nodeConnections = ImmutableMap.builder();
 for (N node : network.nodes()) {
  nodeConnections.put(node, connectionsOf(network, node));
 }
 return nodeConnections.build();
}

代码示例来源:origin: google/j2objc

@Override
public Set<N> nodes() {
 return delegate().nodes();
}

代码示例来源:origin: wildfly/wildfly

private static <N, E> Map<N, NetworkConnections<N, E>> getNodeConnections(Network<N, E> network) {
 // ImmutableMap.Builder maintains the order of the elements as inserted, so the map will have
 // whatever ordering the network's nodes do, so ImmutableSortedMap is unnecessary even if the
 // input nodes are sorted.
 ImmutableMap.Builder<N, NetworkConnections<N, E>> nodeConnections = ImmutableMap.builder();
 for (N node : network.nodes()) {
  nodeConnections.put(node, connectionsOf(network, node));
 }
 return nodeConnections.build();
}

代码示例来源:origin: wildfly/wildfly

@Override
public Set<N> nodes() {
 return delegate().nodes();
}

代码示例来源:origin: google/guava

@Override
public final boolean equals(@Nullable Object obj) {
 if (obj == this) {
  return true;
 }
 if (!(obj instanceof Network)) {
  return false;
 }
 Network<?, ?> other = (Network<?, ?>) obj;
 return isDirected() == other.isDirected()
   && nodes().equals(other.nodes())
   && edgeIncidentNodesMap(this).equals(edgeIncidentNodesMap(other));
}

代码示例来源:origin: google/guava

/** Creates a mutable copy of {@code network} with the same nodes and edges. */
public static <N, E> MutableNetwork<N, E> copyOf(Network<N, E> network) {
 MutableNetwork<N, E> copy =
   NetworkBuilder.from(network)
     .expectedNodeCount(network.nodes().size())
     .expectedEdgeCount(network.edges().size())
     .build();
 for (N node : network.nodes()) {
  copy.addNode(node);
 }
 for (E edge : network.edges()) {
  EndpointPair<N> endpointPair = network.incidentNodes(edge);
  copy.addEdge(endpointPair.nodeU(), endpointPair.nodeV(), edge);
 }
 return copy;
}

代码示例来源:origin: google/j2objc

@Override
public final boolean equals(@NullableDecl Object obj) {
 if (obj == this) {
  return true;
 }
 if (!(obj instanceof Network)) {
  return false;
 }
 Network<?, ?> other = (Network<?, ?>) obj;
 return isDirected() == other.isDirected()
   && nodes().equals(other.nodes())
   && edgeIncidentNodesMap(this).equals(edgeIncidentNodesMap(other));
}

代码示例来源:origin: wildfly/wildfly

@Override
public final boolean equals(@NullableDecl Object obj) {
 if (obj == this) {
  return true;
 }
 if (!(obj instanceof Network)) {
  return false;
 }
 Network<?, ?> other = (Network<?, ?>) obj;
 return isDirected() == other.isDirected()
   && nodes().equals(other.nodes())
   && edgeIncidentNodesMap(this).equals(edgeIncidentNodesMap(other));
}

代码示例来源:origin: google/j2objc

/** Creates a mutable copy of {@code network} with the same nodes and edges. */
public static <N, E> MutableNetwork<N, E> copyOf(Network<N, E> network) {
 MutableNetwork<N, E> copy =
   NetworkBuilder.from(network)
     .expectedNodeCount(network.nodes().size())
     .expectedEdgeCount(network.edges().size())
     .build();
 for (N node : network.nodes()) {
  copy.addNode(node);
 }
 for (E edge : network.edges()) {
  EndpointPair<N> endpointPair = network.incidentNodes(edge);
  copy.addEdge(endpointPair.nodeU(), endpointPair.nodeV(), edge);
 }
 return copy;
}

代码示例来源:origin: wildfly/wildfly

/** Creates a mutable copy of {@code network} with the same nodes and edges. */
public static <N, E> MutableNetwork<N, E> copyOf(Network<N, E> network) {
 MutableNetwork<N, E> copy =
   NetworkBuilder.from(network)
     .expectedNodeCount(network.nodes().size())
     .expectedEdgeCount(network.edges().size())
     .build();
 for (N node : network.nodes()) {
  copy.addNode(node);
 }
 for (E edge : network.edges()) {
  EndpointPair<N> endpointPair = network.incidentNodes(edge);
  copy.addEdge(endpointPair.nodeU(), endpointPair.nodeV(), edge);
 }
 return copy;
}

代码示例来源:origin: google/guava

assertThat(network.nodes()).isEqualTo(asGraph.nodes());
assertThat(network.edges().size()).isAtLeast(asGraph.edges().size());
assertThat(network.nodeOrder()).isEqualTo(asGraph.nodeOrder());
  assertThat(network.nodes()).contains(incidentNode);
  for (E adjacentEdge : network.incidentEdges(incidentNode)) {
   assertTrue(
for (N node : sanityCheckSet(network.nodes())) {
 assertThat(nodeString).contains(node.toString());
 for (N otherNode : network.nodes()) {
  Set<E> edgesConnecting = sanityCheckSet(network.edgesConnecting(node, otherNode));
  switch (edgesConnecting.size()) {

代码示例来源:origin: jrtom/jung

public boolean contains(Network inGraph, Object inNode) {
 boolean contained = false;
 if (inGraph.nodes().contains(inNode)) {
  // inNode is one of the nodes in inGraph
  return true;
 }
 for (Object node : inGraph.nodes()) {
  contained |= (node instanceof Network) && contains((Network) node, inNode);
 }
 return contained;
}

代码示例来源:origin: jrtom/jung

/**
 * Creates an instance for the specified graph and alpha (random jump probability) parameter. The
 * edge weights are all set to 1.
 *
 * @param g the input graph
 * @param alpha the probability of a hub giving some authority to all nodes, and of an authority
 *     increasing the score of all hubs (not just those connected via links)
 */
public HITS(Network<N, E> g, double alpha) {
 super(g, ScoringUtils.getHITSUniformRootPrior(g.nodes()), alpha);
}

代码示例来源:origin: batfish/batfish

/**
 * Initialize incoming EIGRP message queues for each adjacency
 *
 * @param eigrpTopology The topology representing EIGRP adjacencies
 */
void initQueues(Network<EigrpInterface, EigrpEdge> eigrpTopology) {
 _incomingRoutes =
   _interfaces.stream()
     .filter(eigrpTopology.nodes()::contains)
     .flatMap(n -> eigrpTopology.inEdges(n).stream())
     .collect(toImmutableSortedMap(Function.identity(), e -> new ConcurrentLinkedQueue<>()));
}

代码示例来源:origin: jrtom/jung

/**
 * A graph is "forest-shaped" if it is directed, acyclic, and each node has at most one
 * predecessor.
 */
public static <N> boolean isForestShaped(Network<N, ?> graph) {
 checkNotNull(graph, "graph");
 return graph.isDirected()
   && !Graphs.hasCycle(graph)
   && graph.nodes().stream().allMatch(node -> graph.predecessors(node).size() <= 1);
}

代码示例来源:origin: jrtom/jung

public void setNetwork(Network<N, E> network, boolean forceUpdate) {
 log.trace("setNetwork to n:{} e:{}", network.nodes(), network.edges());
 this.network = network;
 this.layoutModel.setGraph(network.asGraph());
 if (forceUpdate && this.layoutAlgorithm != null) {
  log.trace("will accept {}", layoutAlgorithm);
  layoutModel.accept(this.layoutAlgorithm);
  log.trace("will fire stateChanged");
  changeSupport.fireStateChanged();
  log.trace("fired stateChanged");
 }
}

代码示例来源:origin: jrtom/jung

protected Collection<N> getFilteredNodes() {
 Set<N> nodes = vv.getModel().getNetwork().nodes();
 return nodesAreFiltered()
   ? Sets.filter(nodes, vv.getRenderContext().getNodeIncludePredicate()::test)
   : nodes;
}

相关文章