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


TypeScript Graph.outEdges方法代码示例

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


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

示例1: removeFromGraph

  private removeFromGraph(relativePath) {
    let normalizedPath = this.pathByNamespace(relativePath);
    let id = normalizedPath.id;

    let inEdges = this.graph.inEdges(id) || []
    let inVertices = inEdges.map(edge => edge.v);
    let outEdges = this.graph.outEdges(id) || [];
    let outVertices = outEdges.map(edge => edge.w) || [];

    if (inVertices.length === 0) {
      this.graph.removeNode(id);
      outVertices.forEach(node => {
        if (this.graph.node(node)) {
          this.removeFromGraph(this.graph.node(node).relativePath);
        }
      });
    }
  }
开发者ID:chadhietala,项目名称:fs-graph-diff,代码行数:18,代码来源:index.ts

示例2: if

    return patchImports.map(patch => {
      let operation = patch[0];
      let importPath = patch[1];
      if (this.graph.node(importPath)) {
        if (operation === 'connect') {
          this.graph.setEdge(relativePath, importPath);

          let inEdges = this.graph.outEdges(importPath);
          let inEdgePaths = inEdges.map(edge => this.graph.node(edge.v).inputPath);

          return [inputPath, ...inEdgePaths];
        } else if (operation === 'disconnect') {
          this.graph.removeEdge(normalizedPath.id, importPath);

          let inEdges = this.graph.inEdges(importPath);

          return null;
        }
      }
      // TODO we need to handle things coming out of node_modules
    }).filter(Boolean);
开发者ID:chadhietala,项目名称:fs-graph-diff,代码行数:21,代码来源:index.ts


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