Example #1
0
        public void AddOrUpdate(Object keyObject, AGraphElement graphElement)
        {
            IComparable key;

            if (!IndexHelper.CheckObject(out key, keyObject))
            {
                return;
            }

            if (WriteResource())
            {
                List <AGraphElement> values;
                if (_idx.TryGetValue(key, out values))
                {
                    values.Add(graphElement);
                }
                else
                {
                    values = new List <AGraphElement> {
                        graphElement
                    };
                    _idx.Add(key, values);
                }

                FinishWriteResource();

                return;
            }

            throw new CollisionException();
        }
Example #2
0
        public void RemoveValue(AGraphElement graphElement)
        {
            if (WriteResource())
            {
                try
                {
                    var toBeRemovedKeys = new List <IComparable>();

                    foreach (var aKv in _idx)
                    {
                        aKv.Value.Remove(graphElement);
                        if (aKv.Value.Count == 0)
                        {
                            toBeRemovedKeys.Add(aKv.Key);
                        }
                    }

                    toBeRemovedKeys.ForEach(_ => _idx.Remove(_));
                }
                finally
                {
                    FinishWriteResource();
                }

                return;
            }

            throw new CollisionException(this);
        }
Example #3
0
        /// <summary>
        ///   Trims the Fallen-8.
        /// </summary>
        private void TrimPrivate()
        {
            for (var i = 0; i <= _currentId; i++)
            {
                AGraphElement graphElement = _graphElements.GetElement(i);
                if (graphElement != null)
                {
                    graphElement.Trim();
                }
            }

#if __MonoCS__
            //mono specific code
#else
            GC.Collect();
            GC.Collect();
            GC.WaitForFullGCComplete();
            GC.WaitForPendingFinalizers();
#endif

#if __MonoCS__
            //mono specific code
#else
            var errorCode = SaveNativeMethods.EmptyWorkingSet(Process.GetCurrentProcess().Handle);
#endif

            RecalculateGraphElementCounter();
        }
Example #4
0
        public void AddOrUpdateUnitTest()
        {
            var           target       = new SingleValueIndex(); // TODO: Initialize to an appropriate value
            object        keyObject    = null;                   // TODO: Initialize to an appropriate value
            AGraphElement graphElement = null;                   // TODO: Initialize to an appropriate value

            target.AddOrUpdate(keyObject, graphElement);
        }
        public void FulltextSearchResultElementConstructorUnitTest()
        {
            Assert.Inconclusive("TODO");

            AGraphElement        graphElement = null; // TODO: Initialize to an appropriate value
            double               score        = 0F;   // TODO: Initialize to an appropriate value
            IEnumerable <string> highlights   = null; // TODO: Initialize to an appropriate value
            var target = new FulltextSearchResultElement(graphElement, score, highlights);
        }
Example #6
0
        public void RemoveValueUnitTest()
        {
            Assert.Inconclusive("TODO");

            var           target       = new DictionaryIndex(); // TODO: Initialize to an appropriate value
            AGraphElement graphElement = null;                  // TODO: Initialize to an appropriate value

            target.RemoveValue(graphElement);
        }
Example #7
0
        public void AddOrUpdateUnitTest()
        {
            Assert.Inconclusive("TODO");

            var           target       = new DictionaryIndex(); // TODO: Initialize to an appropriate value
            object        keyObject    = null;                  // TODO: Initialize to an appropriate value
            AGraphElement graphElement = null;                  // TODO: Initialize to an appropriate value

            target.AddOrUpdate(keyObject, graphElement);
        }
        public void GraphElementUnitTest()
        {
            Assert.Inconclusive("TODO");

            IRTreeDataContainer target   = CreateIRTreeDataContainer(); // TODO: Initialize to an appropriate value
            AGraphElement       expected = null;                        // TODO: Initialize to an appropriate value
            AGraphElement       actual;

            target.GraphElement = expected;
            actual = target.GraphElement;
            Assert.AreEqual(expected, actual);
        }
Example #9
0
        /// <summary>
        ///   Trims the Fallen-8.
        /// </summary>
        private void TrimPrivate()
        {
            for (var i = 0; i < _currentId; i++)
            {
                AGraphElement graphElement = _graphElements[i];
                if (graphElement != null)
                {
                    graphElement.Trim();
                }
            }

            List <AGraphElement> newGraphElementList = new List <AGraphElement>();

            //copy the list and exclude nulls
            foreach (var aGraphElement in _graphElements)
            {
                if (aGraphElement != null)
                {
                    newGraphElementList.Add(aGraphElement);
                }
            }

            //check the IDs
            for (int i = 0; i < newGraphElementList.Count; i++)
            {
                newGraphElementList[i].SetId(i);
            }

            //set the correct currentID
            _currentId = newGraphElementList.Count;

            //cleanup and switch
            _graphElements.Clear();
            _graphElements = newGraphElementList;

#if __MonoCS__
            //mono specific code
#else
            GC.Collect();
            GC.Collect();
            GC.WaitForFullGCComplete(-1);
            GC.WaitForPendingFinalizers();
#endif

#if __MonoCS__
            //mono specific code
#else
            var errorCode = SaveNativeMethods.EmptyWorkingSet(Process.GetCurrentProcess().Handle);
#endif

            RecalculateGraphElementCounter();
        }
Example #10
0
        public void DistanceUnitTest1()
        {
            Assert.Inconclusive("TODO");

            ISpatialIndex target        = CreateISpatialIndex(); // TODO: Initialize to an appropriate value
            AGraphElement graphElement1 = null;                  // TODO: Initialize to an appropriate value
            AGraphElement graphElement2 = null;                  // TODO: Initialize to an appropriate value
            float         expected      = 0F;                    // TODO: Initialize to an appropriate value
            float         actual;

            actual = target.Distance(graphElement1, graphElement2);
            Assert.AreEqual(expected, actual);
        }
Example #11
0
        public Boolean TryGetGraphElement(out AGraphElement result, Int32 id)
        {
            if (ReadResource())
            {
                _graphElements.TryGetElementOrDefault(out result, id);

                FinishReadResource();

                return(result != null);
            }

            throw new CollisionException();
        }
