예제 #1
0
        public List <int>[] GetConnectivityMap()
        {
            HashSet <GraphEdge> .Enumerator enumerator = new HashSet <GraphEdge> .Enumerator();

            List <int>[] nums  = new List <int> [checked (checked (this.Count - 1) + 1)];
            int          count = checked (this.Count - 1);

            for (int i = 0; i <= count; i = checked (i + 1))
            {
                nums[i] = new List <int>();
            }
            try {
                enumerator = this.Edges.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    GraphEdge current = enumerator.Current;
                    if (!current.IsValid())
                    {
                        continue;
                    }
                    nums[current.From].Add(current.To);
                    nums[current.To].Add(current.From);
                }
            } finally {
                ((IDisposable)enumerator).Dispose();
            }
            return(nums);
        }
예제 #2
0
        public void PurgeEdges()
        {
            HashSet <GraphEdge> .Enumerator enumerator = new HashSet <GraphEdge> .Enumerator();

            List <GraphEdge> graphEdges = new List <GraphEdge>();

            try {
                enumerator = this.Edges.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    GraphEdge current = enumerator.Current;
                    if (current.IsValid())
                    {
                        continue;
                    }
                    graphEdges.Add(current);
                }
            } finally {
                ((IDisposable)enumerator).Dispose();
            }
            int count = checked (graphEdges.Count - 1);

            for (int i = 0; i <= count; i = checked (i + 1))
            {
                this.Edges.Remove(graphEdges[i]);
            }
        }