Пример #1
0
 private void Search(Vertex v, int destinationId)
 {
     _visitedNodes.Add(v.ID);
     _currentPath.Add(v.ID);
     foreach (Edge e in v.Edges)
     {
         if (e.DestinationID == destinationId)
         {
             // do not mark destination as visited
             // this allows search to reach destination via different routes
             // add current path to successful paths (fake last step!)
             _currentPath.Add(e.DestinationID);
             _successfulPaths.Add(_currentPath.ToList());
             _currentPath.Remove(e.DestinationID); //reverse
         }
         else
         {
             if (!_visitedNodes.Contains(e.DestinationID))
             {
                 var w = (from n in _nodes
                     where n.ID == e.DestinationID
                     select n).FirstOrDefault();
                 Search(w, destinationId);
             }
         }
     }
     _currentPath.Remove(v.ID); //reverse
 }
		public IHttpActionResult Save(Vertex[] vertices)
		{
			try
			{
				_service.SaveVertices(vertices);
				return Ok();
			}
			catch (Exception ex)
			{
				return BadRequest(ex.Message);
			}
		}
Пример #3
0
		public void SaveVertices(Vertex[] vertices)
		{
			DeleteAllVertices();
			using (ISession dbSession = _repository.OpenSession())
			{
				foreach (var v in vertices)
				{
					using (var transaction = dbSession.BeginTransaction())
					{
						dbSession.Save(v);
						transaction.Commit();
					}
				}
			}
		}
Пример #4
0
 public DepthFirstSearch(Vertex[] nodes)
 {
     _nodes = nodes;
 }
Пример #5
0
		public Graph(Vertex[] nodes)
		{
			_nodes = nodes;
		}