Browse Source

xls:数据信息调整

xulisong 6 years ago
parent
commit
49a0e82520

+ 32 - 2
MBI/SAGA.DotNetUtils/Data/EdgesArray/EAEdge.cs

@@ -38,14 +38,40 @@ namespace SAGA.DotNetUtils.Data
         /// 边类型
         /// </summary>
         public EAEdgeType EdgeType { get; set; }
+
+        private string m_StartVertex;
         /// <summary>
         /// 开始点
         /// </summary>
-        public string StartVertex { get; set; }
+        public string StartVertex
+        {
+            get { return m_StartVertex;}
+            set
+            {
+                if (ValidId)
+                {
+                    throw new Exception("确定id的点不能修改");
+                }
+                m_StartVertex = value;
+            }
+        }
+
+        private string m_EndVertex;
         /// <summary>
         /// 结束点
         /// </summary>
-        public string EndVertex { get; set; }
+        public string EndVertex
+        {
+            get { return m_EndVertex; }
+            set
+            {
+                if (ValidId)
+                {
+                    throw new Exception("确定id的点不能修改");
+                }
+                m_EndVertex = value;
+            }
+        }
         #endregion
 
         #region 边提供方法
@@ -84,5 +110,9 @@ namespace SAGA.DotNetUtils.Data
             EndVertex = tempId;
         }
         #endregion
+
+        #region 缓存相关数据
+
+        #endregion
     }
 }

+ 2 - 6
MBI/SAGA.DotNetUtils/Data/EdgesArray/EAElement.cs

@@ -109,15 +109,11 @@ namespace SAGA.DotNetUtils.Data
         /// <returns></returns>
         public virtual bool IsMatch(EAElement<T> ea)
         {
-            if (ea == null)
+            if (ea == null|| !ValidId)
             {
                 return false;
             }
-            if (Id == ea.Id)
-            {
-                return true;
-            }
-            return this.Equals(ea);
+            return Id == ea.Id || this.Equals(ea);
         }       
     }
     #region 节点集合类

+ 2 - 2
MBI/SAGA.DotNetUtils/Data/EdgesArray/EAVertex.cs

@@ -20,7 +20,7 @@ namespace SAGA.DotNetUtils.Data
         /// </summary>
         /// <param name="data"></param>
         /// <returns></returns>
-        public virtual bool DataEqual(T data)
+        public virtual bool DataEquals(T data)
         {
             
             if (Data==null||data == null)
@@ -36,7 +36,7 @@ namespace SAGA.DotNetUtils.Data
                 EAVertex<T> refV = ea as EAVertex<T>;
                 if (refV != null)
                 {
-                    flag = DataEqual(refV.Data);
+                    flag = DataEquals(refV.Data);
                 }             
             }
             return flag;

+ 0 - 223
MBI/SAGA.DotNetUtils/Data/EdgesArray/EdgesArray.cs