Example #12
0
        /// <summary>
        /// Gets a value from the index
        /// </summary>
        /// <param name="result">Result</param>
        /// <param name="key">Key</param>
        /// <returns>
        /// <c>true</c> if something was found; otherwise, <c>false</c>.
        /// </returns>
        public bool TryGetValue(out AGraphElement result, IComparable key)
        {
            if (ReadResource())
            {
                var value = _idx.TryGetValue(key, out result);

                FinishReadResource();

                return(value);
            }

            throw new CollisionException(this);
        }
Example #13
0
        public Boolean TryGetGraphElement(out AGraphElement result, Int32 id)
        {
            if (ReadResource())
            {
                result = _graphElements[id];

                FinishReadResource();

                return(result != null);
            }

            throw new CollisionException(this);
        }
Example #14
0
        public void ContainmentUnitTest()
        {
            Assert.Inconclusive("TODO");

            ISpatialIndex target = CreateISpatialIndex();             // TODO: Initialize to an appropriate value
            ReadOnlyCollection <AGraphElement> result         = null; // TODO: Initialize to an appropriate value
            ReadOnlyCollection <AGraphElement> resultExpected = null; // TODO: Initialize to an appropriate value
            AGraphElement graphElement = null;                        // TODO: Initialize to an appropriate value
            bool          expected     = false;                       // TODO: Initialize to an appropriate value
            bool          actual;

            actual = target.Containment(out result, graphElement);
            Assert.AreEqual(resultExpected, result);
            Assert.AreEqual(expected, actual);
        }
Example #15
0
        public void TryGetValueUnitTest1()
        {
            Assert.Inconclusive("TODO");

            var           target         = new SingleValueIndex(); // TODO: Initialize to an appropriate value
            AGraphElement result         = null;                   // TODO: Initialize to an appropriate value
            AGraphElement resultExpected = null;                   // TODO: Initialize to an appropriate value
            IComparable   key            = null;                   // TODO: Initialize to an appropriate value
            bool          expected       = false;                  // TODO: Initialize to an appropriate value
            bool          actual;

            actual = target.TryGetValue(out result, key);
            Assert.AreEqual(resultExpected, result);
            Assert.AreEqual(expected, actual);
        }
Example #16
0
        /// <summary>
        ///   Writes A graph element.
        /// </summary>
        /// <param name='graphElement'> Graph element. </param>
        /// <param name='writer'> Writer. </param>
        private static void WriteAGraphElement(AGraphElement graphElement, SerializationWriter writer)
        {
            writer.Write(graphElement.Id);
            writer.Write(graphElement.CreationDate);
            writer.Write(graphElement.ModificationDate);

            var properties = graphElement.GetAllProperties();

            writer.WriteOptimized(properties.Count);
            foreach (var aProperty in properties)
            {
                writer.WriteOptimized(aProperty.PropertyId);
                writer.WriteObject(aProperty.Value);
            }
        }
Example #17
0
        public void TryGetGraphElementIntegrationTest()
        {
            Assert.Inconclusive("TODO.");

            IRead         target         = CreateIRead(); // TODO: Initialize to an appropriate value
            AGraphElement result         = null;          // TODO: Initialize to an appropriate value
            AGraphElement resultExpected = null;          // TODO: Initialize to an appropriate value
            int           id             = 0;             // TODO: Initialize to an appropriate value
            bool          expected       = false;         // TODO: Initialize to an appropriate value
            bool          actual;

            actual = target.TryGetGraphElement(out result, id);
            Assert.AreEqual(resultExpected, result);
            Assert.AreEqual(expected, actual);
        }
Example #18
0
        public void RemoveValue(AGraphElement graphElement)
        {
            if (WriteResource())
            {
                var toBeRemovedKeys = (from aKv in _idx where ReferenceEquals(aKv.Value, graphElement) select aKv.Key).ToList();

                toBeRemovedKeys.ForEach(_ => _idx.Remove(_));

                FinishWriteResource();

                return;
            }

            throw new CollisionException(this);
        }
Example #19
0
        public void SearchDistanceUnitTest1()
        {
            Assert.Inconclusive("TODO");

            ISpatialIndex target = CreateISpatialIndex();             // TODO: Initialize to an appropriate value
            ReadOnlyCollection <AGraphElement> result         = null; // TODO: Initialize to an appropriate value
            ReadOnlyCollection <AGraphElement> resultExpected = null; // TODO: Initialize to an appropriate value
            float         distance     = 0F;                          // TODO: Initialize to an appropriate value
            AGraphElement graphElement = null;                        // TODO: Initialize to an appropriate value
            bool          expected     = false;                       // TODO: Initialize to an appropriate value
            bool          actual;

            actual = target.SearchDistance(out result, distance, graphElement);
            Assert.AreEqual(resultExpected, result);
            Assert.AreEqual(expected, actual);
        }
Example #20
0
        public void GetNextNeighborsUnitTest1()
        {
            Assert.Inconclusive("TODO");

            ISpatialIndex target = CreateISpatialIndex();             // TODO: Initialize to an appropriate value
            ReadOnlyCollection <AGraphElement> result         = null; // TODO: Initialize to an appropriate value
            ReadOnlyCollection <AGraphElement> resultExpected = null; // TODO: Initialize to an appropriate value
            AGraphElement graphElement         = null;                // TODO: Initialize to an appropriate value
            int           countOfNextNeighbors = 0;                   // TODO: Initialize to an appropriate value
            bool          expected             = false;               // TODO: Initialize to an appropriate value
            bool          actual;

            actual = target.GetNextNeighbors(out result, graphElement, countOfNextNeighbors);
            Assert.AreEqual(resultExpected, result);
            Assert.AreEqual(expected, actual);
        }
Example #21
0
        public bool TryAddProperty(Int32 graphElementId, UInt16 propertyId, Object property)
        {
            if (WriteResource())
            {
                var           success      = false;
                AGraphElement graphElement = _graphElements[graphElementId];
                if (graphElement != null)
                {
                    success = graphElement != null && graphElement.TryAddProperty(propertyId, property);
                }

                FinishWriteResource();

                return(success);
            }

            throw new CollisionException(this);
        }
Example #22
0
        public void AddOrUpdate(Object keyObject, AGraphElement graphElement)
        {
            IComparable key;

            if (!IndexHelper.CheckObject(out key, keyObject))
            {
                return;
            }

            if (WriteResource())
            {
                _idx[key] = graphElement;

                FinishWriteResource();

                return;
            }

            throw new CollisionException(this);
        }
