Пример #1
0
        internal override void RegisterVertex(TVertex vertex)
        {
            int handle  = Size;
            int newSize = ++this.size;

            EnsureListSize(newSize);
            List[handle]  = new VertexDisjointSet(vertex);
            vertex.Handle = handle;
        }
Пример #2
0
 void EnsureListSize(int newSize)
 {
     if (newSize > this.capacity)
     {
         int _capacity = this.capacity * 2;
         if (newSize > _capacity)
         {
             _capacity = newSize * 2;
         }
         VertexDisjointSet[] _list = new VertexDisjointSet[_capacity];
         Array.Copy(List, _list, List.Length);
         this.list     = _list;
         this.capacity = _capacity;
     }
 }
Пример #3
0
        internal override List <Edge <TValue, TVertex> > GetEdgeList()
        {
            List <Edge <TValue, TVertex> > list = new List <Edge <TValue, TVertex> >();

            for (int n = 0; n < Size; n++)
            {
                VertexDisjointSet set = List[n];
                foreach (TVertex vertex in set.GetVertices(false))
                {
                    if (AllowEdge(set, vertex))
                    {
                        list.Add(new Edge <TValue, TVertex>(set.Vertex, vertex, set.GetItem(vertex).EdgeData.Weight));
                    }
                }
            }
            return(list);
        }
Пример #4
0
 protected override bool AllowEdge(VertexDisjointSet set, DirectedAdjSetGraphVertex <T> vertex)
 {
     return(true);
 }
Пример #5
0
 protected override bool AllowEdge(VertexDisjointSet set, AdjSetGraphVertex <T> vertex)
 {
     return(vertex.Handle >= set.Vertex.Handle);
 }
Пример #6
0
 protected abstract bool AllowEdge(VertexDisjointSet set, TVertex vertex);