Exemplo n.º 1
0
        /// <note>
        ///     Raises an edgeAdded event.
        /// </note>
        public IEdge AddEdge(object id, IVertex outVertex, IVertex inVertex, string label)
        {
            GraphContract.ValidateAddEdge(id, outVertex, inVertex, label);
            var outVertexToSet = outVertex;

            if (outVertex is EventVertex)
            {
                outVertexToSet = (outVertex as EventVertex).Vertex;
            }

            var inVertexToSet = inVertex;

            if (inVertex is EventVertex)
            {
                inVertexToSet = (inVertex as EventVertex).Vertex;
            }

            if (inVertexToSet == null || outVertexToSet == null)
            {
                throw new InvalidOperationException();
            }
            var edge = BaseGraph.AddEdge(id, outVertexToSet, inVertexToSet, label);

            OnEdgeAdded(edge);
            return(new EventEdge(edge, this));
        }
Exemplo n.º 2
0
        public IEdge AddEdge(object id, IVertex outVertex, IVertex inVertex, string label)
        {
            GraphContract.ValidateAddEdge(id, outVertex, inVertex, label);
            if (_uniqueIds && null != id && null != GetEdge(id))
            {
                throw new ArgumentException(string.Concat("edge with given id already exists: ", id));
            }

            VerifyNativeElement(outVertex);
            VerifyNativeElement(inVertex);

            var base_ = _baseGraph.AddEdge(id, ((IdVertex)outVertex).GetBaseVertex(),
                                           ((IdVertex)inVertex).GetBaseVertex(), label);

            if (_supportEdgeIds)
            {
                var v = id ?? _edgeIdFactory.CreateId();

                if (null != v)
                {
                    base_.SetProperty(Id, v);
                }
            }

            return(new IdEdge(base_, this));
        }
Exemplo n.º 3
0
        public IEdge AddEdge(object id, IVertex outVertex, IVertex inVertex, string label)
        {
            GraphContract.ValidateAddEdge(id, outVertex, inVertex, label);

            if (!(outVertex is BatchVertex) || !(inVertex is BatchVertex))
            {
                throw new ArgumentException("Given element was not created in this baseGraph");
            }
            NextElement();

            var ov = GetCachedVertex(outVertex.Id);
            var iv = GetCachedVertex(inVertex.Id);

            _previousOutVertexId = outVertex.Id; //keep track of the previous out vertex id

            if (ov != null && iv != null)
            {
                _currentEdgeCached = _baseGraph.AddEdge(id, ov, iv, label);
                if (_edgeIdKey != null && id != null)
                {
                    _currentEdgeCached.SetProperty(_edgeIdKey, id);
                }
            }

            _currentEdge = new BatchEdge(this);
            return(_currentEdge);
        }
Exemplo n.º 4
0
        public IEdge AddEdge(object id, IVertex outVertex, IVertex inVertex, string label)
        {
            GraphContract.ValidateAddEdge(id, outVertex, inVertex, label);

            var edge = new PartitionEdge(BaseGraph.AddEdge(id,
                                                           ((PartitionVertex)outVertex).Vertex,
                                                           ((PartitionVertex)inVertex).Vertex,
                                                           label),
                                         this);

            edge.SetPartition(_writePartition);
            return(edge);
        }
Exemplo n.º 5
0
        public virtual IEdge AddEdge(object id, IVertex outVertex, IVertex inVertex, string label)
        {
            GraphContract.ValidateAddEdge(id, outVertex, inVertex, label);

            string idString = null;
            IEdge  edge;

            if (null != id)
            {
                idString = id.ToString();
                edge     = Edges.Get(idString);
                if (null != edge)
                {
                    throw ExceptionFactory.EdgeWithIdAlreadyExist(id);
                }
            }
            else
            {
                var done = false;
                while (!done)
                {
                    idString = GetNextId();
                    edge     = Edges.Get(idString);
                    if (null == edge)
                    {
                        done = true;
                    }
                }
            }

            edge = new TinkerEdge(idString, outVertex, inVertex, label, this);
            Edges.Put(edge.Id.ToString(), edge);
            var out_ = (TinkerVertex)outVertex;
            var in_  = (TinkerVertex)inVertex;

            out_.AddOutEdge(label, edge);
            in_.AddInEdge(label, edge);
            return(edge);
        }
Exemplo n.º 6
0
        public IEdge AddEdge(object id, IVertex outVertex, IVertex inVertex, string label)
        {
            GraphContract.ValidateAddEdge(id, outVertex, inVertex, label);

            return(_graph.AddEdge(id, outVertex, inVertex, label));
        }