From 576b92fd82f568572bc4beb125fa0ba0191a602f Mon Sep 17 00:00:00 2001
From: asmrobot <asmrobot@hotmail.com>
Date: Wed, 13 Nov 2019 14:59:52 +0000
Subject: [PATCH] add map editor

---
 src/RichCreator.Utility/PathFinding/Dijkstra.cs |   46 +++++++++++++++++++++++-----------------------
 1 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/src/RichCreator.Utility/PathFinding/Dijkstra.cs b/src/RichCreator.Utility/PathFinding/Dijkstra.cs
index 0a06952..57a0756 100644
--- a/src/RichCreator.Utility/PathFinding/Dijkstra.cs
+++ b/src/RichCreator.Utility/PathFinding/Dijkstra.cs
@@ -8,49 +8,49 @@
 {
     public class Dijkstra<T> where T : IEquatable<T>
     {
-        private Dictionary<T, Dictionary<T, Int32>> vertices = new Dictionary<T, Dictionary<T, Int32>>();
+        private Dictionary<T, Dictionary<T, Int32>> edges = new Dictionary<T, Dictionary<T, Int32>>();
 
         /// <summary>
         /// 添加顶点
         /// </summary>
-        /// <param name="name">顶点名称</param>
-        /// <param name="edges">顶点所有的边</param>
-        public void AddVertex(T name, Dictionary<T, Int32> edges)
+        /// <param name="vertice">顶点名称</param>
+        /// <param name="targetVertice">顶点所有的边</param>
+        public void AddEdge(T vertice, Dictionary<T, Int32> targetVertice)
         {
-            foreach (var item in edges)
+            foreach (var item in targetVertice)
             {
-                AddVertex(name, item.Key, item.Value);
+                AddEdge(vertice, item.Key, item.Value);
             }
         }
 
         /// <summary>
         /// 添加顶点
         /// </summary>
-        /// <param name="name">顶点名称</param>
-        /// <param name="target">可连接顶点</param>
+        /// <param name="vertice">顶点名称</param>
+        /// <param name="targetVertice">可连接顶点</param>
         /// <param name="weight">权重</param>
-        public void AddVertex(T name, T target, Int32 weight)
+        public void AddEdge(T vertice, T targetVertice, Int32 weight)
         {
-            if (!this.vertices.ContainsKey(name))
+            if (!this.edges.ContainsKey(vertice))
             {
-                this.vertices.Add(name, new Dictionary<T, Int32>());
+                this.edges.Add(vertice, new Dictionary<T, Int32>());
             }
 
-            if (!this.vertices[name].ContainsKey(target))
+            if (!this.edges[vertice].ContainsKey(targetVertice))
             {
-                this.vertices[name].Add(target, weight);
+                this.edges[vertice].Add(targetVertice, weight);
             }
 
 
-            if (!this.vertices.ContainsKey(target))
+            if (!this.edges.ContainsKey(targetVertice))
             {
-                this.vertices.Add(target, new Dictionary<T, Int32>());
+                this.edges.Add(targetVertice, new Dictionary<T, Int32>());
             }
 
 
-            if (!this.vertices[target].ContainsKey(name))
+            if (!this.edges[targetVertice].ContainsKey(vertice))
             {
-                this.vertices[target].Add(name, weight);
+                this.edges[targetVertice].Add(vertice, weight);
             }
 
         }
@@ -59,14 +59,14 @@
         /// 移除顶点
         /// </summary>
         /// <param name="name"></param>
-        public void RemoveVertex(T name)
+        public void RemoveEdge(T name)
         {
-            if (this.vertices.ContainsKey(name))
+            if (this.edges.ContainsKey(name))
             {
                 return;
             }
-            this.vertices.Remove(name);
-            foreach (var item in this.vertices)
+            this.edges.Remove(name);
+            foreach (var item in this.edges)
             {
                 if (item.Value.ContainsKey(name))
                 {
@@ -93,7 +93,7 @@
 
             List<T> path = null;
 
-            foreach (var vertex in vertices)
+            foreach (var vertex in edges)
             {
                 if (vertex.Key.Equals(start))
                 {
@@ -134,7 +134,7 @@
                     break;
                 }
 
-                foreach (var neighbor in vertices[smallest])
+                foreach (var neighbor in edges[smallest])
                 {
                     var alt = distances[smallest] + neighbor.Value;
                     if (alt < distances[neighbor.Key])

--
Gitblit v1.9.3