@@ -1,223 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-namespace SAGA.DotNetUtils.Data
-{
-    #region 概述
-    /*
-     * 有向图,和无向图,部分方法不同;
-     * 
-     * 内部操作使用索引;功能扩展使用Data
-     */ 
-    #endregion
-    /// <summary>
-    /// 边集列表
-    /// </summary>
-    public  class EdgesArray<V,VD,E,ED> : BaseEdgesArray<V, VD, E, ED> where V : EAVertex<VD> where E : EAEdge<ED>
-    {
-        public EdgesArray()
-        {
-          
-        }
-        #region 控制属性
-        /// <summary>
-        /// 表示该图信息是否是有向的
-        /// </summary>
-        public bool IsDirection { get; set; }
-        #endregion
-        #region 编号系统
-        private int m_CurrentVertexIndex;
-        /// <summary>
-        /// 生成节点索引
-        /// </summary>
-        /// <returns></returns>
-        private string GenerateVertexIndex()
-        {
-            return "V" + (++m_CurrentVertexIndex);
-        }
-        /// <summary>
-        /// 生成节点索引
-        /// </summary>
-        /// <returns></returns>
-        private string GenerateEdgeIndex()
-        {
-            return "E" + (++m_CurrentVertexIndex);
-        }
-        #endregion
-
-        #region 点操作
-        /// <summary>
-        /// 增加顶点
-        /// </summary>
-        /// <param name="vertex"></param>
-        /// <returns></returns>
-        public virtual V AddVertex(V vertex)
-        {
-            if (vertex == null)
-                return null;
-            V result = vertex;
-            var useVertex = FindVertex(vertex);
-            if (useVertex == null)
-            {
-                vertex.Id = GenerateVertexIndex();
-                this.m_Vertexes.Add(vertex);
-            }
-            else
-            {
-                useVertex.Merge(vertex);
-                result = useVertex;
-            }     
-            return result;
-        }
-
-        /// <summary>
-        /// 根据顶点Id查询相应的节点
-        /// </summary>
-        /// <param name="vertexId"></param>
-        /// <returns></returns>
-        public virtual V FindVertex(string vertexId)
-        {
-            if (string.IsNullOrWhiteSpace(vertexId))
-            {
-                return null;
-            }
-            if (this.m_Vertexes.Contains(vertexId))
-            {
-                return this.m_Vertexes[vertexId];
-            }
-            return null ;
-        }
-        /// <summary>
-        /// 根据顶点Id查询相应的节点
-        /// </summary>
-        /// <param name="v">根据顶点信息去检索点</param>
-        /// <returns></returns>
-        public virtual V FindVertex(V v)
-        {
-            /*
-             * 待改进:id快索引,IsMatch值匹配慢索引
-             */
-            var useV = FindVertex(v.Id);
-            if(useV==null)
-            {
-                useV= this.Vertexes.FirstOrDefault(c =>c.IsMatch(v));
-            }
-            return useV;
-        }
-        /// <summary>
-        /// 根据Id移除节点
-        /// </summary>
-        /// <param name="vertexId"></param>
-        /// <returns></returns>
-        public virtual bool RemoveVertex(string vertexId)
-        {
-            var realRemove = this.m_Vertexes.Remove(vertexId);
-            if (realRemove)
-            {
-                //移除节点需要移除相应的边
-            }
-            return realRemove;
-        }
-        /// <summary>
-        /// 隐藏点
-        /// </summary>
-        /// <param name="vertexId"></param>
-        public virtual void HideVertex(string vertexId)
-        {
-
-        }
-        /// <summary>
-        /// 合并关联的点
-        /// </summary>
-        /// <param name="vs"></param>
-        /// <returns></returns>
-        public virtual V CombineVertexes(List<V> vs)
-        {
-            return null;
-        }
-        #endregion
-
-        #region 边操作
-        public E GetEdge(string edgeId)
-        {
-            if (this.m_Edges.Contains(edgeId))
-            {
-                return m_Edges[edgeId];
-            }
-            return null;
-        }
-        /// <summary>
-        /// 增加边
-        /// </summary>
-        /// <param name="edge"></param>
-        /// <returns></returns>
-        public virtual E AddEdge(E edge)
-        {
-            var start = FindVertex(edge.StartVertex);
-            if (start == null)
-                throw new Exception("start元素必须在图中");
-            var end = FindVertex(edge.EndVertex);
-            if (end == null)
-                throw new Exception("end元素必须在图中");
-            edge.Id = GenerateEdgeIndex();
-            this.m_Edges.Add(edge);
-            return edge;
-        }
-        /// <summary>
-        /// 增加边信息
-        /// </summary>
-        /// <param name="start"></param>
-        /// <param name="end"></param>
-        /// <param name="edge"></param>
-        /// <returns></returns>
-        public virtual E AddEdge(V start, V end, E edge)
-        {
-            var startV = AddVertex(start);
-            if (startV == null)
-            {
-                throw new Exception("start不能为null");
-            }
-            var endV = AddVertex(end);
-            if (endV == null)
-            {
-                throw new Exception("end不能为null");
-            }
-            edge.StartVertex =startV.Id;
-            edge.EndVertex = endV.Id;
-            edge.Id = GenerateEdgeIndex();
-            this.m_Edges.Add(edge);
-            return edge;
-        }
-        /// <summary>
-        /// 移除边信息
-        /// </summary>
-        /// <param name="edgeId"></param>
-        /// <returns></returns>
-        public virtual bool RemoveEdge(string edgeId)
-        {
-            return this.m_Edges.Remove(edgeId); ;
-        }
-        #endregion
-
-        #region 相关公开方法
-        /// <summary>
-        /// 获取最后一个状态的边集集合
-        /// </summary>
-        /// <returns></returns>
-        public List<E> GetLastStateEdges()
-        {
-            var edges=this.Edges.Where(e => e.Parent == null).ToList();
-            return edges;
-        }
-        /// <summary>
-        /// 获取原始状态的边集合
-        /// </summary>
-        /// <returns></returns>
-        public List<E> GeFirstStateEdges()
-        {
-            var edges = this.Edges.Where(e => e.Parent.Children.Count==0).ToList();
-            return edges;
-        }
-        #endregion
-    }
-}

+ 2 - 2
MBI/SAGA.DotNetUtils/Data/EdgesArray/BaseEdgesArray.cs

