Example #1
0
 public void TestVertexCollection()
 {
     var vertexCollection1 = new VertexUnsortedCollection(new StackListQueue <int> {
         1, 2, 3, 4, 6
     });
     var vertexCollection2 = new VertexUnsortedCollection(new StackListQueue <int> {
         1, 2, 3, 4, 5
     });
     var vertexCollection3 = new VertexUnsortedCollection(new StackListQueue <int> {
         5, 1, 2, 3, 4
     });
     var vertexCollection4 = new VertexUnsortedCollection(new StackListQueue <int> {
         5, 4, 3, 2, 1
     });
     var circle1 = new Circle(new VertexUnsortedCollection(new StackListQueue <int> {
         2, 3, 4, 6, 1
     }));
     var circle2 = new Circle(new VertexUnsortedCollection(new StackListQueue <int> {
         6, 4, 3, 2, 1
     }));
     var segment1 = new Segment(new VertexUnsortedCollection(new StackListQueue <int> {
         6, 1
     }));
     var segment2 = new Segment(new VertexUnsortedCollection(new StackListQueue <int> {
         6, 1
     }));
     var segmentCollection1 = new SegmentCollection {
         segment1
     };
     var segmentCollection2 = new SegmentCollection {
         segment2
     };
 }
Example #2
0
        public override int GetHashCode()
        {
            var reverse = new VertexUnsortedCollection {
                GetReverse()
            };

            return(base.GetHashCode() ^ reverse.GetHashCode());
        }
Example #3
0
        /// <summary>
        ///     Разделение графа на связанные подграфы
        /// </summary>
        /// <returns></returns>
        public IEnumerable <Graph> GetAllSubGraphs()
        {
            var           list     = new StackListQueue <Graph>();
            List <Vertex> vertexes = Vertices.ToList();

            while (vertexes.Any())
            {
                var stackListQueue = new StackListQueue <Vertex> {
                    vertexes.First()
                };
                var list1 = new VertexUnsortedCollection();
                while (stackListQueue.Any())
                {
                    Vertex pop = stackListQueue.Pop();
                    vertexes.Remove(pop);
                    list1.Add(pop);
                    stackListQueue.AddRange(Children[pop].Intersect(vertexes).Except(stackListQueue));
                }
                Dictionary <Vertex, VertexSortedCollection> children = list1.ToDictionary(vertex => vertex,
                                                                                          vertex => Children[vertex]);
                list.Add(new Graph(children));
            }
            return(list);
        }