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

x33g5p2x  于2022-01-20 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(181)

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

Graph.allowsSelfLoops介绍

[英]Returns true if this graph allows self-loops (edges that connect a node to itself). Attempting to add a self-loop to a graph that does not allow them will throw an IllegalArgumentException.
[中]如果此图允许自循环(将节点连接到自身的边),则返回true。尝试向不允许自循环的图形添加自循环将引发IllegalArgumentException。

代码示例

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

static void assertStronglyEquivalent(Graph<?> graphA, Graph<?> graphB) {
 // Properties not covered by equals()
 assertThat(graphA.allowsSelfLoops()).isEqualTo(graphB.allowsSelfLoops());
 assertThat(graphA.nodeOrder()).isEqualTo(graphB.nodeOrder());
 assertThat(graphA).isEqualTo(graphB);
}

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

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

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

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

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

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

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

assertThat(graphString).contains("allowsSelfLoops: " + graph.allowsSelfLoops());
  if (!graph.allowsSelfLoops()) {
   assertThat(node).isNotEqualTo(adjacentNode);

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

@After
public void validateGraphState() {
 assertStronglyEquivalent(graph, Graphs.copyOf(graph));
 assertStronglyEquivalent(graph, ImmutableValueGraph.copyOf(graph));
 Graph<Integer> asGraph = graph.asGraph();
 AbstractGraphTest.validateGraph(asGraph);
 assertThat(graph.nodes()).isEqualTo(asGraph.nodes());
 assertThat(graph.edges()).isEqualTo(asGraph.edges());
 assertThat(graph.nodeOrder()).isEqualTo(asGraph.nodeOrder());
 assertThat(graph.isDirected()).isEqualTo(asGraph.isDirected());
 assertThat(graph.allowsSelfLoops()).isEqualTo(asGraph.allowsSelfLoops());
 for (Integer node : graph.nodes()) {
  assertThat(graph.adjacentNodes(node)).isEqualTo(asGraph.adjacentNodes(node));
  assertThat(graph.predecessors(node)).isEqualTo(asGraph.predecessors(node));
  assertThat(graph.successors(node)).isEqualTo(asGraph.successors(node));
  assertThat(graph.degree(node)).isEqualTo(asGraph.degree(node));
  assertThat(graph.inDegree(node)).isEqualTo(asGraph.inDegree(node));
  assertThat(graph.outDegree(node)).isEqualTo(asGraph.outDegree(node));
  for (Integer otherNode : graph.nodes()) {
   boolean hasEdge = graph.hasEdgeConnecting(node, otherNode);
   assertThat(hasEdge).isEqualTo(asGraph.hasEdgeConnecting(node, otherNode));
   assertThat(graph.edgeValueOrDefault(node, otherNode, null) != null).isEqualTo(hasEdge);
   assertThat(!graph.edgeValueOrDefault(node, otherNode, DEFAULT).equals(DEFAULT))
     .isEqualTo(hasEdge);
  }
 }
}

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

assertThat(network.nodeOrder()).isEqualTo(asGraph.nodeOrder());
assertThat(network.isDirected()).isEqualTo(asGraph.isDirected());
assertThat(network.allowsSelfLoops()).isEqualTo(asGraph.allowsSelfLoops());

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

static void assertStronglyEquivalent(Graph<?> treeA, Graph<?> treeB) {
 // Properties not covered by equals()
 assertThat(treeA.allowsSelfLoops()).isEqualTo(treeB.allowsSelfLoops());
 assertThat(treeA.nodeOrder()).isEqualTo(treeB.nodeOrder());
 assertThat(treeA).isEqualTo(treeB);
}

代码示例来源:origin: net.kyori/lunar

checkArgument(!graph.allowsSelfLoops(), "the graph cannot allow self loops");

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

static void assertStronglyEquivalent(Graph<?> graphA, Graph<?> graphB) {
 // Properties not covered by equals()
 assertThat(graphA.allowsSelfLoops()).isEqualTo(graphB.allowsSelfLoops());
 assertThat(graphA.nodeOrder()).isEqualTo(graphB.nodeOrder());
 assertThat(graphA).isEqualTo(graphB);
}

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

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

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

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

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

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

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

assertThat(graphString).contains("allowsSelfLoops: " + graph.allowsSelfLoops());
  if (!graph.allowsSelfLoops()) {
   assertThat(node).isNotEqualTo(adjacentNode);

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

@After
public void validateGraphState() {
 assertStronglyEquivalent(graph, Graphs.copyOf(graph));
 assertStronglyEquivalent(graph, ImmutableValueGraph.copyOf(graph));
 Graph<Integer> asGraph = graph.asGraph();
 AbstractGraphTest.validateGraph(asGraph);
 assertThat(graph.nodes()).isEqualTo(asGraph.nodes());
 assertThat(graph.edges()).isEqualTo(asGraph.edges());
 assertThat(graph.nodeOrder()).isEqualTo(asGraph.nodeOrder());
 assertThat(graph.isDirected()).isEqualTo(asGraph.isDirected());
 assertThat(graph.allowsSelfLoops()).isEqualTo(asGraph.allowsSelfLoops());
 for (Integer node : graph.nodes()) {
  assertThat(graph.adjacentNodes(node)).isEqualTo(asGraph.adjacentNodes(node));
  assertThat(graph.predecessors(node)).isEqualTo(asGraph.predecessors(node));
  assertThat(graph.successors(node)).isEqualTo(asGraph.successors(node));
  assertThat(graph.degree(node)).isEqualTo(asGraph.degree(node));
  assertThat(graph.inDegree(node)).isEqualTo(asGraph.inDegree(node));
  assertThat(graph.outDegree(node)).isEqualTo(asGraph.outDegree(node));
  for (Integer otherNode : graph.nodes()) {
   boolean hasEdge = graph.hasEdgeConnecting(node, otherNode);
   assertThat(hasEdge).isEqualTo(asGraph.hasEdgeConnecting(node, otherNode));
   assertThat(graph.edgeValueOrDefault(node, otherNode, null) != null).isEqualTo(hasEdge);
   assertThat(!graph.edgeValueOrDefault(node, otherNode, DEFAULT).equals(DEFAULT))
     .isEqualTo(hasEdge);
  }
 }
}

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

assertThat(network.nodeOrder()).isEqualTo(asGraph.nodeOrder());
assertThat(network.isDirected()).isEqualTo(asGraph.isDirected());
assertThat(network.allowsSelfLoops()).isEqualTo(asGraph.allowsSelfLoops());

相关文章