Example #23
0
        /// <summary>
        ///   Saves the graph element bunch.
        /// </summary>
        /// <returns> The path to the graph element bunch </returns>
        /// <param name='range'> Range. </param>
        /// <param name='graphElements'> Graph elements. </param>
        /// <param name='pathToSavePoint'> Path to save point basis. </param>
        private static String SaveBunch(Tuple <Int32, Int32> range, List <AGraphElement> graphElements,
                                        String pathToSavePoint)
        {
            var partitionFileName = pathToSavePoint + Constants.GraphElementsSaveString + range.Item1 + "_to_" + range.Item2;

            using (var partitionFile = File.Create(partitionFileName, Constants.BufferSize, FileOptions.SequentialScan))
            {
                var partitionWriter = new SerializationWriter(partitionFile);

                partitionWriter.Write(range.Item1);
                partitionWriter.Write(range.Item2);

                for (var i = range.Item1; i < range.Item2; i++)
                {
                    AGraphElement aGraphElement = graphElements[i];
                    //there can be nulls
                    if (aGraphElement == null)
                    {
                        partitionWriter.Write(SerializedNull); // 2 for null
                        continue;
                    }

                    //code if it is an vertex or an edge
                    if (aGraphElement is VertexModel)
                    {
                        WriteVertex((VertexModel)aGraphElement, partitionWriter);
                    }
                    else
                    {
                        WriteEdge((EdgeModel)aGraphElement, partitionWriter);
                    }
                }

                partitionWriter.UpdateHeader();
                partitionWriter.Flush();
                partitionFile.Flush();
            }

            return(Path.GetFileName(partitionFileName));
        }
Example #24
0
        public void AddOrUpdate(object keyObject, AGraphElement graphElement)
        {
            String key;

            if (!IndexHelper.CheckObject(out key, keyObject))
            {
                return;
            }

            if (WriteResource())
            {
                try
                {
                    List <AGraphElement> values;
                    if (_idx.TryGetValue(key, out values))
                    {
                        values.Add(graphElement);
                    }
                    else
                    {
                        values = new List <AGraphElement> {
                            graphElement
                        };
                        _idx.Add(key, values);
                    }
                }
                finally
                {
                    FinishWriteResource();
                }

                return;
            }

            throw new CollisionException(this);
        }
Example #25
0
        /// <summary>
        ///   Writes A graph element.
        /// </summary>
        /// <param name='graphElement'> Graph element. </param>
        /// <param name='writer'> Writer. </param>
        private static void WriteAGraphElement(AGraphElement graphElement, SerializationWriter writer)
        {
            writer.Write(graphElement.Id);
            writer.Write(graphElement.CreationDate);
            writer.Write(graphElement.ModificationDate);

            var properties = graphElement.GetAllProperties();
            writer.Write(properties.Count);
            foreach (var aProperty in properties)
            {
                writer.Write(aProperty.PropertyId);
                writer.WriteObject(aProperty.Value);
            }
        }
 /// <summary>
 /// Create a new FulltextSearchResultElement instance
 /// </summary>
 /// <param name="graphElement">Graph element</param>
 /// <param name="score">Score</param>
 /// <param name="highlights">Highlights</param>
 public FulltextSearchResultElement(AGraphElement graphElement, Double score, IEnumerable<String> highlights = null )
 {
     GraphElement = graphElement;
     Score = score;
     Highlights = highlights == null ? new List<string>() : new List<string>(highlights);
 }
Example #27
0
        public void AddOrUpdate(object keyObject, AGraphElement graphElement)
        {
            String key;
            if (!IndexHelper.CheckObject(out key, keyObject))
            {
                return;
            }

            if (WriteResource())
            {
                List<AGraphElement> values;
                if (_idx.TryGetValue(key, out values))
                {
                    values.Add(graphElement);
                }
                else
                {
                    values = new List<AGraphElement> { graphElement };
                    _idx.Add(key, values);
                }

                FinishWriteResource();

                return;
            }

            throw new CollisionException();
        }
Example #28
0
        /// <summary>
        ///   Loads the graph elements.
        /// </summary>
        /// <param name='graphElements'> Graph elements of Fallen-8. </param>
        /// <param name='graphElementStreams'> Graph element streams. </param>
        private static void LoadGraphElements(AGraphElement[] graphElements, List<String> graphElementStreams)
        {
            var edgeTodo = new Dictionary<Int32, List<EdgeOnVertexToDo>>();
            var result = new List<List<EdgeSneakPeak>>(graphElementStreams.Count);

            //create the major part of the graph elements
            for (var i = 0; i < graphElementStreams.Count; i++)
            {
                result.Add(LoadAGraphElementBunch(graphElementStreams[i], graphElements, edgeTodo));
            }

            foreach (var aEdgeSneakPeakList in result)
            {
                foreach (var aSneakPeak in aEdgeSneakPeakList)
                {
                    VertexModel sourceVertex = graphElements[aSneakPeak.SourceVertexId] as VertexModel;
                    VertexModel targetVertex = graphElements[aSneakPeak.TargetVertexId] as VertexModel;
                    if (sourceVertex != null && targetVertex != null)
                    {
                        graphElements[aSneakPeak.Id] =
                            new EdgeModel(
                                aSneakPeak.Id,
                                aSneakPeak.CreationDate,
                                aSneakPeak.ModificationDate,
                                targetVertex,
                                sourceVertex,
                                aSneakPeak.Properties);
                    }
                    else
                    {
                        throw new Exception(String.Format("Corrupt savegame... could not create the edge {0}", aSneakPeak.Id));
                    }
                }
            }

            foreach (var aKV in edgeTodo)
            {
                EdgeModel edge = graphElements[aKV.Key] as EdgeModel;
                if (edge != null)
                {
                    foreach (var aTodo in aKV.Value)
                    {
                        VertexModel interestingVertex = graphElements[aTodo.VertexId] as VertexModel;
                        if (interestingVertex != null)
                        {
                            if (aTodo.IsIncomingEdge)
                            {
                                interestingVertex.AddIncomingEdge(aTodo.EdgePropertyId, edge);
                            }
                            else
                            {
                                interestingVertex.AddOutEdge(aTodo.EdgePropertyId, edge);
                            }
                        }
                        else
                        {
                            Logger.LogError(String.Format("Corrupt savegame... could not get the vertex {0}", aTodo.VertexId));
                        }
                    }
                }
                else
                {
                    Logger.LogError(String.Format("Corrupt savegame... could not get the edge {0}", aKV.Key));
                }
            }
        }
