本文整理了Java中com.google.common.graph.Network.incidentNodes()
方法的一些代码示例,展示了Network.incidentNodes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Network.incidentNodes()
方法的具体详情如下:
包路径:com.google.common.graph.Network
类名称:Network
方法名:incidentNodes
[英]Returns the nodes which are the endpoints of edge in this network.
[中]返回作为此网络中edge的端点的节点。
代码示例来源:origin: google/guava
@Override
public EndpointPair<N> apply(E edge) {
return network.incidentNodes(edge);
}
};
代码示例来源:origin: google/j2objc
@Override
public EndpointPair<N> apply(E edge) {
return network.incidentNodes(edge);
}
};
代码示例来源: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 N apply(E edge) {
return network.incidentNodes(edge).source();
}
};
代码示例来源:origin: google/guava
@Override
public EndpointPair<N> incidentNodes(E edge) {
return network.incidentNodes(edge);
}
代码示例来源:origin: google/guava
@Override
public EndpointPair<N> incidentNodes(E edge) {
return delegate().incidentNodes(edge);
}
代码示例来源:origin: google/guava
private static <N, E> Map<E, N> getEdgeToReferenceNode(Network<N, E> network) {
// ImmutableMap.Builder maintains the order of the elements as inserted, so the map will have
// whatever ordering the network's edges do, so ImmutableSortedMap is unnecessary even if the
// input edges are sorted.
ImmutableMap.Builder<E, N> edgeToReferenceNode = ImmutableMap.builder();
for (E edge : network.edges()) {
edgeToReferenceNode.put(edge, network.incidentNodes(edge).nodeU());
}
return edgeToReferenceNode.build();
}
代码示例来源:origin: google/j2objc
@Override
public N apply(E edge) {
return network.incidentNodes(edge).source();
}
};
代码示例来源:origin: google/j2objc
@Override
public N apply(E edge) {
return network.incidentNodes(edge).target();
}
};
代码示例来源:origin: google/j2objc
@Override
public N apply(E edge) {
return network.incidentNodes(edge).adjacentNode(node);
}
};
代码示例来源:origin: google/j2objc
@Override
public EndpointPair<N> incidentNodes(E edge) {
return delegate().incidentNodes(edge);
}
代码示例来源:origin: wildfly/wildfly
@Override
public N apply(E edge) {
return network.incidentNodes(edge).source();
}
};
代码示例来源:origin: wildfly/wildfly
@Override
public N apply(E edge) {
return network.incidentNodes(edge).target();
}
};
代码示例来源:origin: google/j2objc
private static <N, E> Map<E, N> getEdgeToReferenceNode(Network<N, E> network) {
// ImmutableMap.Builder maintains the order of the elements as inserted, so the map will have
// whatever ordering the network's edges do, so ImmutableSortedMap is unnecessary even if the
// input edges are sorted.
ImmutableMap.Builder<E, N> edgeToReferenceNode = ImmutableMap.builder();
for (E edge : network.edges()) {
edgeToReferenceNode.put(edge, network.incidentNodes(edge).nodeU());
}
return edgeToReferenceNode.build();
}
代码示例来源: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/j2objc
@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
/** 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
/**
* Returns the subgraph of {@code network} induced by {@code nodes}. This subgraph is a new graph
* that contains all of the nodes in {@code nodes}, and all of the {@link Network#edges() edges}
* from {@code network} for which the {@link Network#incidentNodes(Object) incident nodes} are
* both contained by {@code nodes}.
*
* @throws IllegalArgumentException if any element in {@code nodes} is not a node in the graph
*/
public static <N, E> MutableNetwork<N, E> inducedSubgraph(
Network<N, E> network, Iterable<? extends N> nodes) {
MutableNetwork<N, E> subgraph =
(nodes instanceof Collection)
? NetworkBuilder.from(network).expectedNodeCount(((Collection) nodes).size()).build()
: NetworkBuilder.from(network).build();
for (N node : nodes) {
subgraph.addNode(node);
}
for (N node : subgraph.nodes()) {
for (E edge : network.outEdges(node)) {
N successorNode = network.incidentNodes(edge).adjacentNode(node);
if (subgraph.nodes().contains(successorNode)) {
subgraph.addEdge(node, successorNode, edge);
}
}
}
return subgraph;
}
代码示例来源: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;
}
内容来源于网络,如有侵权,请联系作者删除!