當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。