Assigns a variable for each edge in G.
    (u, v) and (v, u) map to the same variable.
765231
def _edge_mapping(G):
    
    edge_mapping = {edge: idx for idx, edge in enumerate(G.edges)}
    edge_mapping.update({(e1, e0): idx for (e0, e1), idx in edge_mapping.items()})
    return edge_mapping
656942
def set_U1U2(self, U1, U2):
        
        if len(np.shape(U1)) == 0:
          U1 = U1 * np.ones((self.ny)) 
        if len(np.shape(U2)) == 0:
          U2 = U2 * np.ones((self.ny)) 
        #self.Ubg = np.array([U1,U2])[:,np.newaxis,np.newaxis]
        self.U1 = U1
        self.U2 = U2
        self.Ubg = np.array([U1,U2])
1366997
function _safeGetEdge(g, u, v) {
    var key = _edgeKey(u, v);
    if (!(key in g._edges)) {
      throw new Error("No such edge: (" + u + ", " + v + ")");
    }
    return g._edges[key];
  }
220108
def g(number_of_links, size_x, size_y)
      a = (size_x + size_y) ** p
      b = size_x ** p
      c = size_x ** p

      number_of_links / (a - b - c)
    end
1142680
def add_edge(self, u_vertex, v_vertex):
        
        self._vertices.add(u_vertex)
        self._vertices.add(v_vertex)
        if not self.is_edge(u_vertex, v_vertex):
            self.indegrees[v_vertex] += 1
            self.adj_dict[u_vertex].append(v_vertex)
            return True

        return False
792438
function init(g) {
    g.nodes().forEach(function(u) {
      var attrs = g.node(u);
      attrs.y = _rankSep * attrs.rank;
      if (attrs.width) {
        attrs.width = parseInt(attrs.width);
      } else {
        attrs.width = attrs.dummy ? _edgeWidth : _nodeWidth;
      }
    });
  }
32998
public void initialize(IGraph<V, E> graph) {
        int nVertices = graph.numVertices();
        int[] degrees = new int[nVertices];
        for (int i = 0; i < nVertices; i++)
            degrees[i] = graph.getVertexDegree(i);
        initialize(degrees);
    }
1337830
private void addEdge(int i, int j) {
		if(!nodes.contains(i)){
			nodes.add(i);
			edges.put(i, new HashSet<Integer>());
			size++;
		}else if(!edges.containsKey(i)){
			edges.put(i, new HashSet<Integer>());
		}

		if(!nodes.contains(j)){
			nodes.add(j);
			size++;
		}
		edgesInv.put(j, i);

		if(!edges.get(i).contains(j)){
			edges.get(i).add(j);
		}

	}
1042205
def _adjacency_to_edges(adjacency):
    """"""
    edges = set()
    for u in adjacency:
        for v in adjacency[u]:
            try:
                edge = (u, v) if u <= v else (v, u)
            except TypeError:
                # Py3 does not allow sorting of unlike types
                if (v, u) in edges:
                    continue
                edge = (u, v)

            edges.add(edge)
    return edges
335392
function EdgeShape(v1, v2) {
  if (!(this instanceof EdgeShape)) {
    return new EdgeShape(v1, v2);
  }

  EdgeShape._super.call(this);

  this.m_type = EdgeShape.TYPE;
  this.m_radius = Settings.polygonRadius;

  // These are the edge vertices
  this.m_vertex1 = v1 ? Vec2.clone(v1) : Vec2.zero();
  this.m_vertex2 = v2 ? Vec2.clone(v2) : Vec2.zero();

  // Optional adjacent vertices. These are used for smooth collision.
  // Used by chain shape.
  this.m_vertex0 = Vec2.zero();
  this.m_vertex3 = Vec2.zero();
  this.m_hasVertex0 = false;
  this.m_hasVertex3 = false;
}
230820
def setdummies(self,e):
        
        v0,v1 = e.v
        r0,r1 = self.grx[v0].rank,self.grx[v1].rank
        if r0>r1:
            assert e in self.alt_e
            v0,v1 = v1,v0
            r0,r1 = r1,r0
        if (r1-r0)>1:
            # "dummy vertices" are stored in the edge ctrl dict,
            # keyed by their rank in layers.
            ctrl=self.ctrls[e]={}
            ctrl[r0]=v0
            ctrl[r1]=v1
            for r in xrange(r0+1,r1):
                self.dummyctrl(r,ctrl)
539909
def add_edge(self, edge):
        
        u, v = edge

        both_exist = u in self.vertices and v in self.vertices
        # Using `is` because if they belong to the same component, they MUST
        # share the same set object!
        if both_exist and self.components[u] is self.components[v]:
            # Both vertices are part of the same connected component.
            raise InvariantError('Adding %r would form a cycle' % (edge,))
        if u == v:
            raise InvariantError('Cannot add loop: %r' % (edge,))

        # Ensure the vertices exist in the graph.
        self.add_vertex(u)
        self.add_vertex(v)

        # Add the edges to each other.
        self._vertices[u].add(v)
        self._vertices[v].add(u)

        # Add all of the smaller components to the bigger one.
        smaller_component, bigger_component = self.sort_components(u, v)
        for vertex in smaller_component:
            bigger_component.add(vertex)
            # And with this assignment, say bye-bye to the smaller component.
            self.components[vertex] = bigger_component
541102
def edges
	    points = self.vertices
	    points.each_cons(2).map {|p1,p2| Edge.new(p1,p2) } + [Edge.new(points.last, points.first)]
	end
697325
public Assignment mapVariables(Map<Integer, Integer> varMap) {
    int[] newVarNums = new int[vars.length];
    Object[] newValues = new Object[vars.length];

    int numFilled = 0;
    for (int i = 0; i < vars.length; i++) {
      if (varMap.containsKey(vars[i])) {
        newVarNums[numFilled] = varMap.get(vars[i]);
        newValues[numFilled] = values[i];
        numFilled++;
      }
    }
    
    if (numFilled < newVarNums.length) {
      newVarNums = Arrays.copyOf(newVarNums, numFilled);
      newValues = Arrays.copyOf(newValues, numFilled);
    }
    return Assignment.fromUnsortedArrays(newVarNums, newValues);
  }
92612
private EdgeSet<T> addIfAbsent(int v) {
        S edges = getEdgeSet(v);
        if (edges == null) {
            edges = createEdgeSet(v);
            vertexToEdges.put(v, edges);
        }
        return edges;
    }
690005
function addVertexEdgeMap(vertex, edge) {
		if (vertexEdgeMap[vertex]===undefined) {
			vertexEdgeMap[vertex] = [];
		}
		
		vertexEdgeMap[vertex].push(edge);
	}
384686
public Graph<K, VV, EV> union(Graph<K, VV, EV> graph) {
		DataSet<Vertex<K, VV>> unionedVertices = graph
			.getVertices()
			.union(this.getVertices())
				.name("Vertices")
			.distinct()
				.name("Vertices");

		DataSet<Edge<K, EV>> unionedEdges = graph
			.getEdges()
			.union(this.getEdges())
				.name("Edges");

		return new Graph<>(unionedVertices, unionedEdges, this.context);
	}