@@ -10,9 +10,9 @@ namespace SAGA.DotNetUtils.Data
     /// <summary>
     /// 基础边集数据
     /// </summary>
-    public class BaseEdgesArray<V, VD, E, ED> where V : EAVertex<VD> where E : EAEdge<ED>
+    public class EdgesArrayBase<V, VD, E, ED> where V : EAVertex<VD> where E : EAEdge<ED>
     {
-        public BaseEdgesArray()
+        public EdgesArrayBase()
         {
             m_Vertexes = new VCollection<V, VD>();
             Vertexes = new ReadOnlyCollection<V>(m_Vertexes);

+ 437 - 0
MBI/SAGA.DotNetUtils/Data/EdgesArray/EdgesArrayGraph.cs

@@ -0,0 +1,437 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+namespace SAGA.DotNetUtils.Data
+{
+    #region 概述
+    /*
+     * 有向图,和无向图,部分方法不同;
+     * 
+     * 内部操作使用索引;功能扩展使用Data
+     */ 
+    #endregion
+    /// <summary>
+    /// 边集列表
+    /// </summary>
+    public  class EdgesArrayGraph<V,VD,E,ED> : EdgesArrayBase<V, VD, E, ED> where V : EAVertex<VD> ,new() where E : EAEdge<ED>,new()
+    {
+        public EdgesArrayGraph()
+        {
+          
+        }
+        #region 控制属性
+        /// <summary>
+        /// 表示该图信息是否是有向的
+        /// </summary>
+        public bool IsDirection { get; set; }
+        #endregion
+        #region 编号系统
+        private int m_CurrentVertexIndex;
+        /// <summary>
+        /// 生成节点索引
+        /// </summary>
+        /// <returns></returns>
+        private string GenerateVertexIndex()
+        {
+            return "V" + (++m_CurrentVertexIndex);
+        }
+        /// <summary>
+        /// 生成节点索引
+        /// </summary>
+        /// <returns></returns>
+        private string GenerateEdgeIndex()
+        {
+            return "E" + (++m_CurrentVertexIndex);
+        }
+        #endregion
+
+        #region 点操作
+
+        #region 查找点
+        /// <summary>
+        /// 根据顶点Id查询相应的节点
+        /// </summary>
+        /// <param name="vertexId"></param>
+        /// <returns></returns>
+        public virtual V FindVertex(string vertexId)
+        {
+            if (string.IsNullOrWhiteSpace(vertexId))
+            {
+                return null;
+            }
+            if (this.m_Vertexes.Contains(vertexId))
+            {
+                return this.m_Vertexes[vertexId];
+            }
+            return null;
+        }
+        /// <summary>
+        /// 根据顶点Id查询相应的节点
+        /// </summary>
+        /// <param name="v">根据顶点信息去检索点</param>
+        /// <returns></returns>
+        public virtual V FindVertex(V v)
+        {
+            /*
+             * 待改进:id快索引,IsMatch值匹配慢索引
+             */
+            var useV = FindVertex(v.Id) ?? this.Vertexes.FirstOrDefault(c => c.IsMatch(v));
+            return useV;
+        }
+        #endregion
+
+        #region 增加点
+        /// <summary>
+        /// 增加顶点
+        /// </summary>
+        /// <param name="vertex"></param>
+        /// <returns></returns>
+        public virtual V AddVertex(V vertex)
+        {
+            if (vertex == null)
+                return null;
+            V result = vertex;
+            var useVertex = FindVertex(vertex);
+            if (useVertex == null)
+            {
+                vertex.Id = GenerateVertexIndex();
+                this.m_Vertexes.Add(vertex);
+            }
+            else
+            {
+                useVertex.Merge(vertex);
+                result = useVertex;
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// 增加顶点
+        /// </summary>
+        /// <param name="vData"></param>
+        /// <returns></returns>
+        public virtual V AddVertex(VD vData)
+        {
+            if (vData == null)
+                return null;
+            var v = new V();
+            v.Data = vData;
+            return AddVertex(v);
+        }
+        #endregion
+
+        #region 移除点相关操作
+        /// <summary>
+        /// 根据Id移除节点
+        /// </summary>
+        /// <param name="vertexId"></param>
+        /// <returns></returns>
+        public virtual bool RemoveVertex(string vertexId)
+        {
+            var realRemove = this.m_Vertexes.Remove(vertexId);
+            if (realRemove)
+            {
+                //移除节点需要移除相应的边
+                #region 移除相关联的边
+                var edges = this.Edges.Where(e => e.ContainVertex(vertexId) > -1);
+                foreach (var edge in edges)
+                {
+                    this.m_Edges.Remove(edge.Id);
+                } 
+                #endregion
+
+            }
+            return realRemove;
+        }
+        /// <summary>
+        /// 隐藏点
+        /// </summary>
+        /// <param name="vertexId"></param>
+        public virtual void HideVertex(string vertexId)
+        {
+            /*
+             * 将指定点隐藏:概念上是将该点关联的边和点信息删除重构;
+             * 一般适用于三点一线,隐藏掉中间点的情况;
+             * 其他情况下,边关联信息可能会出现问题
+             */
+        }
+        #endregion
+
+        #region 合并点
+        /// <summary>
+        /// 合并关联的点
+        /// </summary>
+        /// <param name="vs"></param>
+        /// <returns></returns>
+        public virtual V CombineVertexes(List<V> vs)
+        {
+            //将关联点合并。1、将点与点之间的边信息进行处理;2、创建新的点
+            return null;
+        }
+        #endregion
+        #endregion
+
+        #region 边操作
+        #region 查找边
+        /// <summary>
+        /// 获取边信息
+        /// </summary>
+        /// <param name="edgeId"></param>
+        /// <returns></returns>
+        public E FindEdge(string edgeId)
+        {
+            if (this.m_Edges.Contains(edgeId))
+            {
+                return m_Edges[edgeId];
+            }
+            return null;
+        }
+        #endregion
+        #region 增加边
+        /// <summary>
+        /// 增加边
+        /// </summary>
+        /// <param name="edge"></param>
+        /// <returns></returns>
+        public virtual E AddEdge(E edge)
+        {
+            var start = FindVertex(edge.StartVertex);
+            if (start == null)
+                throw new Exception("start元素必须在图中");
+            var end = FindVertex(edge.EndVertex);
+            if (end == null)
+                throw new Exception("end元素必须在图中");
+            edge.Id = GenerateEdgeIndex();
+            this.m_Edges.Add(edge);
+            return edge;
+        }
+        /// <summary>
+        /// 增加边信息
+        /// </summary>
+        /// <param name="start"></param>
+        /// <param name="end"></param>
+        /// <param name="edge"></param>
+        /// <returns></returns>
+        public virtual E AddEdge(V start, V end, E edge)
+        {
+            var startV = AddVertex(start);
+            if (startV == null)
+            {
+                throw new Exception("start不能为null");
+            }
+            var endV = AddVertex(end);
+            if (endV == null)
+            {
+                throw new Exception("end不能为null");
+            }
+            edge.StartVertex = startV.Id;
+            edge.EndVertex = endV.Id;
+            edge.Id = GenerateEdgeIndex();
+            this.m_Edges.Add(edge);
+            return edge;
+        } 
+        #endregion
+        /// <summary>
+        /// 移除边信息
+        /// </summary>
+        /// <param name="edgeId"></param>
+        /// <returns></returns>
+        public virtual bool RemoveEdge(string edgeId)
+        {
+            return this.m_Edges.Remove(edgeId); ;
+        }
+        #endregion
+
+        #region 联动查询
+        /*
+         * 念念不忘的可优化部分;根据点去查询边的情况
+         */
+        /// <summary>
+        /// 获取出边
+        /// </summary>
+        /// <param name="vertexId"></param>
+        /// <returns></returns>
+        public List<E> GetOutEdges(string vertexId)
+        {
+            List<E> result = new List<E>();
+            foreach (var edge in this.Edges)
+            {
+                var flag = edge.ContainVertex(vertexId);
+                if (flag == -1)
+                    continue;
+                if (!IsDirection)
+                {
+                    result.Add(edge);
+                }
+                else
+                {
+                    if (flag == 0)
+                    {
+                        result.Add(edge);
+                    }
+                }
+            }
+            return result;
+        }
+        /// <summary>
+        /// 获取入边
+        /// </summary>
+        /// <param name="vertexId"></param>
+        /// <returns></returns>
+        public List<E> GetInEdges(string vertexId)
+        {
+            List<E> result = new List<E>();
+            foreach (var edge in this.Edges)
+            {
+                var flag = edge.ContainVertex(vertexId);
+                if (flag == -1)
+                    continue;
+                if (!IsDirection)
+                {
+                    result.Add(edge);
+                }
+                else
+                {
+                    if (flag == 1)
+                    {
+                        result.Add(edge);
+                    }
+                }
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// 获取两个点确定的边信息
+        /// </summary>
+        /// <param name="startId"></param>
+        /// <param name="endId"></param>
+        /// <returns></returns>
+        public List<E> GetEdges(string startId, string endId)
+        {
+            List<E> result = new List<E>();
+            var edges = GetOutEdges(startId);
+            foreach (var edge in edges)
+            {
+                if (edge.GetAnotherVertex(startId) == endId)
+                {
+                    result.Add(edge);
+                }
+            }
+            return result;
+        }
+        /// <summary>
+        /// 获取出的邻节点
+        /// </summary>
+        /// <param name="vertexId"></param>
+        /// <returns></returns>
+        public List<V> GetOutVertexes(string vertexId)
+        {
+            List<V> result = new List<V>();
+            var edges = GetOutEdges(vertexId);
+            foreach (var edge in edges)
+            {
+                var otherId = edge.GetAnotherVertex(vertexId);
+                if (this.m_Vertexes.Contains(otherId))
+                {
+                    result.Add(this.m_Vertexes[otherId]);
+                }
+            }
+            return result;
+        }
+        /// <summary>
+        /// 获取入的邻接点
+        /// </summary>
+        /// <param name="vertexId"></param>
+        /// <returns></returns>
+        public List<V> GetInVertexes(string vertexId)
+        {
+            List<V> result = new List<V>();
+            var edges = GetInEdges(vertexId);
+            foreach (var edge in edges)
+            {
+                var otherId = edge.GetAnotherVertex(vertexId);
+                if (this.m_Vertexes.Contains(otherId))
+                {
+                    result.Add(this.m_Vertexes[otherId]);
+                }
+            }
+            return result;
+        }
+        /// <summary>
+        /// 获取边的开始点
+        /// </summary>
+        /// <param name="edge"></param>
+        /// <returns></returns>
+        public V GetStartVertex(E edge)
+        {
+            return FindVertex(edge.StartVertex);
+        }
+        /// <summary>
+        /// 获取边的结束点
+        /// </summary>
+        /// <param name="edge"></param>
+        /// <returns></returns>
+        public V GetEndVertex(E edge)
+        {
+            return FindVertex(edge.EndVertex);
+        }
+
+        /// <summary>
+        /// 获取边的开始点的根节点
+        /// </summary>
+        /// <param name="edge"></param>
+        /// <returns></returns>
+        public V GetBootStartVertex(E edge)
+        {
+            return FindVertex(edge.StartVertex)?.GetRoot() as V;
+        }
+        /// <summary>
+        /// 获取边的结束店的根节点
+        /// </summary>
+        /// <param name="edge"></param>
+        /// <returns></returns>
+        public V GetBootEndVertex(E edge)
+        {
+            return FindVertex(edge.EndVertex)?.GetRoot() as V;
+        }
+        #endregion
+
+        #region 相关公开方法
+        /// <summary>
+        /// 获取最后一个状态的边集集合
+        /// </summary>
+        /// <returns></returns>
+        public static List<E> GetLastStateEdges(IEnumerable<E> inputEdges)
+        {
+            var edges = inputEdges.Where(e => e.Parent == null).ToList();
+            return edges;
+        }
+        /// <summary>
+        /// 获取原始状态的边集合
+        /// </summary>
+        /// <returns></returns>
+        public static List<E> GeFirstStateEdges(IEnumerable<E> inputEdges)
+        {
+            var edges = inputEdges.Where(e => e.Parent.Children.Count == 0).ToList();
+            return edges;
+        }
+        /// <summary>
+        /// 获取最后一个状态的边集集合
+        /// </summary>
+        /// <returns></returns>
+        public List<E> GetLastStateEdges()
+        {
+            return GetLastStateEdges(this.Edges);
+        }
+        /// <summary>
+        /// 获取原始状态的边集合
+        /// </summary>
+        /// <returns></returns>
+        public List<E> GeFirstStateEdges()
+        {
+            return GeFirstStateEdges(this.Edges);
+        }
+        #endregion
+    }
+}

+ 4 - 4
MBI/SAGA.DotNetUtils/Data/EdgesArray/EdgesArrayUtil.cs

@@ -6,7 +6,7 @@ using System.Threading.Tasks;
 
 namespace SAGA.DotNetUtils.Data
 {
-    public class EdgesArrayUtil
+    public class EdgesArrayGraphUtil
     {
         /// <summary>
         /// 串联处理
@@ -17,7 +17,7 @@ namespace SAGA.DotNetUtils.Data
         /// <typeparam name="ED"></typeparam>
         /// <param name="edgesArray"></param>
         /// <returns></returns>
-        public static EdgesArray<V, VD, E, ED> ParallelHandle<V, VD, E, ED>(EdgesArray<V, VD, E, ED> edgesArray) where V : EAVertex<VD> where E : EAEdge<ED>,new ()
+        public static EdgesArrayGraph<V, VD, E, ED> ParallelHandle<V, VD, E, ED>(EdgesArrayGraph<V, VD, E, ED> edgesArray) where V : EAVertex<VD>,new() where E : EAEdge<ED>,new ()
         {
             var edges = edgesArray.GetLastStateEdges();
             VisitControl map = new VisitControl();
@@ -62,7 +62,7 @@ namespace SAGA.DotNetUtils.Data
         /// <typeparam name="ED"></typeparam>
         /// <param name="edgesArray"></param>
         /// <returns></returns>
-        public static EdgesArray<V, VD, E, ED> SeriesHandle<V, VD, E, ED>(EdgesArray<V, VD, E, ED> edgesArray) where V : EAVertex<VD> where E : EAEdge<ED>,new ()
+        public static EdgesArrayGraph<V, VD, E, ED> SeriesHandle<V, VD, E, ED>(EdgesArrayGraph<V, VD, E, ED> edgesArray) where V : EAVertex<VD>, new() where E : EAEdge<ED>,new ()
         {
             var edges = edgesArray.GetLastStateEdges();
             VisitControl map = new VisitControl();
@@ -139,7 +139,7 @@ namespace SAGA.DotNetUtils.Data
         /// <typeparam name="ED"></typeparam>
         /// <param name="edgesArray"></param>
         /// <returns></returns>
-        public static EdgesArray<V, VD, E, ED> GplotAnalyse<V, VD, E, ED>(EdgesArray<V, VD, E, ED> edgesArray) where V : EAVertex<VD> where E : EAEdge<ED>,new ()
+        public static EdgesArrayGraph<V, VD, E, ED> GplotAnalyse<V, VD, E, ED>(EdgesArrayGraph<V, VD, E, ED> edgesArray) where V : EAVertex<VD>, new() where E : EAEdge<ED>,new ()
         {
                 var preCount = edgesArray.GetLastStateEdges().Count;
                 do

+ 1 - 1
MBI/SAGA.DotNetUtils/Data/EdgesArray/ForwardStar.cs

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
 
 namespace SAGA.DotNetUtils.Data
 {
-    public class ForwardStar<V, VD,E, ED> : BaseEdgesArray<V, VD, E, ED> where V : EAVertex<VD> where E : EAEdge<ED>
+    public class ForwardStar<V, VD,E, ED> : EdgesArrayBase<V, VD, E, ED> where V : EAVertex<VD> where E : EAEdge<ED>
     {
         public ForwardStar()
         {

+ 53 - 0
MBI/SAGA.DotNetUtils/Data/NumberGenerater.cs

@@ -0,0 +1,53 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:NumberGenerater
+ * 作者:xulisong
+ * 创建时间: 2019/2/13 17:31:00
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.DotNetUtils.Data
+{
+    /// <summary>
+    /// 序号生成器
+    /// </summary>
+    public class NumberGenerater
+    {
+        private const string DefaultCategory = "D39D59D2-A068-4366-B915-CA651698E30A";
+        private Dictionary<string, int> m_Seeds;
+        public NumberGenerater()
+        {
+            m_Seeds = new Dictionary<string, int>();
+        }
+        public string GetNumber(string category, string format)
+        {
+            if (!m_Seeds.TryGetValue(category, out int seed))
+            {
+                m_Seeds[category] = seed;
+            }
+            return string.Format(format, ++seed);
+        }
+        
+        public string GetNumber(string format)
+        {
+            return GetNumber(DefaultCategory, format);
+        }
+        public string GetNumberWithPrefix(string category, string prefix)
+        {
+            if (!m_Seeds.TryGetValue(category, out int seed))
+            {
+                m_Seeds[category] = seed;
+            }
+            return string.Format("{0}{1}", prefix, ++seed);
+        }
+        public string GetNumberWithPrefix(string prefix)
+        {
+            return GetNumberWithPrefix(DefaultCategory, prefix);
+        }
+    }
+}

+ 4 - 3
MBI/SAGA.DotNetUtils/SAGA.DotNetUtils.csproj

@@ -246,18 +246,19 @@
     <Compile Include="Configration\TSZVersion.cs" />
     <Compile Include="Configration\XMLFile.cs" />
     <Compile Include="Configration\XmlManger.cs" />
-    <Compile Include="Data\EdgesArray\BaseEdgesArray.cs" />
+    <Compile Include="Data\EdgesArray\EdgesArrayBase.cs" />
     <Compile Include="Data\EdgesArray\DBCollection.cs" />
     <Compile Include="Data\EdgesArray\EAEdge.cs" />
     <Compile Include="Data\EdgesArray\EAVertex.cs" />
     <Compile Include="Data\EdgesArray\EAElement.cs" />
-    <Compile Include="Data\EdgesArray\EdgesArray.cs" />
-    <Compile Include="Data\EdgesArray\EdgesArrayUtil.cs" />
+    <Compile Include="Data\EdgesArray\EdgesArrayGraph.cs" />
+    <Compile Include="Data\EdgesArray\EdgesArrayGraphUtil.cs" />
     <Compile Include="Data\EdgesArray\ForwardStar.cs" />
     <Compile Include="Data\EdgesArray\VisitControl.cs" />
     <Compile Include="Data\FlagDecorator.cs" />
     <Compile Include="Data\InitAttribute.cs" />
     <Compile Include="Data\InitObejct.cs" />
+    <Compile Include="Data\NumberGenerater.cs" />
     <Compile Include="Data\SingleInstance.cs" />
     <Compile Include="DB\SQLiteHelper.cs" />
     <Compile Include="DB\TableNameAttribute.cs" />

+ 18 - 18
MBI/SAGA.GplotManage/GplotCommand.cs

@@ -142,25 +142,25 @@ namespace SAGA.GplotManage
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
             //var graph = new ChillWaterLoop();
-            //List<Gplot> gplots = new List<Gplot>();
-            //gplots.Add(new ElementSpNeighborhood());
-            //gplots.Add(new TrafficNetwork());
-            //gplots.Add(new ConvectionNetwork());
-            //gplots.Add(new RadiationNetwork());
-            //foreach (var gplot in gplots)
-            //{
-            //    var graph =gplot;//new ElementSpNeighborhood();
-            //    graph.Relationship = graph.ComputerEffectRelationShip;
-            //    graph.Upload();
+            List<Gplot> gplots = new List<Gplot>();
+            gplots.Add(new ElementSpNeighborhood());
+            gplots.Add(new TrafficNetwork());
+            gplots.Add(new ConvectionNetwork());
+            gplots.Add(new RadiationNetwork());
+            foreach (var gplot in gplots)
+            {
+                var graph = gplot;//new ElementSpNeighborhood();
+                graph.Relationship = graph.ComputerEffectRelationShip;
+                graph.Upload();
 
-            //}
-            var relationDatas = RelationDataUtil.BuildRelations("ChillWaterLoop");
-              Criteria Criterias= new Criteria
-              {
-                  criterias = relationDatas
-              };
-            var relation= ConvertJsonString(Criterias);
-            MessageShow.Infomation(relation);
+            }
+            //var relationDatas = RelationDataUtil.BuildRelations("ChillWaterLoop");
+            //  Criteria Criterias= new Criteria
+            //  {
+            //      criterias = relationDatas
+            //  };
+            //var relation= ConvertJsonString(Criterias);
+            //MessageShow.Infomation(relation);
             return Result.Succeeded;
         }
         private string ConvertJsonString(object object1)

+ 5 - 14
MBI/SAGA.RevitUtils/Data/ElementEdgesArray.cs

@@ -2,9 +2,6 @@
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Documents;
 using Autodesk.Revit.DB;
 using SAGA.RevitUtils;
 
@@ -19,24 +16,19 @@ namespace SAGA.RevitUtils
         {
             m_Vertexes = new List<ElementsVertex>();
             Vertexes = new ReadOnlyCollection<ElementsVertex>(m_Vertexes);
-
             m_Edges = new List<ElementsEdge>();
             Edges = new ReadOnlyCollection<ElementsEdge>(m_Edges);
-
             VERelations = new Dictionary<string, List<string>>();
         }
-
         #region 编号系统
-
-        private int m_CurrentVertexIndex;
-
+        private int m_CurrentIndex;
         /// <summary>
         /// 生成节点索引
         /// </summary>
         /// <returns></returns>
         private string GenerateVertexIndex()
         {
-            return "V" + (++m_CurrentVertexIndex);
+            return "V" + (++m_CurrentIndex);
         }
 
         /// <summary>
@@ -45,9 +37,8 @@ namespace SAGA.RevitUtils
         /// <returns></returns>
         private string GenerateEdgeIndex()
         {
-            return "E" + (++m_CurrentVertexIndex);
+            return "E" + (++m_CurrentIndex);
         }
-
         #endregion
 
         /// <summary>
@@ -112,7 +103,7 @@ namespace SAGA.RevitUtils
         /*
          * 增加一个点和边的关联关系,便于以后的查找速度 
          */
-        private Dictionary<string, List<string>> VERelations { get; set; }
+        private Dictionary<string, List<string>> VERelations { get;  set; }
         /// <summary>
         /// 增加点与边的关联关系
         /// </summary>
@@ -238,7 +229,7 @@ namespace SAGA.RevitUtils
             });
         }
         /// <summary>
-        /// 删除指定Id的节点,并把该节点关联的点直连新的边
+        /// 删除指定Id的节点,并把该节点关联的点直连新的边
         /// </summary>
         /// <param name="id"></param>
         /// <param name="predicate">重新连接的点</param>

+ 20 - 40
MBI/SAGA.RevitUtils/Data/ElementsVertex.cs

@@ -1,36 +1,33 @@
-
-using System;
+using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
-using System.ComponentModel;
 using System.Linq;
 using Autodesk.Revit.DB;
 
 namespace SAGA.RevitUtils
 {
-    public enum VertexType
-    {
-        [Description("原始点")]
-        Origin,
-        [Description("融合点")]
-        Combine,
-    }
     /*
      * 节点,可以记录水流方向,这个方向,可以决定拓扑中的串并联
      */
     public class ElementsVertex:GraphNode<ElementsVertex>
     {
-        protected List<Element> m_RefElelemts;
-      
+        protected List<Element> m_RefElelemts;    
         public ElementsVertex(List<Element> elements)
         {
+            if (elements == null)
+                throw new ArgumentNullException(nameof(elements));
             this.m_RefElelemts = new List<Element>(elements);
             this.RefData = new ReadOnlyCollection<Element>(this.m_RefElelemts);
-            if (elements.Any())
+            if (RefData.Any())
             {
-                this.Name = elements.FirstOrDefault().Id.IntegerValue.ToString();
+                this.Name = RefData.FirstOrDefault().Id.IntegerValue.ToString();
             }
         }
+
+        public ElementsVertex(Element element) : this(new List<Element>() { element })
+        {
+        }
+
         /// <summary>
         /// 创建空点
         /// </summary>
@@ -47,20 +44,11 @@ namespace SAGA.RevitUtils
         public bool IsEmpty()
         {
             return this.RefData.Count == 0;
-        }
-
-        public ElementsVertex(Element element):this(new List<Element>() { element })
-        {
-           
-        }
+        } 
         /// <summary>
         /// 关联卫星数据
         /// </summary>
         public ReadOnlyCollection<Element> RefData { get; private set; }
-        /// <summary>
-        /// 节点的点类型
-        /// </summary>
-        public VertexType Type { get; set; }
 
         #region 匹配数据
         /// <summary>
@@ -120,10 +108,12 @@ namespace SAGA.RevitUtils
             if (element == null)
                 return;
             ExtendRefElements(new List<Element>() { element });
-        }   /// <summary>
-            /// 扩展关联数据
-            /// </summary>
-            /// <param name="elements"></param>
+        }
+
+        /// <summary>
+        /// 扩展关联数据
+        /// </summary>
+        /// <param name="elements"></param>
         public void ExtendRefElements(List<Element> elements)
         {
             if (elements == null || !elements.Any())
@@ -131,26 +121,16 @@ namespace SAGA.RevitUtils
             elements.ForEach(e =>
             {
                 if (
-                   RefData.All(
+                    RefData.All(
                         ori => e.Id.IntegerValue != ori.Id.IntegerValue))
                 {
                     this.m_RefElelemts.Add(e);
                 }
+
                 ;
             });
         }
 
-        /// <summary>
-        /// 去除关联数据中的关联id
-        /// </summary>
-        /// <param name="elementId"></param>
-        public void RemoveRefElements(ElementId elementId)
-        {
-            if (elementId == null)
-                return;
-            this.m_RefElelemts.RemoveAll(e => e.Id == elementId);
-        }
-
         #endregion
 
         /// <summary>

+ 1 - 1
MBI/Test/Edges/EdgeGraph.cs

@@ -20,7 +20,7 @@ namespace Test.Edges
     {
 
     }
-    public class EdgeGraph: EdgesArray<VertexString, string, EdgeString, string>
+    public class EdgeGraph: EdgesArrayGraph<VertexString, string, EdgeString, string>
     {
     }
 }

+ 1 - 1
MBI/Test/MainWindow.xaml.cs

@@ -71,7 +71,7 @@ namespace Test
             graph.AddEdge(v6, v5, new EdgeString() { Data = "6-5" });
             graph.AddEdge(v7, v5, new EdgeString() { Data = "7-5" });
 
-            graph=EdgesArrayUtil.GplotAnalyse(graph) as EdgeGraph;
+            graph=EdgesArrayGraphUtil.GplotAnalyse(graph) as EdgeGraph;
 
             var edges = graph.Edges;
             StringBuilder builder = new StringBuilder();