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

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

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

Network.allowsParallelEdges介绍

[英]Returns true if this network allows parallel edges. Attempting to add a parallel edge to a network that does not allow them will throw an IllegalArgumentException.
[中]如果此网络允许平行边,则返回true。尝试向不允许并行边缘的网络添加并行边缘将引发IllegalArgumentException。

代码示例

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

@Override
public boolean allowsParallelEdges() {
 return delegate().allowsParallelEdges();
}

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

@Override
public boolean allowsParallelEdges() {
 return network.allowsParallelEdges();
}

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

@Override
public boolean allowsParallelEdges() {
 return delegate().allowsParallelEdges();
}

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

@Override
public boolean allowsParallelEdges() {
 return delegate().allowsParallelEdges();
}

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

/**
 * Returns true if {@code network} has at least one cycle. A cycle is defined as a non-empty
 * subset of edges in a graph arranged to form a path (a sequence of adjacent outgoing edges)
 * starting and ending with the same node.
 *
 * <p>This method will detect any non-empty cycle, including self-loops (a cycle of length 1).
 */
public static boolean hasCycle(Network<?, ?> network) {
 // In a directed graph, parallel edges cannot introduce a cycle in an acyclic graph.
 // However, in an undirected graph, any parallel edge induces a cycle in the graph.
 if (!network.isDirected()
   && network.allowsParallelEdges()
   && network.edges().size() > network.asGraph().edges().size()) {
  return true;
 }
 return hasCycle(network.asGraph());
}

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

/**
 * Returns true if {@code network} has at least one cycle. A cycle is defined as a non-empty
 * subset of edges in a graph arranged to form a path (a sequence of adjacent outgoing edges)
 * starting and ending with the same node.
 *
 * <p>This method will detect any non-empty cycle, including self-loops (a cycle of length 1).
 */
public static boolean hasCycle(Network<?, ?> network) {
 // In a directed graph, parallel edges cannot introduce a cycle in an acyclic graph.
 // However, in an undirected graph, any parallel edge induces a cycle in the graph.
 if (!network.isDirected()
   && network.allowsParallelEdges()
   && network.edges().size() > network.asGraph().edges().size()) {
  return true;
 }
 return hasCycle(network.asGraph());
}

代码示例来源: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/guava

static void assertStronglyEquivalent(Network<?, ?> networkA, Network<?, ?> networkB) {
 // Properties not covered by equals()
 assertThat(networkA.allowsParallelEdges()).isEqualTo(networkB.allowsParallelEdges());
 assertThat(networkA.allowsSelfLoops()).isEqualTo(networkB.allowsSelfLoops());
 assertThat(networkA.nodeOrder()).isEqualTo(networkB.nodeOrder());
 assertThat(networkA.edgeOrder()).isEqualTo(networkB.edgeOrder());
 assertThat(networkA).isEqualTo(networkB);
}

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

/**
 * Returns true if {@code network} has at least one cycle. A cycle is defined as a non-empty
 * subset of edges in a graph arranged to form a path (a sequence of adjacent outgoing edges)
 * starting and ending with the same node.
 *
 * <p>This method will detect any non-empty cycle, including self-loops (a cycle of length 1).
 */
public static boolean hasCycle(Network<?, ?> network) {
 // In a directed graph, parallel edges cannot introduce a cycle in an acyclic graph.
 // However, in an undirected graph, any parallel edge induces a cycle in the graph.
 if (!network.isDirected()
   && network.allowsParallelEdges()
   && network.edges().size() > network.asGraph().edges().size()) {
  return true;
 }
 return hasCycle(network.asGraph());
}

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

/**
 * Returns a {@link NetworkBuilder} initialized with all properties queryable from {@code
 * network}.
 *
 * <p>The "queryable" properties are those that are exposed through the {@link Network} interface,
 * such as {@link Network#isDirected()}. Other properties, such as {@link
 * #expectedNodeCount(int)}, are not set in the new builder.
 */
public static <N, E> NetworkBuilder<N, E> from(Network<N, E> network) {
 return new NetworkBuilder<N, E>(network.isDirected())
   .allowsParallelEdges(network.allowsParallelEdges())
   .allowsSelfLoops(network.allowsSelfLoops())
   .nodeOrder(network.nodeOrder())
   .edgeOrder(network.edgeOrder());
}

代码示例来源: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: 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/j2objc

/**
 * Returns a {@link NetworkBuilder} initialized with all properties queryable from {@code
 * network}.
 *
 * <p>The "queryable" properties are those that are exposed through the {@link Network} interface,
 * such as {@link Network#isDirected()}. Other properties, such as {@link
 * #expectedNodeCount(int)}, are not set in the new builder.
 */
public static <N, E> NetworkBuilder<N, E> from(Network<N, E> network) {
 return new NetworkBuilder<N, E>(network.isDirected())
   .allowsParallelEdges(network.allowsParallelEdges())
   .allowsSelfLoops(network.allowsSelfLoops())
   .nodeOrder(network.nodeOrder())
   .edgeOrder(network.edgeOrder());
}

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

/**
 * Returns a {@link NetworkBuilder} initialized with all properties queryable from {@code
 * network}.
 *
 * <p>The "queryable" properties are those that are exposed through the {@link Network} interface,
 * such as {@link Network#isDirected()}. Other properties, such as {@link
 * #expectedNodeCount(int)}, are not set in the new builder.
 */
public static <N, E> NetworkBuilder<N, E> from(Network<N, E> network) {
 return new NetworkBuilder<N, E>(network.isDirected())
   .allowsParallelEdges(network.allowsParallelEdges())
   .allowsSelfLoops(network.allowsSelfLoops())
   .nodeOrder(network.nodeOrder())
   .edgeOrder(network.edgeOrder());
}

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

assertThat(networkString).contains("allowsParallelEdges: " + network.allowsParallelEdges());
assertThat(networkString).contains("allowsSelfLoops: " + network.allowsSelfLoops());
     .isEqualTo(Sets.intersection(network.outEdges(node), network.inEdges(otherNode)));
  if (!network.allowsParallelEdges()) {
   assertThat(edgesConnecting.size()).isAtMost(1);

代码示例来源:origin: org.jboss.eap/wildfly-client-all

@Override
public boolean allowsParallelEdges() {
 return delegate().allowsParallelEdges();
}

代码示例来源:origin: com.google.guava/guava-tests

@Override
public boolean allowsParallelEdges() {
 return network.allowsParallelEdges();
}

代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

@Override
public boolean allowsParallelEdges() {
 return delegate().allowsParallelEdges();
}

代码示例来源:origin: com.google.guava/guava-tests

static void assertStronglyEquivalent(Network<?, ?> networkA, Network<?, ?> networkB) {
 // Properties not covered by equals()
 assertThat(networkA.allowsParallelEdges()).isEqualTo(networkB.allowsParallelEdges());
 assertThat(networkA.allowsSelfLoops()).isEqualTo(networkB.allowsSelfLoops());
 assertThat(networkA.nodeOrder()).isEqualTo(networkB.nodeOrder());
 assertThat(networkA.edgeOrder()).isEqualTo(networkB.edgeOrder());
 assertThat(networkA).isEqualTo(networkB);
}

代码示例来源:origin: com.io7m.jgrapht/jgrapht-guava

@Override
public GraphType getType()
{
  return (network.isDirected() ? new DefaultGraphType.Builder().directed()
    : new DefaultGraphType.Builder().undirected())
      .weighted(false).allowMultipleEdges(network.allowsParallelEdges())
      .allowSelfLoops(network.allowsSelfLoops()).build();
}

相关文章