internal override void RegisterVertex(TVertex vertex) { int handle = Size; int newSize = ++this.size; EnsureListSize(newSize); List[handle] = new VertexDisjointSet(vertex); vertex.Handle = handle; }
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; } }
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); }
protected override bool AllowEdge(VertexDisjointSet set, DirectedAdjSetGraphVertex <T> vertex) { return(true); }
protected override bool AllowEdge(VertexDisjointSet set, AdjSetGraphVertex <T> vertex) { return(vertex.Handle >= set.Vertex.Handle); }
protected abstract bool AllowEdge(VertexDisjointSet set, TVertex vertex);