Example #29
0
        public void RemoveValue(AGraphElement graphElement)
        {
            if (WriteResource())
            {
                try
                {
                    var toBeRemovedKeys = new List<IComparable>();

                    foreach (var aKv in _idx)
                    {
                        aKv.Value.Remove(graphElement);
                        if (aKv.Value.Count == 0)
                        {
                            toBeRemovedKeys.Add(aKv.Key);
                        }
                    }

                    toBeRemovedKeys.ForEach(_ => _idx.Remove(_));
                }
                finally
                {
                    FinishWriteResource();
                }

                return;
            }

            throw new CollisionException(this);
        }
Example #30
0
        /// <summary>
        ///   Loads a graph element bunch.
        /// </summary>
        /// <returns> The edges that point to vertices that are not within this bunch. </returns>
        /// <param name='graphElementBunchPath'> Graph element bunch path. </param>
        /// <param name='graphElementsOfFallen8'> Graph elements of Fallen-8. </param>
        /// <param name="edgeTodoOnVertex"> The edges that have to be added to this vertex </param>
        private static List<EdgeSneakPeak> LoadAGraphElementBunch(
            string graphElementBunchPath,
            AGraphElement[] graphElementsOfFallen8,
            Dictionary<Int32, List<EdgeOnVertexToDo>> edgeTodoOnVertex)
        {
            //if there is no savepoint file... do nothing
            if (!File.Exists(graphElementBunchPath))
            {
                return null;
            }

            var result = new List<EdgeSneakPeak>();

            using (var file = File.Open(graphElementBunchPath, FileMode.Open, FileAccess.Read))
            {
                var reader = new SerializationReader(file);
                var minimumId = reader.ReadInt32();
                var maximumId = reader.ReadInt32();
                var countOfElements = maximumId - minimumId;

                for (var i = 0; i < countOfElements; i++)
                {
                    var kind = reader.ReadInt32();
                    switch (kind)
                    {
                        case SerializedEdge:
                            //edge
                            LoadEdge(reader, graphElementsOfFallen8, ref result);
                            break;

                        case SerializedVertex:
                            //vertex
                            LoadVertex(reader, graphElementsOfFallen8, edgeTodoOnVertex);
                            break;

                        case SerializedNull:
                            //null --> do nothing
                            break;
                    }
                }
            }

            return result;
        }
Example #31
0
 public bool GetAllNeighbors(out ReadOnlyCollection<AGraphElement> result, AGraphElement graphElement)
 {
     if (ReadResource())
     {
         result = new List<AGraphElement>().AsReadOnly();
         IRTreeDataContainer output;
         if (_mapOfContainers.TryGetValue(graphElement.Id, out output))
         {
             result = Searching(output, Intersection, Adjacency);
         }
         FinishReadResource();
         return result.Count > 0;
     }
     throw new CollisionException(this);
 }
Example #32
0
        /// <summary>
        ///   Loads the vertex.
        /// </summary>
        /// <param name='reader'> Reader. </param>
        /// <param name='graphElements'> Graph elements. </param>
        /// <param name='edgeTodo'> Edge todo. </param>
        private static void LoadVertex(SerializationReader reader, AGraphElement[] graphElements,
                                       Dictionary<Int32, List<EdgeOnVertexToDo>> edgeTodo)
        {
            var id = reader.ReadInt32();
            var creationDate = reader.ReadUInt32();
            var modificationDate = reader.ReadUInt32();

            #region properties

            var propertyCount = reader.ReadInt32();
            PropertyContainer[] properties = null;

            if (propertyCount > 0)
            {
                properties = new PropertyContainer[propertyCount];
                for (var i = 0; i < propertyCount; i++)
                {
                    var propertyIdentifier = reader.ReadUInt16();
                    var propertyValue = reader.ReadObject();

                    properties[i] = new PropertyContainer {PropertyId = propertyIdentifier, Value = propertyValue};
                }
            }

            #endregion

            #region edges

            #region outgoing edges

            List<EdgeContainer> outEdgeProperties = null;
            var outEdgeCount = reader.ReadInt32();

            if (outEdgeCount > 0)
            {
                outEdgeProperties = new List<EdgeContainer>(outEdgeCount);
                for (var i = 0; i < outEdgeCount; i++)
                {
                    var outEdgePropertyId = reader.ReadUInt16();
                    var outEdgePropertyCount = reader.ReadInt32();
                    var outEdges = new List<EdgeModel>(outEdgePropertyCount);
                    for (var j = 0; j < outEdgePropertyCount; j++)
                    {
                        var edgeId = reader.ReadInt32();

                            EdgeModel edge = graphElements[edgeId] as EdgeModel;
                            if (edge != null)
                            {
                                outEdges.Add(edge);
                            }
                            else
                            {
                                var aEdgeTodo = new EdgeOnVertexToDo
                                {
                                    VertexId = id,
                                    EdgePropertyId = outEdgePropertyId,
                                    IsIncomingEdge = false
                                };

                                List<EdgeOnVertexToDo> todo;
                                if (edgeTodo.TryGetValue(edgeId, out todo))
                                {
                                    todo.Add(aEdgeTodo);
                                }
                                else
                                {
                                    edgeTodo.Add(edgeId, new List<EdgeOnVertexToDo> { aEdgeTodo });
                                }
                            }
                    }
                    outEdgeProperties.Add(new EdgeContainer(outEdgePropertyId, outEdges));
                }
            }

            #endregion

            #region incoming edges

            List<EdgeContainer> incEdgeProperties = null;
            var incEdgeCount = reader.ReadInt32();

            if (incEdgeCount > 0)
            {
                incEdgeProperties = new List<EdgeContainer>(incEdgeCount);
                for (var i = 0; i < incEdgeCount; i++)
                {
                    var incEdgePropertyId = reader.ReadUInt16();
                    var incEdgePropertyCount = reader.ReadInt32();
                    var incEdges = new List<EdgeModel>(incEdgePropertyCount);
                    for (var j = 0; j < incEdgePropertyCount; j++)
                    {
                        var edgeId = reader.ReadInt32();

                            EdgeModel edge = graphElements[edgeId] as EdgeModel;
                            if (edge != null)
                            {
                                incEdges.Add(edge);
                            }
                            else
                            {
                                var aEdgeTodo = new EdgeOnVertexToDo
                                {
                                    VertexId = id,
                                    EdgePropertyId = incEdgePropertyId,
                                    IsIncomingEdge = true
                                };

                                List<EdgeOnVertexToDo> todo;
                                if (edgeTodo.TryGetValue(edgeId, out todo))
                                {
                                    todo.Add(aEdgeTodo);
                                }
                                else
                                {
                                    edgeTodo.Add(edgeId, new List<EdgeOnVertexToDo> { aEdgeTodo });
                                }
                            }
                    }
                    incEdgeProperties.Add(new EdgeContainer(incEdgePropertyId, incEdges));
                }
            }

            #endregion

            #endregion

            graphElements[id] = new VertexModel(id, creationDate, modificationDate, properties, outEdgeProperties,
                                                     incEdgeProperties);
        }
