当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Graph.setNode方法代码示例

本文整理汇总了TypeScript中graphlib.Graph.setNode方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Graph.setNode方法的具体用法?TypeScript Graph.setNode怎么用?TypeScript Graph.setNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在graphlib.Graph的用法示例。


在下文中一共展示了Graph.setNode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: generateOrder

export function generateOrder(proj: project.Project) {
	const inputGraph = new Graph<FileInput, {}>({ directed: true });

	for (const file of proj.files) {
		inputGraph.setNode(file.filename, {
			file,
			groupName: undefined
		});
	}

	for (const file of proj.files) {
		for (const dependency of file.dependencies) {
			inputGraph.setEdge(file.filename, dependency.filename);
		}
	}

	const acyclicGraph = new Graph<FileGroup, {}>({ directed: true });

	for (const group of alg.tarjan(inputGraph)) {
		acyclicGraph.setNode(group[0], {
			filenames: group
		});

		for (const member of group) {
			inputGraph.node(member).groupName = group[0];
		}
	}

	for (const filename of inputGraph.nodes()) {
		const groupName = inputGraph.node(filename).groupName;
		for (const edge of inputGraph.inEdges(filename)) {
			const otherGroup = inputGraph.node(edge.w).groupName;
			if (groupName !== otherGroup) acyclicGraph.setEdge(groupName, otherGroup);
		}
	}

	const order = alg.topsort(acyclicGraph);
	let index = 0;

	for (const groupName of order) {
		const group = acyclicGraph.node(groupName);
		const component: file.SourceFile[] = [];
		const cyclic = group.filenames.length !== 1;
		for (const filename of group.filenames) {
			const file = inputGraph.node(filename).file;
			if (cyclic) {
				file.hasCircularDependencies = true;
				file.connectedComponent = component;
				component.push(file);
			} else {
				file.hasCircularDependencies = false;
			}
			file.orderIndex = index++;
			proj.orderFiles.push(file);
		}
	}
}
开发者ID:daslicht,项目名称:small,代码行数:57,代码来源:order.ts

示例2: addToGraph

  private addToGraph(relativePath, inputPath) {
    let normalizedPath = this.pathByNamespace(relativePath);

    if (this.graph.node(normalizedPath.id)) return;

    let mod = new Module({
      id: normalizedPath.id,
      namespace: normalizedPath.namespace,
      relativePath,
      inputPath
    });

    this.graph.setNode(mod.id, mod);

    mod.imports.forEach(dep => {
      this.graph.setEdge(mod.id, dep);
      let normalizedPath = this.pathByNamespace(relativePath);

      if (normalizedPath.namespace === this.namespace) {
        let inputPath = `${this.srcDir}/${relativePath}.ts`;
        let outputPath = `${this.destDir}/${relativePath}.ts`;
        this.addToGraph(relativePath, inputPath);
      } else {
        console.log('EXTERNAL: ' + normalizedPath.path);
      }
    });
  }
开发者ID:chadhietala,项目名称:fs-graph-diff,代码行数:27,代码来源:index.ts

示例3:

 jobs.forEach((job : model.BuildSchema) => {
     graph.setNode(job._id, job);
 });
开发者ID:mserranom,项目名称:lean-ci,代码行数:3,代码来源:PipelineGraph.ts


注:本文中的graphlib.Graph.setNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。