Пример #1
0
 public Edge(string label, int localId, IVertex inVertex, IVertex outVertex, IEdgeProperties properties)
 {
     Label          = label;
     ID             = localId;
     InVertex       = inVertex.ID;
     InVertexLabel  = inVertex.Label;
     OutVertex      = outVertex.ID;
     OutVertexLabel = outVertex.Label;
     Properties     = properties;
 }
Пример #2
0
        /// <summary>
        /// Creates a directed Edge and saves to DB
        /// </summary>
        /// <param name="label">Label of created edge</param>
        /// <param name="InVertex">Ingoing vertex to connect</param>
        /// <param name="OutVertex">Outgoing vertex to connect</param>
        /// <param name="Properties">Properties of created edge</param>
        /// <returns>Created IEdge</returns>
        public IEdge AddDirectedEdge(string label, IVertex OutVertex, IVertex InVertex, IEdgeProperties Properties = null)
        {
            IEdge           tmpEdge          = new OrientEdge();
            IVertex         orientOutVertex  = OutVertex;
            IVertex         orientInVertex   = InVertex;
            IEdgeProperties orientProperties = Properties;

            tmpEdge.Label = label;
            tmpEdge.ID    = localId.ToString();
            localId++;
            tmpEdge.InVertexLabel  = InVertex.Label;
            tmpEdge.OutVertexLabel = OutVertex.Label;
            tmpEdge.Properties     = orientProperties;
            tmpEdge.InVertex       = orientInVertex.ID;
            tmpEdge.OutVertex      = orientOutVertex.ID;

            try
            {
                IEdge createdEdge = Gremlin.CreateEdge(tmpEdge.OutVertex.ToString(), tmpEdge.InVertex.ToString(), label);
                logger.Info("Edge " + createdEdge.ID + "has been created.");
                tmpEdge = createdEdge;
            }
            catch (WebSocketException we)
            {
                logger.Error("Can not connect to Server. " + we);
                throw;
            }
            catch (JsonReaderException jre)
            {
                logger.Error("Can not read JSON. " + jre.Data + jre.StackTrace);
                throw;
            }
            catch (Exception e)
            {
                logger.Error("Unhandled Exception occured: " + e);
                throw;
            }
            return(tmpEdge);
        }
Пример #3
0
        /// <summary>
        /// Creates a bidirected Edge and saves to DB
        /// </summary>
        /// <param name="label">Label of created edge</param>
        /// <param name="vertex1">A vertex to connect</param>
        /// <param name="vertex2">Another vertex to connect</param>
        /// <param name="Properties">Properties of created edge</param>
        /// <returns>Created bidirected edge as List of IEdge</returns>
        public List <IEdge> AddBiDirectedEdge(string label, IVertex vertex1, IVertex vertex2, IEdgeProperties Properties = null)
        {
            List <IEdge> biDirectedEdges = new List <IEdge>();

            biDirectedEdges.Add(AddDirectedEdge(label, vertex1, vertex2, Properties));
            biDirectedEdges.Add(AddDirectedEdge(label, vertex2, vertex1, Properties));
            return(biDirectedEdges);
        }
Пример #4
0
 /// <summary>
 /// Creates a directed Edge and saves to DB
 /// </summary>
 /// <param name="label">Label of created edge</param>
 /// <param name="InVertex">Ingoing vertex to connect</param>
 /// <param name="OutVertex">Outgoing vertex to connect</param>
 /// <param name="Properties">Properties of created edge</param>
 /// <returns>Created IEdge</returns>
 public IEdge AddDirectedEdge(string label, IVertex OutVertex, IVertex InVertex, IEdgeProperties Properties = null)
 {
     ++localId;
     try
     {
         IEdge edge = GremlinClient.CreateEdge(OutVertex.ID, InVertex.ID, label, (Dictionary <string, object>)Properties);
         logger.Debug("Edge " + edge.Label + " has been created.");
         return(edge);
     }
     catch (WebSocketException we)
     {
         logger.Error("Can not connect to Server. " + we);
         throw;
     }
     catch (JsonReaderException jre)
     {
         logger.Error("Can not read JSON. " + jre.Data + jre.StackTrace);
         throw;
     }
     catch (Exception e)
     {
         logger.Error("Unhandled Exception occured. " + e);
         throw;
     }
 }