Example #33
0
        /// <summary>
        ///   Load Fallen-8 from a save point
        /// </summary>
        /// <param name="fallen8">Fallen-8</param>
        /// <param name="graphElements">The graph elements </param>
        /// <param name="pathToSavePoint">The path to the save point.</param>
        /// <param name="currentId">The maximum graph element id</param>
        /// <param name="startServices">Start the services</param>
        internal static Boolean Load(Fallen8 fallen8, ref List<AGraphElement> graphElements, string pathToSavePoint, ref Int32 currentId, Boolean startServices)
        {
            //if there is no savepoint file... do nothing
            if (!File.Exists(pathToSavePoint))
            {
                Logger.LogError(String.Format("Fallen-8 could not be loaded because the path \"{0}\" does not exist.", pathToSavePoint));

                return false;
            }

            var pathName = Path.GetDirectoryName(pathToSavePoint);
            var fileName = Path.GetFileName(pathToSavePoint);

            Logger.LogInfo(String.Format("Now loading file \"{0}\" from path \"{1}\"", fileName, pathName));

            using (var file = File.Open(pathToSavePoint, FileMode.Open, FileAccess.Read))
            {
                var reader = new SerializationReader(file);
                currentId = reader.ReadInt32();

                AGraphElement[] graphElementArray = new AGraphElement[currentId];

                #region graph elements

                //initialize the list of graph elements
                var graphElementStreams = new List<String>();
                var numberOfGraphElemementStreams = reader.ReadInt32();
                for (var i = 0; i < numberOfGraphElemementStreams; i++)
                {
                    var graphElementBunchFilename = Path.Combine(pathName, reader.ReadString());
                    Logger.LogInfo(String.Format("Found graph element bunch {0} here: \"{1}\"", i, graphElementBunchFilename));

                    graphElementStreams.Add(graphElementBunchFilename);
                }

                LoadGraphElements(graphElementArray, graphElementStreams);

                graphElements = new List<AGraphElement>(graphElementArray);

                #endregion

                #region indexe

                var indexStreams = new List<String>();
                var numberOfIndexStreams = reader.ReadInt32();
                for (var i = 0; i < numberOfIndexStreams; i++)
                {
                    var indexFilename = Path.Combine(pathName, reader.ReadString());
                    Logger.LogInfo(String.Format("Found index number {0} here: \"{1}\"", i, indexFilename));

                    indexStreams.Add(indexFilename);
                }
                var newIndexFactory = new IndexFactory();
                LoadIndices(fallen8, newIndexFactory, indexStreams);
                fallen8.IndexFactory = newIndexFactory;

                #endregion

                #region services

                var serviceStreams = new List<String>();
                var numberOfServiceStreams = reader.ReadInt32();
                for (var i = 0; i < numberOfServiceStreams; i++)
                {
                    var serviceFilename = Path.Combine(pathName, reader.ReadString());
                    Logger.LogInfo(String.Format("Found service number {0} here: \"{1}\"", i, serviceFilename));

                    serviceStreams.Add(serviceFilename);
                }
                var newServiceFactory = new ServiceFactory(fallen8);
                fallen8.ServiceFactory = newServiceFactory;
                LoadServices(fallen8, newServiceFactory, serviceStreams, startServices);

                #endregion

                return true;
            }
        }
Example #34
0
        public void AddOrUpdate(Object keyObject, AGraphElement graphElement)
        {
            IComparable key;
            if (!IndexHelper.CheckObject(out key, keyObject))
            {
                return;
            }

            if (WriteResource())
            {
                _idx[key] = graphElement;

                FinishWriteResource();

                return;
            }

            throw new CollisionException(this);
        }
Example #35
0
        public void RemoveValue(AGraphElement graphElement)
        {
            if (WriteResource())
            {
                var toBeRemovedKeys = (from aKv in _idx where ReferenceEquals(aKv.Value, graphElement) select aKv.Key).ToList();

                toBeRemovedKeys.ForEach(_ => _idx.Remove(_));

                FinishWriteResource();

                return;
            }

            throw new CollisionException(this);
        }
Example #36
0
        /// <summary>
        ///   Load Fallen-8 from a save point
        /// </summary>
        /// <param name="fallen8">Fallen-8</param>
        /// <param name="graphElements">The graph elements </param>
        /// <param name="pathToSavePoint">The path to the save point.</param>
        /// <param name="currentId">The maximum graph element id</param>
        /// <param name="startServices">Start the services</param>
        internal static Boolean Load(Fallen8 fallen8, ref List <AGraphElement> graphElements, string pathToSavePoint, ref Int32 currentId, Boolean startServices)
        {
            //if there is no savepoint file... do nothing
            if (!File.Exists(pathToSavePoint))
            {
                Logger.LogError(String.Format("Fallen-8 could not be loaded because the path \"{0}\" does not exist.", pathToSavePoint));

                return(false);
            }

            var pathName = Path.GetDirectoryName(pathToSavePoint);
            var fileName = Path.GetFileName(pathToSavePoint);

            Logger.LogInfo(String.Format("Now loading file \"{0}\" from path \"{1}\"", fileName, pathName));

            using (var file = File.Open(pathToSavePoint, FileMode.Open, FileAccess.Read))
            {
                var reader = new SerializationReader(file);
                currentId = reader.ReadInt32();

                AGraphElement[] graphElementArray = new AGraphElement[currentId];

                #region graph elements

                //initialize the list of graph elements
                var graphElementStreams           = new List <String>();
                var numberOfGraphElemementStreams = reader.ReadInt32();
                for (var i = 0; i < numberOfGraphElemementStreams; i++)
                {
                    var graphElementBunchFilename = Path.Combine(pathName, reader.ReadString());
                    Logger.LogInfo(String.Format("Found graph element bunch {0} here: \"{1}\"", i, graphElementBunchFilename));

                    graphElementStreams.Add(graphElementBunchFilename);
                }

                LoadGraphElements(graphElementArray, graphElementStreams);

                graphElements = new List <AGraphElement>(graphElementArray);

                #endregion

                #region indexe

                var indexStreams         = new List <String>();
                var numberOfIndexStreams = reader.ReadInt32();
                for (var i = 0; i < numberOfIndexStreams; i++)
                {
                    var indexFilename = Path.Combine(pathName, reader.ReadString());
                    Logger.LogInfo(String.Format("Found index number {0} here: \"{1}\"", i, indexFilename));

                    indexStreams.Add(indexFilename);
                }
                var newIndexFactory = new IndexFactory();
                LoadIndices(fallen8, newIndexFactory, indexStreams);
                fallen8.IndexFactory = newIndexFactory;

                #endregion

                #region services

                var serviceStreams         = new List <String>();
                var numberOfServiceStreams = reader.ReadInt32();
                for (var i = 0; i < numberOfServiceStreams; i++)
                {
                    var serviceFilename = Path.Combine(pathName, reader.ReadString());
                    Logger.LogInfo(String.Format("Found service number {0} here: \"{1}\"", i, serviceFilename));

                    serviceStreams.Add(serviceFilename);
                }
                var newServiceFactory = new ServiceFactory(fallen8);
                fallen8.ServiceFactory = newServiceFactory;
                LoadServices(fallen8, newServiceFactory, serviceStreams, startServices);

                #endregion

                return(true);
            }
        }
