Find next vertex and cut edge
324970
function next(a, b, noCut) {
    var nextCell, nextVertex, nextDir
    for(var i=0; i<2; ++i) {
      if(adj[i][b].length > 0) {
        nextCell = adj[i][b][0]
        nextDir = i
        break
      }
    }
    nextVertex = nextCell[nextDir^1]

    for(var dir=0; dir<2; ++dir) {
      var nbhd = adj[dir][b]
      for(var k=0; k<nbhd.length; ++k) {
        var e = nbhd[k]
        var p = e[dir^1]
        var cmp = compareAngle(
            positions[a], 
            positions[b], 
            positions[nextVertex],
            positions[p])
        if(cmp > 0) {
          nextCell = e
          nextVertex = p
          nextDir = dir
        }
      }
    }
    if(noCut) {
      return nextVertex
    }
    if(nextCell) {
      cut(nextCell, nextDir)
    }
    return nextVertex
  }
1285322
def pick_next_boat_trip(node, m, c, frontier):
    
    next_path = []
    cur_path = []
    boat, mult = boat_on_left_bank(node)
    shore = 1 - boat
    m1, c1, m2, c2 = parse_miss_cann(node, m, c)
    if (m1 - 1 >= c1 or m1 == 1) and (m2 + 1 >= c2) and (m1 > 0):
        cur_path = (node[0]-mult,node[1], shore)
        if cur_path not in frontier:
            next_path.append(cur_path)

    if (m1 >= c1-1 or m1 == 0) and (m2 -1 >= c2 or m2 == 0) and ( c1 > 0):
        cur_path = (node[0],node[1]-mult, shore)
        if cur_path not in frontier:
            next_path.append(cur_path)
        
    if (m1 >= c1) and (m2 >= c2) and (m1 > 0) and (c1 > 0):
        cur_path = (node[0]-mult,node[1]-mult, shore)
        if cur_path not in frontier:
            next_path.append(cur_path)
        
    if (m1 - 2 >= c1 or m1 == 2) and (m2 >= c2 or m2 == 0) and (m1 > 1):
        cur_path = (node[0]-(mult*2),node[1], shore)
        if cur_path not in frontier:
            next_path.append(cur_path)
        
    if (m1 >= c1 - 2 or m1 == 0) and (m2 >= c2 + 2 or m2 == 0) and (c1 > 1):
        cur_path = (node[0],node[1]-(mult*2), shore)
        if cur_path not in frontier:
            next_path.append(cur_path)

    #print(next_path)    
    return next_path
1338934
def del_edge(self, u_vertex, v_vertex):
        
        if self.is_edge(u_vertex, v_vertex):
            self.indegrees[v_vertex] -= 1
            self.adj_dict[u_vertex].remove(v_vertex)
            return True

        return False
470868
def next(self):
        
        x, y = next(self.scan)
        xs = int(round(x))
        ys = int(round(y))
        return xs, ys
417289
def add_edge(self, u, v, **attr):
        
        if u not in self.vertices:
            self.vertices[u] = []
            self.pred[u] = []
            self.succ[u] = []
        if v not in self.vertices:
            self.vertices[v] = []
            self.pred[v] = []
            self.succ[v] = []
        vertex = (u, v)
        self.edges[vertex] = {}
        self.edges[vertex].update(attr)
        self.vertices[u].append(v)
        self.pred[v].append(u)
        self.succ[u].append(v)
1122939
private void advance() {
        // If we don't have any simple graphs to return, and there are still
        // more subgraphs, then pick off the next subgraph and decompose it
        if (next.isEmpty() && subgraphIterator.hasNext()) {
            Multigraph<T,E> g = subgraphIterator.next();

            // Find all pairs of edges, checking whether the graph is a simple
            // graph already
            boolean isSimpleAlready = true;
            List<IntPair> connected = new ArrayList<IntPair>();
            for (int i : g.vertices()) {
                for (int j : g.vertices()) {
                    if (i == j)
                        break;
                    Set<E> edges = null;
                    try {
                        edges = g.getEdges(i, j);
                    } catch (NullPointerException npe) {
                        System.out.println("Bad graph? : " + g);
                        throw npe;
                    }
                    int size = edges.size();
                    if (size > 0)
                        connected.add(new IntPair(i, j));
                    if (size > 1)
                        isSimpleAlready = false;
                }
            }
            // If the subgraph was already a simple graph, then just append it
            // to the list
            if (isSimpleAlready) {
                // System.out.println("next graph was already simple: " + g);
                next.add(g);
            }
            // Otherwise, generate a recursive call to enumerate all the
            // simple graphs from this graph
            else {
                // Create an empty graph which will be populated with a new edge
                // and then copied 
                Multigraph<T,E> m = g.copy(Collections.<Integer>emptySet()); //Graphs.asMultigraph(new GenericGraph<E>());
                next.addAll(enumerateSimpleGraphs(g, connected, 0, m));
            }
        }
    }
