本文整理汇总了Java中com.google.javascript.jscomp.graph.UndiGraph.connect方法的典型用法代码示例。如果您正苦于以下问题:Java UndiGraph.connect方法的具体用法?Java UndiGraph.connect怎么用?Java UndiGraph.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.javascript.jscomp.graph.UndiGraph
的用法示例。
在下文中一共展示了UndiGraph.connect方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testUndirectedSimple
import com.google.javascript.jscomp.graph.UndiGraph; //导入方法依赖的package包/类
public void testUndirectedSimple() {
UndiGraph<String, String> graph =
new LinkedUndirectedGraph<String, String>();
graph.createNode("a");
graph.createNode("b");
graph.createNode("c");
graph.connect("a", "--", "b");
assertTrue(graph.hasNode("a"));
assertTrue(graph.hasNode("b"));
assertTrue(graph.hasNode("c"));
assertFalse(graph.hasNode("d"));
assertTrue(graph.isConnected("a", "b"));
assertTrue(graph.isConnected("b", "a"));
assertFalse(graph.isConnected("a", "c"));
assertFalse(graph.isConnected("b", "c"));
assertFalse(graph.isConnected("c", "a"));
assertFalse(graph.isConnected("c", "b"));
assertFalse(graph.isConnected("a", "a"));
assertFalse(graph.isConnected("b", "b"));
assertFalse(graph.isConnected("b", "c"));
// Removal.
graph.disconnect("a", "b");
assertFalse(graph.isConnected("a", "b"));
assertFalse(graph.isConnected("b", "a"));
}
示例2: testUndirectedNeighbors
import com.google.javascript.jscomp.graph.UndiGraph; //导入方法依赖的package包/类
public void testUndirectedNeighbors() {
UndiGraph<String, String> graph =
new LinkedUndirectedGraph<String, String>();
graph.createNode("a");
graph.createNode("b");
graph.createNode("c");
graph.createNode("d");
graph.connect("a", "-", "b");
graph.connect("a", "--", "b");
graph.connect("a", "---", "b");
graph.connect("a", "-", "c");
graph.connect("c", "-", "d");
assertSetEquals(graph.getNeighborNodes("a"), "b", "c");
assertSetEquals(graph.getNeighborNodes("b"), "a");
assertSetEquals(graph.getNeighborNodes("c"), "a", "d");
assertListCount(graph.getNeighborNodes("a"), "b", 3);
// Removal.
graph.disconnect("a", "b");
assertFalse(graph.isConnected("a", "b"));
}
示例3: testSimpleSubGraph
import com.google.javascript.jscomp.graph.UndiGraph; //导入方法依赖的package包/类
public void testSimpleSubGraph() {
UndiGraph<String, String> graph =
new LinkedUndirectedGraph<String, String>();
graph.createNode("a");
graph.createNode("b");
graph.createNode("c");
graph.connect("a", "--", "b");
SubGraph<String, String> subGraph = graph.newSubGraph();
subGraph.addNode("a");
subGraph.addNode("b");
try {
subGraph.addNode("d");
fail("SubGraph should not allow add for node that is not in graph.");
} catch (IllegalArgumentException e) {
// exception expected
}
assertFalse(subGraph.isIndependentOf("a"));
assertFalse(subGraph.isIndependentOf("b"));
assertTrue(subGraph.isIndependentOf("c"));
}
示例4: testUndirectedSimple
import com.google.javascript.jscomp.graph.UndiGraph; //导入方法依赖的package包/类
public void testUndirectedSimple() {
UndiGraph<String, String> graph =
LinkedUndirectedGraph.create();
graph.createNode("a");
graph.createNode("b");
graph.createNode("c");
graph.connect("a", "--", "b");
assertTrue(graph.hasNode("a"));
assertTrue(graph.hasNode("b"));
assertTrue(graph.hasNode("c"));
assertFalse(graph.hasNode("d"));
assertTrue(graph.isConnected("a", "b"));
assertTrue(graph.isConnected("b", "a"));
assertFalse(graph.isConnected("a", "c"));
assertFalse(graph.isConnected("b", "c"));
assertFalse(graph.isConnected("c", "a"));
assertFalse(graph.isConnected("c", "b"));
assertFalse(graph.isConnected("a", "a"));
assertFalse(graph.isConnected("b", "b"));
assertFalse(graph.isConnected("b", "c"));
// Removal.
graph.disconnect("a", "b");
assertFalse(graph.isConnected("a", "b"));
assertFalse(graph.isConnected("b", "a"));
}
示例5: testUndirectedNeighbors
import com.google.javascript.jscomp.graph.UndiGraph; //导入方法依赖的package包/类
public void testUndirectedNeighbors() {
UndiGraph<String, String> graph =
LinkedUndirectedGraph.create();
graph.createNode("a");
graph.createNode("b");
graph.createNode("c");
graph.createNode("d");
graph.connect("a", "-", "b");
graph.connect("a", "--", "b");
graph.connect("a", "---", "b");
graph.connect("a", "-", "c");
graph.connect("c", "-", "d");
assertSetEquals(graph.getNeighborNodes("a"), "b", "c");
assertSetEquals(graph.getNeighborNodes("b"), "a");
assertSetEquals(graph.getNeighborNodes("c"), "a", "d");
assertListCount(graph.getNeighborNodes("a"), "b", 3);
// Removal.
graph.disconnect("a", "b");
assertFalse(graph.isConnected("a", "b"));
}
示例6: testSimpleSubGraph
import com.google.javascript.jscomp.graph.UndiGraph; //导入方法依赖的package包/类
public void testSimpleSubGraph() {
UndiGraph<String, String> graph =
LinkedUndirectedGraph.create();
graph.createNode("a");
graph.createNode("b");
graph.createNode("c");
graph.connect("a", "--", "b");
SubGraph<String, String> subGraph = graph.newSubGraph();
subGraph.addNode("a");
subGraph.addNode("b");
try {
subGraph.addNode("d");
fail("SubGraph should not allow add for node that is not in graph.");
} catch (IllegalArgumentException e) {
// exception expected
}
assertFalse(subGraph.isIndependentOf("a"));
assertFalse(subGraph.isIndependentOf("b"));
assertTrue(subGraph.isIndependentOf("c"));
}
示例7: testUndirectedSelfLoop
import com.google.javascript.jscomp.graph.UndiGraph; //导入方法依赖的package包/类
public void testUndirectedSelfLoop() {
UndiGraph<String, String> graph =
new LinkedUndirectedGraph<String, String>();
graph.createNode("a");
graph.createNode("b");
graph.connect("a", "--", "a");
assertTrue(graph.isConnected("a", "a"));
assertFalse(graph.isConnected("a", "b"));
assertFalse(graph.isConnected("b", "a"));
// Removal.
graph.disconnect("a", "a");
assertFalse(graph.isConnected("a", "a"));
}
示例8: testUndirectedSelfLoop
import com.google.javascript.jscomp.graph.UndiGraph; //导入方法依赖的package包/类
public void testUndirectedSelfLoop() {
UndiGraph<String, String> graph =
LinkedUndirectedGraph.create();
graph.createNode("a");
graph.createNode("b");
graph.connect("a", "--", "a");
assertTrue(graph.isConnected("a", "a"));
assertFalse(graph.isConnected("a", "b"));
assertFalse(graph.isConnected("b", "a"));
// Removal.
graph.disconnect("a", "a");
assertFalse(graph.isConnected("a", "a"));
}
示例9: testUndirectedGetFirstEdge
import com.google.javascript.jscomp.graph.UndiGraph; //导入方法依赖的package包/类
public void testUndirectedGetFirstEdge() {
UndiGraph<String, String> graph =
LinkedUndirectedGraph.create();
graph.createNode("a");
graph.createNode("b");
graph.createNode("c");
graph.connect("a", "-", "b");
assertEquals(graph.getFirstEdge("a", "b").getValue(), "-");
assertEquals(graph.getFirstEdge("b", "a").getValue(), "-");
assertNull(graph.getFirstEdge("a", "c"));
}