Example #37
0
        public void AddOrUpdate(Object keyObject, AGraphElement graphElement)
        {
            IGeometry key;
            if (!IndexHelper.CheckObject(out key, keyObject))
            {
                return;
            }

            if (WriteResource())
            {
                if (DimensionTest(key.Dimensions) && TestOfGeometry(key))
                {
                    if (!_mapOfContainers.ContainsKey(graphElement.Id))
                    {
                        IRTreeDataContainer currentContainer;

                        if (key is IPoint)
                        {
                            var coordinations = ((IPoint)key).PointToSpaceR();
                            currentContainer = new PointDataContainer(coordinations) {GraphElement = graphElement};

                        }
                        else
                        {
                            var mbr = key.GeometryToMBR();
                            currentContainer = new SpatialDataContainer(mbr.Lower, mbr.Upper)
                                                   {GraphElement = graphElement};
                        }

                        InsertData(currentContainer);
                        _mapOfContainers.Add(graphElement.Id, currentContainer);

                    }
                    else
                    {
                        RemoveValue(graphElement);
                        AddOrUpdate(key, graphElement);
                    }

                }
                FinishWriteResource();
                return;
            }
            throw new CollisionException(this);
        }
Example #38
0
        public Boolean TryGetGraphElement(out AGraphElement result, Int32 id)
        {
            if (ReadResource())
            {
                result = _graphElements.GetElement(id);

                FinishReadResource();

                return result != null;
            }

            throw new CollisionException();
        }
Example #39
0
        /// <summary>
        /// Gets a value from the index
        /// </summary>
        /// <param name="result">Result</param>
        /// <param name="key">Key</param>
        /// <returns>
        /// <c>true</c> if something was found; otherwise, <c>false</c>.
        /// </returns>
        public bool TryGetValue(out AGraphElement result, IComparable key)
        {
            if (ReadResource())
            {
                var value = _idx.TryGetValue(key, out result);

                FinishReadResource();

                return value;
            }

            throw new CollisionException(this);
        }
Example #40
0
        public bool GetNextNeighbors(out ReadOnlyCollection<AGraphElement> result, AGraphElement graphElement, int countOfNextNeighbors)
        {
            if (ReadResource())
            {
                result = new List<AGraphElement>().AsReadOnly();
                IRTreeDataContainer output;
                if (_mapOfContainers.TryGetValue(graphElement.Id, out output))
                {
                    var containers = new LinkedList<Tuple<float, IRTreeDataContainer>>();
                    var elements = ((RTreeLeaf)output.Parent).Data;
                    var parent = (RTreeLeaf)output.Parent;
                    var maxElement = float.PositiveInfinity;
                    foreach (var value in elements)
                    {
                        var dist = Distance(output, value);
                        if ((containers.Count < countOfNextNeighbors || dist < maxElement) && value != output)
                        {
                            if (containers.Count == 0)
                            {
                                containers.AddFirst(new LinkedListNode<Tuple<float, IRTreeDataContainer>>(Tuple.Create(dist, value)));
                                maxElement = dist;
                            }
                            else
                            {
                                var end = true;
                                var start = containers.First;
                                while (end)
                                {

                                    if (dist < start.Value.Item1)
                                    {
                                        containers.AddBefore(start, Tuple.Create(dist, value));
                                        if (containers.Count > countOfNextNeighbors)
                                        {
                                            containers.RemoveLast();
                                            maxElement = containers.Last.Value.Item1;
                                        }
                                        break;
                                    }
                                    if (start == containers.Last)
                                    {
                                        end = false;
                                    }
                                    else
                                    {
                                        start = start.Next;
                                    }
                                }
                                if (!end && containers.Count < countOfNextNeighbors)
                                {
                                    maxElement = dist;
                                    containers.AddLast(Tuple.Create(dist, value));
                                }

                            }
                        }
                    }
                    var stack = new Stack<ARTreeContainer>();
                    if (Distance(_root, output) < maxElement || containers.Count < countOfNextNeighbors)
                        stack.Push(_root);
                    while (stack.Count > 0)
                    {
                        var currentContainer = stack.Pop();

                        if (!currentContainer.IsLeaf)
                        {
                            foreach (var value2 in ((RTreeNode)currentContainer).Children)
                            {
                                if (Distance(value2, output) < maxElement || containers.Count < countOfNextNeighbors)
                                    stack.Push(value2);
                            }
                        }
                        else
                        {
                            if (currentContainer != parent)
                                foreach (var value2 in ((RTreeLeaf)currentContainer).Data)
                                {
                                    var dist = Distance(value2, output);

                                    if ((containers.Count < countOfNextNeighbors || dist < maxElement) && value2 != output)
                                    {
                                        if (containers.Count == 0)
                                        {
                                            containers.AddFirst(new LinkedListNode<Tuple<float, IRTreeDataContainer>>(Tuple.Create(dist, value2)));
                                            maxElement = dist;
                                        }
                                        else
                                        {
                                            var end = true;
                                            var start = containers.First;
                                            while (end)
                                            {

                                                if (dist < start.Value.Item1)
                                                {
                                                    containers.AddBefore(start, Tuple.Create(dist, value2));
                                                    if (containers.Count > countOfNextNeighbors)
                                                    {
                                                        containers.RemoveLast();
                                                        maxElement = containers.Last.Value.Item1;
                                                    }
                                                    break;
                                                }
                                                if (start == containers.Last)
                                                {
                                                    end = false;
                                                }
                                                else
                                                {
                                                    start = start.Next;
                                                }
                                            }
                                            if (!end && containers.Count < countOfNextNeighbors)
                                            {
                                                maxElement = dist;
                                                containers.AddLast(Tuple.Create(dist, value2));
                                            }
                                        }
                                    }
                                }
                        }

                    }
                    result = containers.Select(_ => _.Item2.GraphElement).ToList().AsReadOnly();
                }
                FinishReadResource();
                return result.Count > 0;

            }
            throw new CollisionException(this);
        }
