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 <PointString> roads) { NetworkCleaner cleaner = new NetworkCleaner(roads); List <PointString> divs = cleaner.GetAllDivs(); divPolys = divs; List <Edge> edges = divs.Select(v => new Edge() { StartPoint = new Position(v.Points.First().X, v.Points.First().Y), EndPoint = new Position(v.Points.Last().X, v.Points.Last().Y), Length = v.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) { Position pos = _position; _edges = topoNet.Edges.Where(x => x.StartPoint.Equals(pos) || x.EndPoint.Equals(pos)).ToList <Edge>(); }