Divide the edges into groups
327569
def _iter_candidate_groups(self, init_match, edges0, edges1):
        """"""
        # collect all end vertices0 and end vertices1 that belong to the same
        # group.
        sources = {}
        for start_vertex0, end_vertex0 in edges0:
            l = sources.setdefault(start_vertex0, [])
            l.append(end_vertex0)
        dests = {}
        for start_vertex1, end_vertex1 in edges1:
            start_vertex0 = init_match.reverse[start_vertex1]
            l = dests.setdefault(start_vertex0, [])
            l.append(end_vertex1)
        for start_vertex0, end_vertices0 in sources.items():
            end_vertices1 = dests.get(start_vertex0, [])
            yield end_vertices0, end_vertices1
1265479
def initial_edges(self) -> iter:
        """"""
        nodes_in = lambda n: ([n] if self.is_node(n) else self.nodes_in(n))
        for node, succs in self.edges.items():
            twos = tuple(two for succ in succs for two in nodes_in(succ))
            for one in nodes_in(node):
                for two in twos:
                    yield one, two
1206794
def _group(self, rdd):
        """"""
        return rdd.reduceByKey(lambda x, y: x.append(y))
25356
def edges
      vertices.map { |vert| vert.successors.map { |succ| [vert, succ] }}.flatten 1
    end
1249173
def paths2edges(paths):
    
    edges_all = set()
    for path in paths:
        for edge in path2edges(path):
            edges_all.add(edge)
    return edges_all
916274
function computeEdgeDepths(nodes, orient) {
    var keyAttr = orient === 'vertical' ? 'x' : 'y';
    zrUtil.each(nodes, function (node) {
        node.outEdges.sort(function (a, b) {
            return a.node2.getLayout()[keyAttr] - b.node2.getLayout()[keyAttr];
        });
        node.inEdges.sort(function (a, b) {
            return a.node1.getLayout()[keyAttr] - b.node1.getLayout()[keyAttr];
        });
    });
    zrUtil.each(nodes, function (node) {
        var sy = 0;
        var ty = 0;
        zrUtil.each(node.outEdges, function (edge) {
            edge.setLayout({sy: sy}, true);
            sy += edge.getLayout().dy;
        });
        zrUtil.each(node.inEdges, function (edge) {
            edge.setLayout({ty: ty}, true);
            ty += edge.getLayout().dy;
        });
    });
}
920978
private static IBond[] neighbors(int v, int[][] g, EdgeToBondMap bondMap) {
        int[]   ws    = g[v];
        IBond[] bonds = new IBond[ws.length];
        for (int i = 0; i < ws.length; i++) {
            bonds[i] = bondMap.get(v, ws[i]);
        }
        return bonds;
    }
123126
def _to_edges(self, tokens):
        """"""
        # prepend self.order Nones
        chain = self._end_context + tokens + self._end_context

        has_space = False

        context = []

        for i in xrange(len(chain)):
            context.append(chain[i])

            if len(context) == self.order:
                if chain[i] == self.SPACE_TOKEN_ID:
                    context.pop()
                    has_space = True
                    continue

                yield tuple(context), has_space

                context.pop(0)
                has_space = False
144871
def get_edges(self):
        """"""
        edge_from_to = []
        for parent, children in self.p_from_cs.items():
            for child in children:
                edge_from_to.append((child, parent))
        for parent, children in self.c_from_ps.items():
            for child in children:
                edge_from_to.append((child, parent))
        return edge_from_to
1010028
def edges(&block)
      return to_enum(__callee__) unless block_given?

      children do |v|
        yield self, v
        v.edges(&block)
      end
    end
1097700
function wrapPartsIntoGroups(parts, indexes) {
  if (indexes.length === 0) {
    return parts;
  }

  let lastEnd = 0;

  return indexes.reduce((accumulator, index) => {
    const { start, end, alignment, before, after } = index;
    const printedPartsForGrouping = concat([
      before || "",
      concat(parts.slice(start, end)),
      after || ""
    ]);
    const newArray = accumulator.concat(
      parts.slice(lastEnd, start),
      alignment
        ? dedentToRoot(
            group(
              concat([
                align(new Array(alignment).join(" "), printedPartsForGrouping)
              ])
            )
          )
        : group(printedPartsForGrouping),
      end === parts.length - 1 ? parts.slice(end) : ""
    );

    lastEnd = end;

    return newArray;
  }, []);
}
1293134
def _init_edges(p2cs, c2ps):
        """"""
        edge_from_to = []
        for parent, children in p2cs.items():
            for child in children:
                # if child in goids_present and parent in goids_present:
                edge_from_to.append((child, parent))
        for parent, children in c2ps.items():
            for child in children:
                # if child in goids_present and parent in goids_present:
                edge_from_to.append((child, parent))
        return edge_from_to
61979
def chk_edges(self):
        """"""
        goids = set(self.go2obj)
        self.chk_edges_nodes(self.edges, goids, "is_a")
        for reltype, edges in self.edges_rel.items():
            self.chk_edges_nodes(edges, goids, reltype)
790837
def del_edges(self, edges, *args, **kwargs):
        
        for edge in edges:
            self.del_edge(edge, *args, **kwargs)
1277535
def ungroupslice(groups,gslice):
  ''
  'coordinate transform: takes a match from seqingroups() and transforms to ungrouped coordinates'
  eltsbefore=0
  for i in range(gslice[0]): eltsbefore+=len(groups[i])-1
  x=eltsbefore+gslice[1]; return [x-1,x+gslice[2]-1]
357621
function makeAcyclic(g) {
    var onStack = {};
    var visited = {};

    function dfs(u) {
      if (u in visited) {
        return;
      }
      visited[u] = true;
      onStack[u] = true;
      g.successors(u).forEach(function(v) {
        if (v in onStack) {
          g.addEdge(v, u);
          g.removeEdge(u, v);
        } else {
          dfs(v);
        }
      });
      delete onStack[u];
    }

    g.nodes().forEach(function(u) {
      dfs(u);
    });
  }
883454
def chk_edges_nodes(edges, nodes, name):
        """"""
        edge_nodes = set(e for es in edges for e in es)
        missing_nodes = edge_nodes.difference(nodes)
        assert not missing_nodes, "MISSING: {GOs}\n{NM} EDGES MISSING {N} NODES (OF {T})".format(
            NM=name, N=len(missing_nodes), T=len(edge_nodes), GOs=missing_nodes)