2230 IAssert(NEdges > 0 && NEdges < Graph->GetEdges());
2232 const int Nodes = Graph->
GetNodes();
2233 const int Edges = Graph->
GetEdges();
2240 ToAdd.
Gen(NEdges / 2, 0);
2241 for(
int i = 0; i < NEdges / 2; i++) {
2244 if(Graph->
IsEdge(Src, Dst)) { i--;
continue; }
2249 ToDel.
Gen(Edges, 0);
2251 ToDel.
Add(
TIntPr(EI.GetSrcNId(), EI.GetDstNId()));
2255 for(
int i = 0; i < NEdges / 2; i++) {
2256 Graph->
DelEdge(ToDel[i].Val1, ToDel[i].Val2);
2257 Graph->
AddEdge(ToAdd[i].Val1, ToAdd[i].Val2);
TPair< TInt, TInt > TIntPr
void GetNIdV(TIntV &NIdV) const
Gets a vector IDs of all nodes in the graph.
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the graph.
int GetEdges() const
Returns the number of edges in the graph.
TEdgeI BegEI() const
Returns an iterator referring to the first edge in the graph.
int GetNodes() const
Returns the number of nodes in the graph.
Edge iterator. Only forward iteration (operator++) is supported.
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge from node IDs SrcNId to node DstNId to the graph.
void DelEdge(const int &SrcNId, const int &DstNId, const bool &IsDir=true)
Deletes an edge from node IDs SrcNId to DstNId from the graph.
bool IsEdge(const int &SrcNId, const int &DstNId, const bool &IsDir=true) const
Tests whether an edge from node IDs SrcNId to DstNId exists in the graph.
void Shuffle(TRnd &Rnd)
Randomly shuffles the elements of the vector.
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
int GetUniDevInt(const int &Range=0)
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.