/// <summary> /// Create a new SinglEdgeCollection /// </summary> /// <param name="myFirstVertex">The first vertex of the collection</param> /// <param name="myStartingSize">The starting size of the underlying data structure</param> public IncomingEdgeCollection(InMemoryVertex myFirstVertex, Int32 myStartingSize = 100) { _containedVertices = new InMemoryVertex[myStartingSize]; _idx = 0; _containedVertices[_idx++] = myFirstVertex; _isDirty = true; }
/// <summary> /// Removes a vertex from the collection /// </summary> /// <param name="myVertex">The vertex to remove.</param> public void RemoveVertex(InMemoryVertex myVertex) { var contElements = _containedVertices.Where(item => item == myVertex); _containedVertices = _containedVertices.Except(contElements).ToArray(); _idx = _idx - contElements.Count(); _isDirty = true; }
/// <summary> /// Creates a new hyper edge /// </summary> /// <param name="myContainedSingleEdges">The single edges that are contained within the hyper edge</param> /// <param name="myEdgeTypeID">The type id of the edge</param> /// <param name="mySourceVertex">The source vertex</param> /// <param name="myComment">The comment on this graph element</param> /// <param name="myCreationDate">The creation date of this element</param> /// <param name="myModificationDate">The modification date of this element</param> /// <param name="myStructuredProperties">The structured properties of this element</param> /// <param name="myUnstructuredProperties">The unstructured properties of this element</param> public HyperEdge( HashSet <SingleEdge> myContainedSingleEdges, Int64 myEdgeTypeID, InMemoryVertex mySourceVertex, String myComment, long myCreationDate, long myModificationDate, IDictionary <Int64, IComparable> myStructuredProperties, IDictionary <String, Object> myUnstructuredProperties) : base(myComment, myCreationDate, myModificationDate, myStructuredProperties, myUnstructuredProperties) { _edgeTypeID = myEdgeTypeID; _sourceVertex = mySourceVertex; ContainedSingleEdges = myContainedSingleEdges; }
/// <summary> /// Creates a new single edge /// </summary> /// <param name="myEdgeTypeID">The edge type id</param> /// <param name="mySourceVertex">The source vertex</param> /// <param name="myTargetVertex">The target vertex</param> /// <param name="myComment">The comment on this graph element</param> /// <param name="myCreationDate">The creation date of this element</param> /// <param name="myModificationDate">The modification date of this element</param> /// <param name="myStructuredProperties">The structured properties of this element</param> /// <param name="myUnstructuredProperties">The unstructured properties of this element</param> public SingleEdge( Int64 myEdgeTypeID, InMemoryVertex mySourceVertex, InMemoryVertex myTargetVertex, String myComment, long myCreationDate, long myModificationDate, IDictionary <Int64, IComparable> myStructuredProperties, IDictionary <String, Object> myUnstructuredProperties) : base(myComment, myCreationDate, myModificationDate, myStructuredProperties, myUnstructuredProperties) { _edgeTypeID = myEdgeTypeID; SourceVertex = mySourceVertex; TargetVertex = myTargetVertex; _hashcode = SourceVertex.GetHashCode() ^ TargetVertex.GetHashCode(); }
/// <summary> /// Adds a vertex to the collection /// </summary> /// <param name="myVertex">The edge that is going to be added</param> public void AddVertex(InMemoryVertex myVertex) { if (_idx >= _containedVertices.Length) { #region grow var newArray = new InMemoryVertex[_containedVertices.Length * 2]; Array.Copy(_containedVertices, newArray, _containedVertices.Length); _containedVertices = newArray; #endregion } _containedVertices[_idx++] = myVertex; _isDirty = true; }
/// <summary> /// Updates an InMemoryVertex /// </summary> /// <param name="toBeUpdatedVertex">The vertex that should be updated</param> /// <param name="myVertexUpdate">The definition of the vertex update</param> /// <returns>The updated vertex</returns> private InMemoryVertex UpdateVertex_private(InMemoryVertex toBeUpdatedVertex, VertexUpdateDefinition myVertexUpdate) { #region udpate comment if (myVertexUpdate.CommentUpdate != null) { toBeUpdatedVertex.UpdateComment(myVertexUpdate.CommentUpdate); } #endregion #region update binary properties if (myVertexUpdate.UpdatedBinaryProperties != null) { toBeUpdatedVertex.UpdateBinaryProperties(myVertexUpdate.UpdatedBinaryProperties.Updated, myVertexUpdate.UpdatedBinaryProperties.Deleted); } #endregion #region udpate single edges if (myVertexUpdate.UpdatedSingleEdges != null) { if (toBeUpdatedVertex.OutgoingEdges == null) { lock (toBeUpdatedVertex) { toBeUpdatedVertex.OutgoingEdges = new Dictionary<long, IEdge>(); } } lock (toBeUpdatedVertex.OutgoingEdges) { #region delete edges if (myVertexUpdate.UpdatedSingleEdges.Deleted != null) { foreach (var item in myVertexUpdate.UpdatedSingleEdges.Deleted) { IEdge edge = null; if (toBeUpdatedVertex.OutgoingEdges.TryGetValue(item, out edge)) { if (edge is SingleEdge) { var targetVertex = edge.GetTargetVertices().First(); RemoveIncommingEdgeFromTargetVertex((InMemoryVertex)targetVertex, targetVertex.VertexTypeID, item, toBeUpdatedVertex); toBeUpdatedVertex.OutgoingEdges.Remove(item); } } } } #endregion #region update edges if (myVertexUpdate.UpdatedSingleEdges.Updated != null) { foreach (var item in myVertexUpdate.UpdatedSingleEdges.Updated) { IEdge edge = null; var targetVertex = GetOrCreateTargetVertex(item.Value.TargetVertex.VertexTypeID, item.Value.TargetVertex.VertexID); if (toBeUpdatedVertex.OutgoingEdges.TryGetValue(item.Key, out edge)) { if (edge is SingleEdge) { var singleEdge = (SingleEdge)edge; if (edge.Comment != null) { singleEdge.UpdateComment(item.Value.CommentUpdate); } if (item.Value.EdgeTypeID != null) { singleEdge.UpdateEdgeType(item.Value.EdgeTypeID); } if (item.Value.UpdatedStructuredProperties != null) { singleEdge.UpdateStructuredProperties( item.Value.UpdatedStructuredProperties.Updated, item.Value.UpdatedStructuredProperties.Deleted); } if (item.Value.UpdatedUnstructuredProperties != null) { singleEdge.UpdateUnStructuredProperties( item.Value.UpdatedUnstructuredProperties.Updated, item.Value.UpdatedUnstructuredProperties.Deleted); } if (item.Value.SourceVertex != null) { lock (singleEdge) { singleEdge.SourceVertex = toBeUpdatedVertex; } } if (item.Value.TargetVertex != null) { lock (singleEdge) { if (singleEdge.TargetVertex != null) { RemoveIncommingEdgeFromTargetVertex(singleEdge.TargetVertex, toBeUpdatedVertex.VertexTypeID, item.Key, toBeUpdatedVertex); } singleEdge.TargetVertex = targetVertex; } } } } else { edge = new SingleEdge(item.Value.EdgeTypeID, toBeUpdatedVertex, targetVertex, item.Value.CommentUpdate, 0, 0, item.Value.UpdatedStructuredProperties == null ? null : item.Value.UpdatedStructuredProperties.Updated, item.Value.UpdatedUnstructuredProperties == null ? null : item.Value.UpdatedUnstructuredProperties.Updated); toBeUpdatedVertex.OutgoingEdges.Add(item.Key, edge); } CreateOrUpdateIncomingEdgesOnVertex(targetVertex, toBeUpdatedVertex.VertexTypeID, item.Key, toBeUpdatedVertex); } } #endregion } } #endregion #region update hyper edges if (myVertexUpdate.UpdateHyperEdges != null) { if (toBeUpdatedVertex.OutgoingEdges == null) { lock (toBeUpdatedVertex) { toBeUpdatedVertex.OutgoingEdges = new Dictionary<long, IEdge>(); } } lock (toBeUpdatedVertex.OutgoingEdges) { #region delete edges if (myVertexUpdate.UpdateHyperEdges.Deleted != null) { foreach (var item in myVertexUpdate.UpdateHyperEdges.Deleted) { IEdge edge = null; if (toBeUpdatedVertex.OutgoingEdges.TryGetValue(item, out edge)) { if (edge is HyperEdge) { foreach (var targetVertex in edge.GetTargetVertices()) { RemoveIncommingEdgeFromTargetVertex((InMemoryVertex)targetVertex, targetVertex.VertexTypeID, item, toBeUpdatedVertex); } toBeUpdatedVertex.OutgoingEdges.Remove(item); } } } } #endregion #region update edges if (myVertexUpdate.UpdateHyperEdges.Updated != null) { foreach (var item in myVertexUpdate.UpdateHyperEdges.Updated) { IEdge edge = null; if (toBeUpdatedVertex.OutgoingEdges.TryGetValue(item.Key, out edge)) { if (edge is HyperEdge) { var hyperEdge = (HyperEdge)edge; if (edge.Comment != null) { hyperEdge.UpdateComment(item.Value.CommentUpdate); } if (item.Value.EdgeTypeID != null) { hyperEdge.UpdateEdgeType(item.Value.EdgeTypeID); } if (item.Value.UpdatedUnstructuredProperties != null) hyperEdge.UpdateUnStructuredProperties( item.Value.UpdatedUnstructuredProperties.Updated, item.Value.UpdatedUnstructuredProperties.Deleted); if (item.Value.UpdatedStructuredProperties != null) hyperEdge.UpdateStructuredProperties( item.Value.UpdatedStructuredProperties.Updated, item.Value.UpdatedStructuredProperties.Deleted); #region update the containing single edges lock (hyperEdge.ContainedSingleEdges) { if (item.Value.ToBeDeletedSingleEdges != null) { foreach (var singleEdge in item.Value.ToBeDeletedSingleEdges) { var targetVertex = GetOrCreateTargetVertex(singleEdge.TargetVertex.VertexTypeID, singleEdge.TargetVertex.VertexID); RemoveIncommingEdgeFromTargetVertex(targetVertex, toBeUpdatedVertex.VertexTypeID, item.Key, toBeUpdatedVertex); hyperEdge.ContainedSingleEdges.RemoveWhere(sEdge => (sEdge.SourceVertex.VertexTypeID == singleEdge.SourceVertex.VertexTypeID && sEdge.SourceVertex.VertexID == singleEdge.SourceVertex.VertexID) && (sEdge.TargetVertex.VertexID == singleEdge.TargetVertex.VertexID && sEdge.TargetVertex.VertexTypeID == singleEdge.TargetVertex.VertexTypeID)); } } if (item.Value.ToBeUpdatedSingleEdges != null) { var newEdges = new List<SingleEdge>(); foreach (var contEdge in item.Value.ToBeUpdatedSingleEdges) { var targetVertex = GetOrCreateTargetVertex(contEdge.TargetVertex.VertexTypeID, contEdge.TargetVertex.VertexID); foreach (var singleEdgeItem in hyperEdge.ContainedSingleEdges) { var correspondTarget = GetOrCreateTargetVertex(contEdge.TargetVertex.VertexTypeID, contEdge.TargetVertex.VertexID); var correspondSource = GetOrCreateTargetVertex(contEdge.SourceVertex.VertexTypeID, contEdge.SourceVertex.VertexID); if (correspondTarget == singleEdgeItem.TargetVertex && singleEdgeItem.SourceVertex == correspondSource) { if (contEdge.CommentUpdate != null) { singleEdgeItem.UpdateComment(contEdge.CommentUpdate); } if (contEdge.EdgeTypeID != null) { singleEdgeItem.UpdateEdgeType(contEdge.EdgeTypeID); } if (contEdge.UpdatedStructuredProperties != null) { singleEdgeItem.UpdateStructuredProperties( contEdge.UpdatedStructuredProperties.Updated, contEdge.UpdatedStructuredProperties.Deleted); } if (contEdge.UpdatedUnstructuredProperties != null) { singleEdgeItem.UpdateUnStructuredProperties( contEdge.UpdatedUnstructuredProperties.Updated, contEdge.UpdatedUnstructuredProperties.Deleted); } if (contEdge.TargetVertex != null) { lock (singleEdgeItem) { if (singleEdgeItem.TargetVertex != null) { RemoveIncommingEdgeFromTargetVertex(singleEdgeItem.TargetVertex, toBeUpdatedVertex.VertexTypeID, item.Key, toBeUpdatedVertex); } singleEdgeItem.TargetVertex = targetVertex; } } if (contEdge.SourceVertex != null) { lock (singleEdgeItem) { singleEdgeItem.SourceVertex = GetOrCreateTargetVertex( contEdge.SourceVertex.VertexTypeID, contEdge.SourceVertex.VertexID); } } } else { newEdges.Add(new SingleEdge(contEdge.EdgeTypeID, toBeUpdatedVertex, GetOrCreateTargetVertex( contEdge.TargetVertex. VertexTypeID, contEdge.TargetVertex.VertexID), contEdge.CommentUpdate, 0, 0, contEdge.UpdatedStructuredProperties == null ? null : contEdge. UpdatedStructuredProperties . Updated, contEdge. UpdatedUnstructuredProperties == null ? null : contEdge. UpdatedUnstructuredProperties . Updated)); } } CreateOrUpdateIncomingEdgesOnVertex(targetVertex, toBeUpdatedVertex.VertexTypeID, item.Key, toBeUpdatedVertex); hyperEdge.ContainedSingleEdges.UnionWith(newEdges); newEdges.Clear(); } } } #endregion } } else { var singleEdges = new HashSet<SingleEdge>(); if (item.Value.ToBeUpdatedSingleEdges != null) { foreach (var singleItem in item.Value.ToBeUpdatedSingleEdges) { var targetVertex = GetOrCreateTargetVertex(singleItem.TargetVertex.VertexTypeID, singleItem.TargetVertex.VertexID); singleEdges.Add(new SingleEdge(singleItem.EdgeTypeID, toBeUpdatedVertex, targetVertex, singleItem.CommentUpdate == null ? null : singleItem.CommentUpdate, 0, 0, singleItem.UpdatedStructuredProperties == null ? null : singleItem.UpdatedStructuredProperties. Updated, singleItem.UpdatedUnstructuredProperties == null ? null : singleItem.UpdatedUnstructuredProperties. Updated)); CreateOrUpdateIncomingEdgesOnVertex(targetVertex, toBeUpdatedVertex.VertexTypeID, item.Key, toBeUpdatedVertex); } toBeUpdatedVertex.OutgoingEdges.Add(item.Key, new HyperEdge(singleEdges, item.Value.EdgeTypeID, toBeUpdatedVertex, item.Value.CommentUpdate == null ? null : item.Value.CommentUpdate, 0, 0, item.Value.UpdatedStructuredProperties == null ? null : item.Value.UpdatedStructuredProperties.Updated, item.Value.UpdatedUnstructuredProperties == null ? null : item.Value.UpdatedUnstructuredProperties.Updated)); } } } } #endregion } } #endregion #region update unstructured properties if (myVertexUpdate.UpdatedUnstructuredProperties != null) { toBeUpdatedVertex.UpdateUnstructuredProperties(myVertexUpdate.UpdatedUnstructuredProperties); } #endregion #region update structured properties if (myVertexUpdate.UpdatedStructuredProperties != null) { toBeUpdatedVertex.UpdateStructuredProperties(myVertexUpdate.UpdatedStructuredProperties); } #endregion return toBeUpdatedVertex; }
/// <summary> /// Removes the incomming edge from a target vertex. /// </summary> /// <param name="myTargetVertex">The target vertex.</param> /// <param name="myIncommingVertexTypeID">The target vertex type id.</param> /// <param name="myIncommingEdgePropID">The edge property id.</param> /// <param name="myIncommingVertex">The vertex which is to be updated.</param> private void RemoveIncommingEdgeFromTargetVertex(InMemoryVertex myTargetVertex, Int64 myIncommingVertexTypeID, Int64 myIncommingEdgePropID, IVertex myIncommingVertex) { if (myTargetVertex.IncomingEdges != null) { lock (myTargetVertex.IncomingEdges) { Dictionary<Int64, IncomingEdgeCollection> iEdgeCollection = null; if (myTargetVertex.IncomingEdges.TryGetValue(myIncommingVertexTypeID, out iEdgeCollection)) { IncomingEdgeCollection edgeCollection = null; if (iEdgeCollection.TryGetValue(myIncommingEdgePropID, out edgeCollection)) { edgeCollection.RemoveVertex((InMemoryVertex)myIncommingVertex); if (edgeCollection.Count() == 0) { iEdgeCollection.Remove(myIncommingEdgePropID); } } if (iEdgeCollection.Count == 0) { myTargetVertex.IncomingEdges.Remove(myIncommingVertexTypeID); } } } } }
/// <summary> /// Creates or updates incoming edges on vertices /// </summary> /// <param name="myTargetVertex">The vertex that should be updated</param> /// <param name="myIncomingVertexTypeID">The id of the incoming vertex type</param> /// <param name="myIncomingEdgeID">The id of the incoming edge property</param> /// <param name="myIncomingVertex">The incoming single edge</param> private void CreateOrUpdateIncomingEdgesOnVertex(InMemoryVertex myTargetVertex, Int64 myIncomingVertexTypeID, Int64 myIncomingEdgeID, InMemoryVertex myIncomingVertex) { lock (myTargetVertex) { if (myTargetVertex.IncomingEdges == null) { myTargetVertex.IncomingEdges = new Dictionary<long, Dictionary<long, IncomingEdgeCollection>>(); var payload = new IncomingEdgeCollection(myIncomingVertex); var innerDict = new Dictionary<Int64, IncomingEdgeCollection> { { myIncomingEdgeID, payload } }; myTargetVertex.IncomingEdges.Add(myIncomingVertexTypeID, innerDict); } else { if (myTargetVertex.IncomingEdges.ContainsKey(myIncomingVertexTypeID)) { if (myTargetVertex.IncomingEdges[myIncomingVertexTypeID].ContainsKey(myIncomingEdgeID)) { myTargetVertex.IncomingEdges[myIncomingVertexTypeID][myIncomingEdgeID].AddVertex(myIncomingVertex); } else { myTargetVertex.IncomingEdges[myIncomingVertexTypeID][myIncomingEdgeID] = new IncomingEdgeCollection(myIncomingVertex); } } else { var payload = new IncomingEdgeCollection(myIncomingVertex); var innerDict = new Dictionary<Int64, IncomingEdgeCollection> { { myIncomingEdgeID, payload } }; myTargetVertex.IncomingEdges.Add(myIncomingVertexTypeID, innerDict); } } } }
private void AddEdgesToVertex(VertexAddDefinition myVertexDefinition, InMemoryVertex myVertex, Dictionary<Int64, IEdge> myEdges) { SingleEdge singleEdge; InMemoryVertex targetVertex; #region single edges //create the single edges if (myVertexDefinition.OutgoingSingleEdges != null) { foreach (var aSingleEdgeDefinition in myVertexDefinition.OutgoingSingleEdges) { targetVertex = GetOrCreateTargetVertex(aSingleEdgeDefinition.TargetVertexInformation.VertexTypeID, aSingleEdgeDefinition.TargetVertexInformation.VertexID); //create the new Edge singleEdge = new SingleEdge(aSingleEdgeDefinition.EdgeTypeID, myVertex, targetVertex, aSingleEdgeDefinition.Comment, aSingleEdgeDefinition.CreationDate, aSingleEdgeDefinition.ModificationDate, aSingleEdgeDefinition.StructuredProperties, aSingleEdgeDefinition.UnstructuredProperties); CreateOrUpdateIncomingEdgesOnVertex( targetVertex, myVertexDefinition.VertexTypeID, aSingleEdgeDefinition.PropertyID, myVertex); myEdges.Add(aSingleEdgeDefinition.PropertyID, singleEdge); } } #endregion #region hyper edges if (myVertexDefinition.OutgoingHyperEdges != null) { foreach (var aHyperEdgeDefinition in myVertexDefinition.OutgoingHyperEdges) { var containedSingleEdges = new HashSet<SingleEdge>(); foreach (var aSingleEdgeDefinition in aHyperEdgeDefinition.ContainedSingleEdges) { targetVertex = GetOrCreateTargetVertex(aSingleEdgeDefinition.TargetVertexInformation.VertexTypeID, aSingleEdgeDefinition.TargetVertexInformation.VertexID); singleEdge = new SingleEdge(aSingleEdgeDefinition.EdgeTypeID, myVertex, targetVertex, aSingleEdgeDefinition.Comment, aSingleEdgeDefinition.CreationDate, aSingleEdgeDefinition.ModificationDate, aSingleEdgeDefinition.StructuredProperties, aSingleEdgeDefinition.UnstructuredProperties); CreateOrUpdateIncomingEdgesOnVertex( targetVertex, myVertexDefinition.VertexTypeID, aHyperEdgeDefinition.PropertyID, myVertex); containedSingleEdges.Add(singleEdge); } //create the new edge myEdges.Add( aHyperEdgeDefinition.PropertyID, new HyperEdge( containedSingleEdges, aHyperEdgeDefinition.EdgeTypeID, myVertex, aHyperEdgeDefinition.Comment, aHyperEdgeDefinition.CreationDate, aHyperEdgeDefinition.ModificationDate, aHyperEdgeDefinition.StructuredProperties, aHyperEdgeDefinition.UnstructuredProperties)); } } #endregion }
public IVertex AddVertex( SecurityToken mySecurityToken, Int64 myTransactionID, VertexAddDefinition myVertexDefinition, Int64 myVertexRevisionID = 0L, Boolean myCreateIncomingEdges = true) { #region create vertex type entry //check for vertex type if (!_vertexStore.ContainsKey(myVertexDefinition.VertexTypeID)) { _vertexStore.TryAdd(myVertexDefinition.VertexTypeID, new ConcurrentDictionary<long, InMemoryVertex>()); } #endregion #region create new vertex var vertexRevisionID = 0L; Dictionary<Int64, Stream> binaryProperties; if (myVertexDefinition.BinaryProperties == null) { binaryProperties = null; } else { binaryProperties = myVertexDefinition.BinaryProperties.ToDictionary(key => key.PropertyID, value => value.Stream); } Boolean addEdges = myVertexDefinition.OutgoingSingleEdges != null || myVertexDefinition.OutgoingHyperEdges != null; #endregion #region store the new vertex InMemoryVertex createdVertex = null; _vertexStore[myVertexDefinition.VertexTypeID]. AddOrUpdate(myVertexDefinition.VertexID, (anotherLong) => { Dictionary<long, IEdge> newEdge = null; if (addEdges) { newEdge = new Dictionary<long, IEdge>(); } InMemoryVertex toBeAddedVertex = new InMemoryVertex( myVertexDefinition.VertexID, myVertexDefinition.VertexTypeID, vertexRevisionID, myVertexDefinition.Edition, binaryProperties, newEdge, myVertexDefinition.Comment, myVertexDefinition.CreationDate, myVertexDefinition.ModificationDate, myVertexDefinition.StructuredProperties, myVertexDefinition.UnstructuredProperties); if (addEdges) { AddEdgesToVertex(myVertexDefinition, toBeAddedVertex, newEdge); } createdVertex = toBeAddedVertex; return toBeAddedVertex; }, (id, oldVertex) => { if (!oldVertex.IsBulkVertex) { throw new VertexAlreadyExistException(myVertexDefinition.VertexTypeID, myVertexDefinition.VertexID); } Dictionary<long, IEdge> oldEdge = null; if (addEdges) { oldEdge = new Dictionary<long, IEdge>(); } oldVertex.Activate( binaryProperties, oldEdge, myVertexDefinition.Comment, myVertexDefinition.CreationDate, myVertexDefinition.ModificationDate, myVertexDefinition.StructuredProperties, myVertexDefinition.UnstructuredProperties); if (addEdges) { AddEdgesToVertex(myVertexDefinition, oldVertex, oldEdge); } createdVertex = oldVertex; return oldVertex; }); #endregion return createdVertex; }
public virtual void Add_InsertVertex_Fails() { #region data var idx = new BinaryTreeIndex(); var vertexID = 1L; var propertyID = 1L; var fake_propertyID = 2L; var propertyValue = 10; // set propertyID for index idx.Init(new List<Int64>() { propertyID }); // create a vertex var v = new InMemoryVertex(vertexID, 1L, 1L, null, null, null, "dummy", DateTime.Now.Ticks, DateTime.Now.Ticks, new Dictionary<long, IComparable>() { { fake_propertyID, propertyValue } }, // structured properties null); #endregion #region test // this won't add the vertex because it doesn't have the indexed property idx.Add(v); Assert.That(idx.KeyCount(), Is.EqualTo(0L), "vertex has been added by mistake"); Assert.That(idx.ValueCount(), Is.EqualTo(0L), "vertex has been added by mistake"); #endregion }
public virtual void Add_InsertVertex() { #region data var idx = new BinaryTreeIndex(); var vertexID = 1L; var propertyID = 1L; var propertyValue = 10; // set propertyID for index idx.Init(new List<Int64>() { propertyID }); // create a vertex var v = new InMemoryVertex(vertexID, 1L, 1L, null, null, null, "dummy", DateTime.Now.Ticks, DateTime.Now.Ticks, new Dictionary<long, IComparable>() { { propertyID, propertyValue } }, // structured properties null); #endregion #region test // add idx.Add(v); Assert.AreEqual(1, idx.KeyCount()); Assert.AreEqual(1, idx.ValueCount()); Assert.IsTrue(idx[propertyValue].Contains(vertexID)); #endregion }