Пример #1
0
 /// <summary>
 /// numerates all elements satisfying the given condition for the given property and value range
 /// </summary>
 /// <param name="property">Property we are looking for</param>
 /// <param name="condition"> filter function, applied with in graph value as 1st parameter, lower as 2nd and higher as 3rd parameter.</param>
 /// <param name="lower">lower value in filtering</param>
 /// <param name="higher">higher value in filtering</param>
 /// <returns></returns>
 public IEnumerable <IElement> Select(PropertyType property, Func <IComparable, IComparable, IComparable, Boolean> condition, IComparable lower, IComparable higher)
 {
     if (property.IsVertexProperty)
     {
         VertexType vt = vertexType[property.TypeId];
         foreach (Vertex vertex in vt.GetVertices())
         {
             IComparable v = property.GetPropertyValue(vertex.VertexId);
             if (condition(v, lower, higher))
             {
                 yield return(vertex);
             }
         }
     }
     else
     {
         EdgeType et = edgeType[property.TypeId];
         foreach (Edge edge in et.GetEdges())
         {
             IComparable v = property.GetPropertyValue(edge.EdgeId);
             if (condition(v, lower, higher))
             {
                 yield return(edge);
             }
         }
     }
 }
Пример #2
0
 /// <summary>
 /// Removes a property type except if any vertex or edge is using it
 /// </summary>
 /// <param name="pt">property type to remove</param>
 public void RemovePropertyType(PropertyType pt)
 {
     if (pt.IsVertexProperty)
     {
         VertexType vt = vertexType[pt.TypeId];
         foreach (Vertex vertex in vt.GetVertices())
         {
             IComparable v = pt.GetPropertyValue(vertex.VertexId);
             if (v != null)
             {
                 throw new PropertyTypeInUseException();
             }
         }
     }
     else
     {
         EdgeType et = edgeType[pt.TypeId];
         foreach (Edge edge in et.GetEdges())
         {
             IComparable v = pt.GetPropertyValue(edge.EdgeId);
             if (v != null)
             {
                 throw new PropertyTypeInUseException();
             }
         }
     }
     if (pt.IsVertexProperty)
     {
         VertexType vt = vertexType[pt.TypeId];
         vt.stringToPropertyType.Remove(pt.Name);
     }
     else
     {
         EdgeType et = edgeType[pt.TypeId];
         et.stringToPropertyType.Remove(pt.Name);
     }
     Update();
     propertyType[pt.PropertyId] = null;
     pt.Unpersist(Session, true);
 }