コード例 #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
 }
コード例 #2
0
		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
ファイル: Graph.cs プロジェクト: steve-westwood/NodePath
		public Graph(Vertex[] nodes)
		{
			_nodes = nodes;
		}