Beispiel #1
0
        public NetworkPath DijkstraPath(int endNodeId)
        {
            NetworkPath path = new NetworkPath();

            if (_dNodes == null)
            {
                return(path);
            }
            Node endNode = _dNodes.ById(endNodeId);

            if (endNode == null)
            {
                return(path);
            }

            while (endNode != null)
            {
                if (endNode.EId > 0)
                {
                    path.Insert(0, new NetworkPathEdge(endNode.EId));
                }
                endNode = _dNodes.ById(endNode.Pre);
            }

            return(path);
        }
Beispiel #2
0
        public NetworkPath DijkstraPath(Nodes nodes)
        {
            NetworkPath path = new NetworkPath(true);

            if (nodes == null || _dNodes == null)
            {
                return(path);
            }

            foreach (Node node in nodes)
            {
                Node endNode = _dNodes.ById(node.Id);

                while (endNode != null)
                {
                    if (endNode.EId > 0)
                    {
                        path.Insert(0, new NetworkPathEdge(endNode.EId));
                    }
                    endNode = _dNodes.ById(endNode.Pre);
                }
            }
            return(path);
        }