public BestPathMatrix(TopoNetwork topoNet) { TopoNet = topoNet; Matrix = new double[MatrixLevel, MatrixLevel]; PathMatrix = new int[MatrixLevel, MatrixLevel]; MaxIterationStep = (int)Math.Floor(Math.Log10(MatrixLevel - 1) / Math.Log10(2)) + 1; InitializeMatrix(); }
//改进 /// <summary> /// 获取一条边的另一点. /// </summary> /// <param name="oneNode">已知点</param> /// <param name="topo">拓扑网络</param> /// <returns></returns> public Node GetTheOtherNode(Node oneNode, TopoNetwork topo) { if (oneNode.Position.Equals(StartPoint)) { return(topo.Nodes.Single(x => x.Position.Equals(EndPoint))); } else if (oneNode.Position.Equals(EndPoint)) { return(topo.Nodes.Single(x => x.Position.Equals(StartPoint))); } return(new Node()); }
public PathFinder(List <Polyline> roads) { NetworkCleaner cleaner = new NetworkCleaner(roads); List <Polyline> divs = cleaner.GetAllDivs(); divPolys = divs; List <Edge> edges = divs.Select(x => new Edge() { StartPoint = new Point(x.Points.First().x, x.Points.First().y), EndPoint = new Point(x.Points.Last().x, x.Points.Last().y), Length = x.Length, ResistanceFactor = 1 }).ToList(); network = new TopoNetwork(edges); matrix = new BestPathMatrix(network); matrix.CalculateMatrix(); }
//改进 /// <summary> /// 沿一条边前进,获取下一点. /// </summary> /// <param name="overThisEdge">沿哪一条边</param> /// <param name="topo">拓扑网络</param> /// <returns></returns> public Node NextNode(Edge overThisEdge, TopoNetwork topo) { return(overThisEdge.GetTheOtherNode(this, topo)); }
//改进 /// <summary> /// 求解该点发出的所有边. /// </summary> /// <param name="topoNet">拓扑网络</param> public void FindEdges(TopoNetwork topoNet) { Point pos = _position; _edges = topoNet.Edges.Where(x => x.StartPoint.Equals(pos) || x.EndPoint.Equals(pos)).ToList <Edge>(); }