92612
private EdgeSet<T> addIfAbsent(int v) {
        S edges = getEdgeSet(v);
        if (edges == null) {
            edges = createEdgeSet(v);
            vertexToEdges.put(v, edges);
        }
        return edges;
    }
589807
def connect_to(self, vertex, weight=1):
        
        for edge in self.edges_out:
            if vertex == edge.vertex_in:
                return edge
        return Edge(self, vertex, weight)
1318353
private void cut(Node<K, V> x, Node<K, V> y) {
        // remove x from child list of y
        x.prev.next = x.next;
        x.next.prev = x.prev;
        y.degree--;
        if (y.degree == 0) {
            y.child = null;
        } else if (y.child == x) {
            y.child = x.next;
        }

        // add x to the root list
        x.parent = null;
        addToRootList(x);

        // clear if marked
        x.mark = false;
    }
772618
function( count ){
            var num = this.vertices.length,
                longestID = 0,
                maxD = 0,
                i = 0,
                d,
                m;

            while( num < count ){
                //find longest edge
                longestID = 0;
                maxD = 0;
                for( i=0; i<num; i++ ){
                    d = this.vertices[i].distanceToSquared( this.vertices[ (i+1) % num ] );
                    if( d > maxD ){
                        longestID = i;
                        maxD = d;
                    }
                }
                //insert mid point of longest segment
                m = this.vertices[longestID]
                    .add(this.vertices[(longestID + 1) % num])
                    .scaleSelf(0.5);
                //push this into the array inbetween the 2 points
                this.vertices.splice( longestID+1, 0, m );
                num++;
            }
            return this;
        }
327890
def get_part(self, vertex_in, vertices_border):
        
        vertices_new = set(self.neighbors[vertex_in])
        vertices_part = set([vertex_in])

        while len(vertices_new) > 0:
            pivot = vertices_new.pop()
            if pivot in vertices_border:
                continue
            vertices_part.add(pivot)
            pivot_neighbors = set(self.neighbors[pivot])
            pivot_neighbors -= vertices_part
            vertices_new |= pivot_neighbors

        return vertices_part
83718
def vertices_per_edge(self):
        """"""
        import numpy as np
        return np.asarray([vertices_in_common(e[0], e[1]) for e in self.f[self.faces_per_edge]])
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;
        });
    });
}
882253
function (vertices, color, c)
    {
        _c = c || _c
        if (color)
        {
            _c.fillStyle = color
        }
        const edges = [], active = []
        let minY = Infinity, maxY = 0

        // create edges
        for (let i = 0; i < vertices.length; i += 2)
        {
            const p1 = { x: vertices[i] * _scale, y: vertices[i + 1] * _scale }
            const p2 = { x: vertices[mod(i + 2, vertices.length)] * _scale, y: vertices[mod(i + 3, vertices.length)] * _scale }
            if (p1.y - p2.y !== 0)
            {
                const edge = {}
                edge.p1 = p1
                edge.p2 = p2
                if (p1.y < p2.y)
                {
                    edge.minY = p1.y
                    edge.minX = p1.x
                }
                else
                {
                    edge.minY = p2.y
                    edge.minX = p2.x
                }
                minY = (edge.minY < minY) ? edge.minY : minY
                edge.maxY = Math.max(p1.y, p2.y)
                maxY = (edge.maxY > maxY) ? edge.maxY : maxY
                if (p1.x - p2.x === 0)
                {
                    edge.slope = Infinity
                    edge.b = p1.x
                }
                else
                {
                    edge.slope = (p1.y - p2.y) / (p1.x - p2.x)
                    edge.b = p1.y - edge.slope * p1.x
                }
                edges.push(edge)
            }
        }
        edges.sort((a, b) => { return a.minY - b.minY })
        for (let y = minY; y <= maxY; y++)
        {
            for (let i = 0; i < edges.length; i++)
            {
                const edge = edges[i]
                if (edge.minY === y)
                {
                    active.push(edge)
                    edges.splice(i, 1)
                    i--
                }
            }
            for (let i = 0; i < active.length; i++)
            {
                const edge = active[i]
                if (edge.maxY < y)
                {
                    active.splice(i, 1)
                    i--
                }
                else
                {
                    if (edge.slope !== Infinity)
                    {
                        edge.x = Math.round((y - edge.b) / edge.slope)
                    }
                    else
                    {
                        edge.x = edge.b
                    }
                }
            }
            active.sort((a, b) => { return a.x - b.x === 0 ? b.maxY - a.maxY : a.x - b.x })
            let bit = true, current = 1
            for (let x = active[0].x; x <= active[active.length - 1].x; x++)
            {
                if (bit)
                {
                    put(x, y)
                }
                if (active[current].x === x)
                {
                    if (active[current].maxY !== y)
                    {
                        bit = !bit
                    }
                    current++
                }
            }
        }
    }
