本文整理了Java中com.google.common.graph.Network.edgesConnecting()
方法的一些代码示例,展示了Network.edgesConnecting()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Network.edgesConnecting()
方法的具体详情如下:
包路径:com.google.common.graph.Network
类名称:Network
方法名:edgesConnecting
[英]Returns the set of edges that each directly connect endpoints (in the order, if any, specified by endpoints).
The resulting set of edges will be parallel (i.e. have equal #incidentNodes(Object). If this network does not #allowsParallelEdges(), the resulting set will contain at most one edge (equivalent to edgeConnecting(endpoints).asSet()).
If this network is directed, endpoints must be ordered.
[中]返回每个直接连接端点的边集(按端点指定的顺序,如果有)。
生成的边集将是平行的(即具有相等的#意外节点(对象))。如果此网络不#AllowsParallelEdge(),则结果集最多将包含一条边(相当于EdgeConnection(端点))。资产())。
如果该网络是定向的,则必须对端点进行排序。
代码示例来源:origin: google/guava
@Override
public Set<E> edgesConnecting(N nodeU, N nodeV) {
return delegate().edgesConnecting(nodeU, nodeV);
}
代码示例来源:origin: google/guava
@Override
public Set<E> edgesConnecting(EndpointPair<N> endpoints) {
return delegate().edgesConnecting(endpoints);
}
代码示例来源:origin: google/guava
@Override
public Set<E> edgesConnecting(N nodeU, N nodeV) {
return delegate().edgesConnecting(nodeV, nodeU); // transpose
}
代码示例来源:origin: google/j2objc
@Override
public Set<E> edgesConnecting(N nodeU, N nodeV) {
return delegate().edgesConnecting(nodeU, nodeV);
}
代码示例来源:origin: google/j2objc
@Override
public Set<E> edgesConnecting(N nodeU, N nodeV) {
return delegate().edgesConnecting(nodeV, nodeU); // transpose
}
代码示例来源:origin: google/guava
@Override
public Set<E> edgesConnecting(EndpointPair<N> endpoints) {
return delegate().edgesConnecting(transpose(endpoints));
}
代码示例来源:origin: wildfly/wildfly
@Override
public Set<E> edgesConnecting(N nodeU, N nodeV) {
return delegate().edgesConnecting(nodeV, nodeU); // transpose
}
代码示例来源:origin: wildfly/wildfly
@Override
public Set<E> edgesConnecting(N nodeU, N nodeV) {
return delegate().edgesConnecting(nodeU, nodeV);
}
代码示例来源:origin: google/guava
@Test
public void edgesConnecting_undirected() {
MutableNetwork<String, String> mutableNetwork =
NetworkBuilder.undirected().allowsSelfLoops(true).build();
mutableNetwork.addEdge("A", "A", "AA");
mutableNetwork.addEdge("A", "B", "AB");
Network<String, String> network = ImmutableNetwork.copyOf(mutableNetwork);
assertThat(network.edgesConnecting("A", "A")).containsExactly("AA");
assertThat(network.edgesConnecting("A", "B")).containsExactly("AB");
assertThat(network.edgesConnecting("B", "A")).containsExactly("AB");
}
}
代码示例来源:origin: google/guava
@Test
public void edgesConnecting_directed() {
MutableNetwork<String, String> mutableNetwork =
NetworkBuilder.directed().allowsSelfLoops(true).build();
mutableNetwork.addEdge("A", "A", "AA");
mutableNetwork.addEdge("A", "B", "AB");
Network<String, String> network = ImmutableNetwork.copyOf(mutableNetwork);
assertThat(network.edgesConnecting("A", "A")).containsExactly("AA");
assertThat(network.edgesConnecting("A", "B")).containsExactly("AB");
assertThat(network.edgesConnecting("B", "A")).isEmpty();
}
代码示例来源:origin: google/guava
private static <N, E> NetworkConnections<N, E> connectionsOf(Network<N, E> network, N node) {
if (network.isDirected()) {
Map<E, N> inEdgeMap = Maps.asMap(network.inEdges(node), sourceNodeFn(network));
Map<E, N> outEdgeMap = Maps.asMap(network.outEdges(node), targetNodeFn(network));
int selfLoopCount = network.edgesConnecting(node, node).size();
return network.allowsParallelEdges()
? DirectedMultiNetworkConnections.ofImmutable(inEdgeMap, outEdgeMap, selfLoopCount)
: DirectedNetworkConnections.ofImmutable(inEdgeMap, outEdgeMap, selfLoopCount);
} else {
Map<E, N> incidentEdgeMap =
Maps.asMap(network.incidentEdges(node), adjacentNodeFn(network, node));
return network.allowsParallelEdges()
? UndirectedMultiNetworkConnections.ofImmutable(incidentEdgeMap)
: UndirectedNetworkConnections.ofImmutable(incidentEdgeMap);
}
}
代码示例来源:origin: google/j2objc
private static <N, E> NetworkConnections<N, E> connectionsOf(Network<N, E> network, N node) {
if (network.isDirected()) {
Map<E, N> inEdgeMap = Maps.asMap(network.inEdges(node), sourceNodeFn(network));
Map<E, N> outEdgeMap = Maps.asMap(network.outEdges(node), targetNodeFn(network));
int selfLoopCount = network.edgesConnecting(node, node).size();
return network.allowsParallelEdges()
? DirectedMultiNetworkConnections.ofImmutable(inEdgeMap, outEdgeMap, selfLoopCount)
: DirectedNetworkConnections.ofImmutable(inEdgeMap, outEdgeMap, selfLoopCount);
} else {
Map<E, N> incidentEdgeMap =
Maps.asMap(network.incidentEdges(node), adjacentNodeFn(network, node));
return network.allowsParallelEdges()
? UndirectedMultiNetworkConnections.ofImmutable(incidentEdgeMap)
: UndirectedNetworkConnections.ofImmutable(incidentEdgeMap);
}
}
代码示例来源:origin: google/guava
AbstractNetworkTest.validateNetwork(transpose);
assertThat(transpose.edgesConnecting(N1, N2)).isEmpty();
assertThat(transpose.edgeConnecting(N1, N2).isPresent()).isFalse();
assertThat(transpose.edgeConnectingOrNull(N1, N2)).isNull();
assertThat(transpose.edgesConnecting(N1, N2)).containsExactly(E21);
assertThat(transpose.edgeConnecting(N1, N2).get()).isEqualTo(E21);
assertThat(transpose.edgeConnectingOrNull(N1, N2)).isEqualTo(E21);
代码示例来源:origin: wildfly/wildfly
private static <N, E> NetworkConnections<N, E> connectionsOf(Network<N, E> network, N node) {
if (network.isDirected()) {
Map<E, N> inEdgeMap = Maps.asMap(network.inEdges(node), sourceNodeFn(network));
Map<E, N> outEdgeMap = Maps.asMap(network.outEdges(node), targetNodeFn(network));
int selfLoopCount = network.edgesConnecting(node, node).size();
return network.allowsParallelEdges()
? DirectedMultiNetworkConnections.ofImmutable(inEdgeMap, outEdgeMap, selfLoopCount)
: DirectedNetworkConnections.ofImmutable(inEdgeMap, outEdgeMap, selfLoopCount);
} else {
Map<E, N> incidentEdgeMap =
Maps.asMap(network.incidentEdges(node), adjacentNodeFn(network, node));
return network.allowsParallelEdges()
? UndirectedMultiNetworkConnections.ofImmutable(incidentEdgeMap)
: UndirectedNetworkConnections.ofImmutable(incidentEdgeMap);
}
}
代码示例来源:origin: google/guava
N nodeV = endpointPair.nodeV();
assertThat(asGraph.edges()).contains(EndpointPair.of(network, nodeU, nodeV));
assertThat(network.edgesConnecting(nodeU, nodeV)).contains(edge);
assertThat(network.successors(nodeU)).contains(nodeV);
assertThat(network.adjacentNodes(nodeU)).contains(nodeV);
assertThat(network.successors(node)).isEqualTo(asGraph.successors(node));
int selfLoopCount = network.edgesConnecting(node, node).size();
assertThat(network.incidentEdges(node).size() + selfLoopCount)
.isEqualTo(network.degree(node));
Set<E> edgesConnecting = sanityCheckSet(network.edgesConnecting(node, otherNode));
switch (edgesConnecting.size()) {
case 0:
|| network.successors(node).contains(adjacentNode));
assertTrue(
!network.edgesConnecting(node, adjacentNode).isEmpty()
|| !network.edgesConnecting(adjacentNode, node).isEmpty());
assertThat(network.edgesConnecting(predecessor, node)).isNotEmpty();
assertThat(network.edgesConnecting(node, successor)).isNotEmpty();
代码示例来源:origin: com.io7m.jgrapht/jgrapht-guava
@Override
public Set<E> getAllEdges(V sourceVertex, V targetVertex)
{
return network.edgesConnecting(sourceVertex, targetVertex);
}
代码示例来源:origin: com.io7m.jgrapht/jgrapht-guava
@Override
public E getEdge(V sourceVertex, V targetVertex)
{
return network
.edgesConnecting(sourceVertex, targetVertex).stream().findFirst().orElse(null);
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
@Override
public Set<E> edgesConnecting(N nodeU, N nodeV) {
return delegate().edgesConnecting(nodeU, nodeV);
}
代码示例来源:origin: com.google.guava/guava-tests
@Test
public void edgesConnecting_directed() {
MutableNetwork<String, String> mutableNetwork =
NetworkBuilder.directed().allowsSelfLoops(true).build();
mutableNetwork.addEdge("A", "A", "AA");
mutableNetwork.addEdge("A", "B", "AB");
Network<String, String> network = ImmutableNetwork.copyOf(mutableNetwork);
assertThat(network.edgesConnecting("A", "A")).containsExactly("AA");
assertThat(network.edgesConnecting("A", "B")).containsExactly("AB");
assertThat(network.edgesConnecting("B", "A")).isEmpty();
}
代码示例来源:origin: com.google.guava/guava-tests
@Test
public void edgesConnecting_undirected() {
MutableNetwork<String, String> mutableNetwork =
NetworkBuilder.undirected().allowsSelfLoops(true).build();
mutableNetwork.addEdge("A", "A", "AA");
mutableNetwork.addEdge("A", "B", "AB");
Network<String, String> network = ImmutableNetwork.copyOf(mutableNetwork);
assertThat(network.edgesConnecting("A", "A")).containsExactly("AA");
assertThat(network.edgesConnecting("A", "B")).containsExactly("AB");
assertThat(network.edgesConnecting("B", "A")).containsExactly("AB");
}
}
内容来源于网络,如有侵权,请联系作者删除!