本文整理汇总了TypeScript中vs/platform/instantiation/common/graph.Graph类的典型用法代码示例。如果您正苦于以下问题:TypeScript Graph类的具体用法?TypeScript Graph怎么用?TypeScript Graph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Graph类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: suite
suite('Graph', () => {
let graph: Graph<string>;
setup(() => {
graph = new Graph<string>(s => s);
});
test('is possible to lookup nodes that don\'t exist', function () {
assert.deepEqual(graph.lookup('ddd'), null);
});
test('inserts nodes when not there yet', function () {
assert.deepEqual(graph.lookup('ddd'), null);
assert.deepEqual(graph.lookupOrInsertNode('ddd').data, 'ddd');
assert.deepEqual(graph.lookup('ddd').data, 'ddd');
});
test('can remove nodes and get length', function () {
assert.ok(graph.isEmpty());
assert.deepEqual(graph.lookup('ddd'), null);
assert.deepEqual(graph.lookupOrInsertNode('ddd').data, 'ddd');
assert.ok(!graph.isEmpty());
graph.removeNode('ddd');
assert.deepEqual(graph.lookup('ddd'), null);
assert.ok(graph.isEmpty());
});
test('root', () => {
graph.insertEdge('1', '2');
let roots = graph.roots();
assert.equal(roots.length, 1);
assert.equal(roots[0].data, '2');
graph.insertEdge('2', '1');
roots = graph.roots();
assert.equal(roots.length, 0);
});
test('root complex', function () {
graph.insertEdge('1', '2');
graph.insertEdge('1', '3');
graph.insertEdge('3', '4');
let roots = graph.roots();
assert.equal(roots.length, 2);
assert(['2', '4'].every(n => roots.some(node => node.data === n)));
});
});
开发者ID:PKRoma,项目名称:vscode,代码行数:48,代码来源:graph.test.ts
示例2: function
test('root complex', function () {
graph.insertEdge('1', '2');
graph.insertEdge('1', '3');
graph.insertEdge('3', '4');
let roots = graph.roots();
assert.equal(roots.length, 2);
assert(['2', '4'].every(n => roots.some(node => node.data === n)));
});
开发者ID:PKRoma,项目名称:vscode,代码行数:9,代码来源:graph.test.ts
示例3:
test('root', () => {
graph.insertEdge('1', '2');
let roots = graph.roots();
assert.equal(roots.length, 1);
assert.equal(roots[0].data, '2');
graph.insertEdge('2', '1');
roots = graph.roots();
assert.equal(roots.length, 0);
});
开发者ID:PKRoma,项目名称:vscode,代码行数:10,代码来源:graph.test.ts
注:本文中的vs/platform/instantiation/common/graph.Graph类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论