static findConnectedEdgesForNodes()

in src/utilities/graph-util.js [213:244]


  static findConnectedEdgesForNodes(
    nodes: Map<string, INode>,
    edgesMap: any,
    nodeKey: string
  ): Map<string, IEdge> {
    const foundEdgesMap = new Map();

    for (const nodeA of nodes) {
      for (const nodeB of nodes) {
        // nodeA and nodeB are map arrays: ["key", node]
        // Find edges where A is connected to B or B is connected to A
        const edgeAB = edgesMap[`${nodeA[1][nodeKey]}_${nodeB[1][nodeKey]}`];
        const edgeBA = edgesMap[`${nodeB[1][nodeKey]}_${nodeA[1][nodeKey]}`];

        if (edgeAB != null) {
          foundEdgesMap.set(
            `${edgeAB.edge.source}_${edgeAB.edge.target}`,
            edgeAB.edge
          );
        }

        if (edgeBA != null) {
          foundEdgesMap.set(
            `${edgeBA.edge.source}_${edgeBA.edge.target}`,
            edgeBA.edge
          );
        }
      }
    }

    return foundEdgesMap;
  }