Example #41
0
 /// <summary>
 /// find all object which distance less or equal d from this element of graph have
 /// </summary>
 /// <param name="result">
 /// result
 /// </param>
 /// <param name="distance">
 /// value of distance for serching
 /// </param>
 /// <param name="graphElement">
 /// element of graph
 /// </param>
 /// <returns>
 /// <c>true</c> if something was found; otherwise, <c>false</c>.
 /// </returns>
 public bool SearchDistance(out ReadOnlyCollection<AGraphElement> result, float distance, AGraphElement graphElement)
 {
     if (ReadResource())
     {
         result = new List<AGraphElement>().AsReadOnly(); IRTreeDataContainer element;
         SpatialDataContainer searchContainer;
         if (_mapOfContainers.TryGetValue(graphElement.Id, out element))
         {
             searchContainer = CreateSearchContainer(element, distance);
             result = OverlapSearch(searchContainer);
         }
         FinishReadResource();
         return result.Count > 0;
     }
     throw new CollisionException(this);
 }
Example #42
0
        public bool TryRemoveGraphElement(Int32 graphElementId)
        {
            if (WriteResource())
            {
                AGraphElement graphElement = _graphElements[graphElementId];

                if (graphElement == null)
                {
                    FinishWriteResource();

                    return(false);
                }

                //used if an edge is removed
                List <UInt16> inEdgeRemovals  = null;
                List <UInt16> outEdgeRemovals = null;

                try
                {
                    #region remove element

                    _graphElements[graphElementId] = null;

                    if (graphElement is VertexModel)
                    {
                        #region remove vertex

                        var vertex = (VertexModel)graphElement;

                        #region out edges

                        var outgoingEdgeConatiner = vertex.GetOutgoingEdges();
                        if (outgoingEdgeConatiner != null)
                        {
                            for (var i = 0; i < outgoingEdgeConatiner.Count; i++)
                            {
                                var aOutEdgeContainer = outgoingEdgeConatiner[i];
                                for (var j = 0; j < aOutEdgeContainer.Edges.Count; j++)
                                {
                                    var aOutEdge = aOutEdgeContainer.Edges[j];

                                    //remove from incoming edges of target vertex
                                    aOutEdge.TargetVertex.RemoveIncomingEdge(aOutEdgeContainer.EdgePropertyId, aOutEdge);

                                    //remove the edge itself
                                    _graphElements[aOutEdge.Id] = null;
                                }
                            }
                        }

                        #endregion

                        #region in edges

                        var incomingEdgeContainer = vertex.GetIncomingEdges();
                        if (incomingEdgeContainer != null)
                        {
                            for (var i = 0; i < incomingEdgeContainer.Count; i++)
                            {
                                var aInEdgeContainer = incomingEdgeContainer[i];
                                for (var j = 0; j < aInEdgeContainer.Edges.Count; j++)
                                {
                                    var aInEdge = aInEdgeContainer.Edges[j];

                                    //remove from outgoing edges of source vertex
                                    aInEdge.SourceVertex.RemoveOutGoingEdge(aInEdgeContainer.EdgePropertyId, aInEdge);

                                    //remove the edge itself
                                    _graphElements[aInEdge.Id] = null;
                                }
                            }
                        }

                        #endregion

                        //update the EdgeCount --> hard way
                        RecalculateGraphElementCounter();

                        #endregion
                    }
                    else
                    {
                        #region remove edge

                        var edge = (EdgeModel)graphElement;

                        //remove from incoming edges of target vertex
                        inEdgeRemovals = edge.TargetVertex.RemoveIncomingEdge(edge);

                        //remove from outgoing edges of source vertex
                        outEdgeRemovals = edge.SourceVertex.RemoveOutGoingEdge(edge);

                        //update the EdgeCount --> easy way
                        EdgeCount--;

                        #endregion
                    }

                    #endregion
                }
                catch (Exception)
                {
                    #region restore

                    _graphElements.Insert(graphElementId, graphElement);

                    if (graphElement is VertexModel)
                    {
                        #region restore vertex

                        var vertex = (VertexModel)graphElement;

                        #region out edges

                        var outgoingEdgeConatiner = vertex.GetOutgoingEdges();
                        if (outgoingEdgeConatiner != null)
                        {
                            for (var i = 0; i < outgoingEdgeConatiner.Count; i++)
                            {
                                var aOutEdgeContainer = outgoingEdgeConatiner[i];
                                for (var j = 0; j < aOutEdgeContainer.Edges.Count; j++)
                                {
                                    var aOutEdge = aOutEdgeContainer.Edges[j];

                                    //remove from incoming edges of target vertex
                                    aOutEdge.TargetVertex.AddIncomingEdge(aOutEdgeContainer.EdgePropertyId, aOutEdge);

                                    //reset the edge
                                    _graphElements.Insert(aOutEdge.Id, aOutEdge);
                                }
                            }
                        }

                        #endregion

                        #region in edges

                        var incomingEdgeContainer = vertex.GetIncomingEdges();
                        if (incomingEdgeContainer != null)
                        {
                            for (var i = 0; i < incomingEdgeContainer.Count; i++)
                            {
                                var aInEdgeContainer = incomingEdgeContainer[i];
                                for (var j = 0; j < aInEdgeContainer.Edges.Count; j++)
                                {
                                    var aInEdge = aInEdgeContainer.Edges[j];

                                    //remove from outgoing edges of source vertex
                                    aInEdge.SourceVertex.AddOutEdge(aInEdgeContainer.EdgePropertyId, aInEdge);

                                    //reset the edge
                                    _graphElements.Insert(aInEdge.Id, aInEdge);
                                }
                            }
                        }

                        #endregion

                        #endregion
                    }
                    else
                    {
                        #region restore edge

                        var edge = (EdgeModel)graphElement;

                        if (inEdgeRemovals != null)
                        {
                            for (var i = 0; i < inEdgeRemovals.Count; i++)
                            {
                                edge.TargetVertex.AddIncomingEdge(inEdgeRemovals[i], edge);
                            }
                        }

                        if (outEdgeRemovals != null)
                        {
                            for (var i = 0; i < outEdgeRemovals.Count; i++)
                            {
                                edge.SourceVertex.AddOutEdge(outEdgeRemovals[i], edge);
                            }
                        }

                        #endregion
                    }

                    //recalculate the counter
                    RecalculateGraphElementCounter();

                    #endregion

                    throw;
                }

                FinishWriteResource();

                return(true);
            }

            throw new CollisionException(this);
        }
