Adds an edge to the model.
</p>
If either the source or target vertex of the edge is not in the model,
they will be automatically added as well.
</p>

@param edge The edge to be added.
@return The model.
761259
public Model addEdge(Edge edge) {
    edges.add(edge);
    if (isNotNull(edge.getSourceVertex()) && !vertices.contains(edge.getSourceVertex())) {
      vertices.add(edge.getSourceVertex());
    }
    if (isNotNull(edge.getTargetVertex()) && !vertices.contains(edge.getTargetVertex())) {
      vertices.add(edge.getTargetVertex());
    }
    return this;
  }
1355679
def add_edge (u, v)
      add_vertex(u)                         # ensure key
      add_vertex(v)                         # ensure key
      basic_add_edge(u, v)
    end
814905
public static Titan0Edge createEdge(Titan0Graph graph, Edge source) {

        if (source == null) {
            return null;
        }
        return new Titan0Edge(graph, source);
    }
775648
def add_edge(self, fr, to):
        
        if fr not in set(self.graph.vs):  # ToDo: find out why item can be in set but not dict
            raise ValueError('can not connect unknown vertices in n-partite graphs, {!r} missing'.format(fr))
        elif to not in set(self.graph.vs):
            raise ValueError('can not connect unknown vertices in n-partite graphs, {!r} missing'.format(to))
        self.graph.add_edge(fr, to)
1151250
public boolean add(Edge e) {
        int toAdd = -1;
        if (e.from() == rootVertex) 
            toAdd = e.to();        
        else if (e.to() == rootVertex)
            toAdd = e.from();
        else
            return false;
        boolean b = edges.add(toAdd);
        return b;
    }
377601
public <K> Graph<K, NullValue, NullValue> keyType(Class<K> vertexKey) {

		if (edgeReader == null) {
			throw new RuntimeException("The edge input file cannot be null!");
		}

		DataSet<Edge<K, NullValue>> edges = edgeReader
			.types(vertexKey, vertexKey)
				.name(GraphCsvReader.class.getName())
			.map(new Tuple2ToEdgeMap<>())
				.name("Type conversion");

		return Graph.fromDataSet(edges, executionContext);
	}
631290
public void setEdges(java.util.Collection<Edge> edges) {
        if (edges == null) {
            this.edges = null;
            return;
        }

        this.edges = new java.util.ArrayList<Edge>(edges);
    }
668827
@Override
    public void removeEdge(Edge edge) {
        super.removeEdge(edge);

        // Keep track of removed edges.
        if (removedEdgeList == null) {
            removedEdgeList = new LinkedList<>();
        }
        removedEdgeList.add(edge);
    }
1205090
public void addEdges(Collection<EdgeIteratorState> edges) {
        for (EdgeIteratorState edge : edges) {
            visitedEdges.add(edge.getEdge());
        }
    }
576785
def insert_into_graph(self, graph):
        
        u = self.source.as_bel()
        v = self.target.as_bel()

        if self.evidence:
            return graph.add_qualified_edge(u, v, **json.loads(self.data))
        else:
            return graph.add_unqualified_edge(u, v, self.relation)
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
427103
public BasicBlock getPredecessorWithEdgeType(BasicBlock target, @Type int edgeType) {
        Edge edge = getIncomingEdgeWithType(target, edgeType);
        return edge != null ? edge.getSource() : null;
    }
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)
693760
public static Titan1Edge createEdge(Titan1Graph graph, Edge source) {

        if (source == null) {
            return null;
        }
        return new Titan1Edge(graph, source);
    }
603385
def add_outward_edge(self, v, e):
        
        self.add_vertex(v)
        self.graph.add_vertex(e)
        self.es.add(e)
        self.graph.add_edge(e, v)
1280327
def add_edge(self, u, v, **attr):
        
        if u not in self.vertices:
            self.vertices[u] = []
        if v not in self.vertices:
            self.vertices[v] = []
        vertex = (u, v)
        self.edges[vertex] = {}
        if attr:
            self.edges[vertex].update(attr)
        self.vertices[u].append(v)
        self.vertices[v].append(u)
1140332
def add_neighbor(self, edge: "Edge") -> None:
        
        if edge is None or (edge.source != self and edge.target != self):
            return

        if edge.source == self:
            other: Node = edge.target
        elif edge.target == self:
            other: Node = edge.source
        else:
            raise ValueError("Tried to add a neighbor with an invalid edge.")

        edge_key: Tuple(int, int) = edge.key

        # The graph is considered undirected, check neighbor existence accordingly.
        if self._neighbors.get(edge_key) or self._neighbors.get((edge_key[1], edge_key[0])):
            return  # The neighbor is already added.

        self._neighbors[edge_key] = edge
        self.dispatch_event(NeighborAddedEvent(other))