567354
function clipSegmentToLine(vOut, vIn, normal, offset, vertexIndexA) {
  // Start with no output points
  var numOut = 0;

  // Calculate the distance of end points to the line
  var distance0 = Vec2.dot(normal, vIn[0].v) - offset;
  var distance1 = Vec2.dot(normal, vIn[1].v) - offset;

  // If the points are behind the plane
  if (distance0 <= 0.0)
    vOut[numOut++].set(vIn[0]);
  if (distance1 <= 0.0)
    vOut[numOut++].set(vIn[1]);

  // If the points are on different sides of the plane
  if (distance0 * distance1 < 0.0) {
    // Find intersection point of edge and plane
    var interp = distance0 / (distance0 - distance1);
    vOut[numOut].v.setCombine(1 - interp, vIn[0].v, interp, vIn[1].v);

    // VertexA is hitting edgeB.
    vOut[numOut].id.cf.indexA = vertexIndexA;
    vOut[numOut].id.cf.indexB = vIn[0].id.cf.indexB;
    vOut[numOut].id.cf.typeA = Manifold.e_vertex;
    vOut[numOut].id.cf.typeB = Manifold.e_face;
    ++numOut;
  }

  return numOut;
}
483584
function removeEdge(vertex, edge) {
  var adj = vertex.adjacent
  var idx = elist.index(adj, edge)
  adj.splice(idx, 1)
  //Check if flag needs to be updated
  if(!((idx < adj.length && adj[idx].level === edge.level) ||
       (idx > 0 && adj[idx-1].level === edge.level))) {
    vertex.euler[edge.level].setFlag(false)
  }
}
1067388
int removeVertex(int vertex, boolean b_left_segment) {
		int path = getPathFromVertex(vertex);
		int prev = getPrevVertex(vertex);
		int next = getNextVertex(vertex);
		if (prev != -1)
			setNextVertex_(prev, next);

		int path_size = getPathSize(path);

		if (vertex == getFirstVertex(path)) {
			setFirstVertex_(path, path_size > 1 ? next : -1);
		}

		if (next != -1)
			setPrevVertex_(next, prev);

		if (vertex == getLastVertex(path)) {
			setLastVertex_(path, path_size > 1 ? prev : -1);
		}

		if (prev != -1 && next != -1) {
			int vindex_prev = getVertexIndex(prev);
			int vindex_next = getVertexIndex(next);
			if (b_left_segment) {
				Segment seg = getSegmentFromIndex_(vindex_prev);
				if (seg != null) {
					Point2D pt = new Point2D();
					m_vertices.getXY(vindex_next, pt);
					seg.setEndXY(pt);
				}
			} else {
				int vindex_erased = getVertexIndex(vertex);
				Segment seg = getSegmentFromIndex_(vindex_erased);
				setSegmentToIndex_(vindex_prev, seg);
				if (seg != null) {
					Point2D pt = m_vertices.getXY(vindex_prev);
					seg.setStartXY(pt);
				}
			}
		}

		setPathSize_(path, path_size - 1);
		int geometry = getGeometryFromPath(path);
		setGeometryVertexCount_(geometry, getPointCount(geometry) - 1);
		freeVertex_(vertex);
		return next;
	}