Example #43
0
        public void RemoveValue(AGraphElement graphElement)
        {
            if (WriteResource())
            {
                IRTreeDataContainer dataContainer;
                if (_mapOfContainers.TryGetValue(graphElement.Id, out dataContainer))
                {
                    ((RTreeLeaf)dataContainer.Parent).Data.Remove(dataContainer);
                    RecalculationByRemoving(dataContainer);
                    _mapOfContainers.Remove(graphElement.Id);
                    if (((RTreeLeaf)dataContainer.Parent).Data.Count < MinCountOfNode)
                    {

                        LocalReorganisationByRemoving(dataContainer.Parent, _levelForOverflowStrategy.Count - 1);
                    }
                }

                FinishWriteResource();

                return;
            }
            throw new CollisionException(this);
        }
Example #44
0
        public float Distance(AGraphElement graphElement1, AGraphElement graphElement2)
        {
            if (ReadResource())
            {
                IRTreeDataContainer container1;
                IRTreeDataContainer container2;
                if (_mapOfContainers.TryGetValue(graphElement1.Id, out container1) &&
                    _mapOfContainers.TryGetValue(graphElement2.Id, out container2))
                {
                    FinishReadResource();
                    return Distance(container1, container2);
                }

                FinishReadResource();
                return float.NaN;
            }
            throw new CollisionException(this);
        }
 /// <summary>
 /// Create a new FulltextSearchResultElement instance
 /// </summary>
 /// <param name="graphElement">Graph element</param>
 /// <param name="score">Score</param>
 /// <param name="highlights">Highlights</param>
 public FulltextSearchResultElement(AGraphElement graphElement, Double score, IEnumerable <String> highlights = null)
 {
     GraphElement = graphElement;
     Score        = score;
     Highlights   = highlights == null ? new List <string>() : new List <string>(highlights);
 }
Example #46
0
        public void AddOrUpdate(Object keyObject, AGraphElement graphElement)
        {
            IComparable key;
            if (!IndexHelper.CheckObject(out key, keyObject))
            {
                return;
            }

            if (WriteResource())
            {
                try
                {

                    List<AGraphElement> values;
                    if (_idx.TryGetValue(key, out values))
                    {
                        values.Add(graphElement);
                    }
                    else
                    {
                        values = new List<AGraphElement> { graphElement };
                        _idx.Add(key, values);
                    }
                }
                finally
                {
                    FinishWriteResource();
                }

                return;
            }

            throw new CollisionException(this);
        }
Example #47
0
        public bool Overlap(out ReadOnlyCollection<AGraphElement> result, AGraphElement graphElement)
        {
            if (ReadResource())
            {
                result = new List<AGraphElement>().AsReadOnly();
                IRTreeDataContainer output;
                if (_mapOfContainers.TryGetValue(graphElement.Id, out output))
                {
                    result = OverlapSearch(output);
                }

                FinishReadResource();
                return result.Count > 0;
            }
            throw new CollisionException(this);
        }
Example #48
0
 private static void CheckIfAGraphElementsAreEqual(AGraphElement aReference, AGraphElement pendant)
 {
     Assert.AreEqual(aReference.Id, pendant.Id);
     Assert.AreEqual(aReference.CreationDate, pendant.CreationDate);
     Assert.AreEqual(aReference.ModificationDate, pendant.ModificationDate);
 }
Example #49
0
        /// <summary>
        ///   Loads the edge.
        /// </summary>
        /// <param name='reader'> Reader. </param>
        /// <param name='graphElements'> Graph elements. </param>
        /// <param name='sneakPeaks'> Sneak peaks. </param>
        private static void LoadEdge(SerializationReader reader, AGraphElement[] graphElements,
                                     ref List<EdgeSneakPeak> sneakPeaks)
        {
            var id = reader.ReadInt32();
            var creationDate = reader.ReadUInt32();
            var modificationDate = reader.ReadUInt32();

            #region properties

            PropertyContainer[] properties = null;
            var propertyCount = reader.ReadInt32();

            if (propertyCount > 0)
            {
                properties = new PropertyContainer[propertyCount];
                for (var i = 0; i < propertyCount; i++)
                {
                    var propertyIdentifier = reader.ReadUInt16();
                    var propertyValue = reader.ReadObject();

                    properties[i] = new PropertyContainer {PropertyId = propertyIdentifier, Value = propertyValue};
                }
            }

            #endregion

            var sourceVertexId = reader.ReadInt32();
            var targetVertexId = reader.ReadInt32();

            VertexModel sourceVertex = graphElements[sourceVertexId] as VertexModel;
            VertexModel targetVertex = graphElements[targetVertexId] as VertexModel;

            if (sourceVertex != null && targetVertex != null)
            {
                graphElements[id] = new EdgeModel(id, creationDate, modificationDate, targetVertex,sourceVertex, properties);
            }
            else
            {
                sneakPeaks.Add(new EdgeSneakPeak
                                   {
                                       CreationDate = creationDate,
                                       Id = id,
                                       ModificationDate = modificationDate,
                                       Properties = properties,
                                       SourceVertexId = sourceVertexId,
                                       TargetVertexId = targetVertexId
                                   });
            }
        }