// add a node from a vector pool // (use TUNGraph::IsOk to check whether the graph is consistent) int TUNGraph::AddNode(const int& NId, const TVecPool<TInt>& Pool, const int& NIdVId) { IAssert(NId != -1); IAssertR(! IsNode(NId), TStr::Fmt("NodeId %d already exists", NId)); MxNId = TMath::Mx(NId+1, MxNId()); TNode& Node = NodeH.AddDat(NId); Node.Id = NId; Node.NIdV.GenExt(Pool.GetValVPt(NIdVId), Pool.GetVLen(NIdVId)); Node.NIdV.Sort(); return NId; }
// Add a node of ID NId to the graph and create edges to all nodes in the vector NIdVId in the vector pool Pool). int TUNGraph::AddNode(const int& NId, const TVecPool<TInt>& Pool, const int& NIdVId) { int NewNId; if (NId == -1) { NewNId = MxNId; MxNId++; } else { IAssertR(!IsNode(NId), TStr::Fmt("NodeId %d already exists", NId)); NewNId = NId; MxNId = TMath::Mx(NewNId+1, MxNId()); } TNode& Node = NodeH.AddDat(NewNId); Node.Id = NewNId; Node.NIdV.GenExt(Pool.GetValVPt(NIdVId), Pool.GetVLen(NIdVId)); Node.NIdV.Sort(); NEdges += Node.GetDeg(); return NewNId; }