SNAP Library , Developer Reference
2013-01-07 14:03:36
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <network.h>
Classes | |
class | TEdge |
class | TEdgeI |
Edge iterator. Only forward iteration (operator++) is supported. More... | |
class | TNode |
class | TNodeI |
Node iterator. Only forward iteration (operator++) is supported. More... | |
Public Types | |
typedef TNodeData | TNodeDat |
typedef TEdgeData | TEdgeDat |
typedef TNodeEdgeNet < TNodeData, TEdgeData > | TNet |
typedef TPt< TNet > | PNet |
Public Member Functions | |
TNodeEdgeNet () | |
TNodeEdgeNet (const int &Nodes, const int &Edges) | |
Constructor that reserves enough memory for a network of Nodes nodes and Edges edges. | |
TNodeEdgeNet (const TNodeEdgeNet &Net) | |
TNodeEdgeNet (TSIn &SIn) | |
Constructor that loads the network from a (binary) stream SIn. | |
virtual | ~TNodeEdgeNet () |
virtual void | Save (TSOut &SOut) const |
Saves the network to a (binary) stream SOut. | |
bool | HasFlag (const TGraphFlag &Flag) const |
Allows for run-time checking the type of the network (see the TGraphFlag for flags). | |
TNodeEdgeNet & | operator= (const TNodeEdgeNet &Net) |
int | GetNodes () const |
Returns the number of nodes in the network. | |
int | AddNode (int NId=-1) |
Adds a node of ID NId to the network. | |
int | AddNode (int NId, const TNodeData &NodeDat) |
Adds node data to node with ID NId. | |
int | AddNode (const TNodeI &NodeId) |
Adds a node NodeId and its node data to the network. | |
void | DelNode (const int &NId) |
Deletes node of ID NId from the network. | |
void | DelNode (const TNode &NodeI) |
Deletes node of ID NodeI.GetId() from the network. | |
bool | IsNode (const int &NId) const |
Tests whether ID NId is a node. | |
TNodeI | BegNI () const |
Returns an iterator referring to the first node in the network. | |
TNodeI | EndNI () const |
Returns an iterator referring to the past-the-end node in the network. | |
TNodeI | GetNI (const int &NId) const |
Returns an iterator referring to the node of ID NId in the network. | |
void | SetNDat (const int &NId, const TNodeData &NodeDat) |
Sets node data for the node of ID NId in the network. | |
TNodeData & | GetNDat (const int &NId) |
Returns node data for the node of ID NId in the network. | |
const TNodeData & | GetNDat (const int &NId) const |
Returns node data for the node of ID NId in the network. | |
int | GetMxNId () const |
Returns the maximum id of a any node in the network. | |
int | GetEdges () const |
Returns the number of edges in the network. | |
int | GetUniqEdges (const bool &IsDir=true) const |
Returns the number of edges in the network with a unique pair of nodes. | |
int | AddEdge (const int &SrcNId, const int &DstNId, int EId=-1) |
Adds an edge between node IDs SrcNId and DstNId to the graph. | |
int | AddEdge (const int &SrcNId, const int &DstNId, int EId, const TEdgeData &EdgeDat) |
Adds an edge and edge data from node IDs SrcNId to node DstNId. | |
int | AddEdge (const TEdgeI &EdgeI) |
Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() and its edge data to the network. | |
void | DelEdge (const int &EId) |
Deletes an edge with ID EId from the network. | |
void | DelEdge (const int &SrcNId, const int &DstNId, const bool &IsDir=true) |
Deletes an edge from node IDs SrcNId to DstNId from the network. | |
bool | IsEdge (const int &EId) const |
Tests whether an edge with ID EId exists in the network. | |
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 network. | |
bool | IsEdge (const int &SrcNId, const int &DstNId, int &EId, const bool &IsDir=true) const |
Tests whether an edge from node IDs SrcNId to DstNId with edge ID EId exists in the network. | |
int | GetEId (const int &SrcNId, const int &DstNId) const |
TEdgeI | BegEI () const |
Returns an iterator referring to the first edge in the network. | |
TEdgeI | EndEI () const |
Returns an iterator referring to the past-the-end edge in the network. | |
TEdgeI | GetEI (const int &EId) const |
TEdgeI | GetEI (const int &SrcNId, const int &DstNId) const |
void | SetEDat (const int &EId, const TEdgeData &EdgeDat) |
Sets edge data for the edge of ID NId in the network. | |
TEdgeData & | GetEDat (const int &EId) |
Returns edge data for the edge with ID EId. | |
const TEdgeData & | GetEDat (const int &EId) const |
Returns edge data for the edge with ID EId. | |
void | SetAllEDat (const TEdgeData &EdgeDat) |
Sets edge data for all the edges in the network to EDat. | |
int | GetRndNId (TRnd &Rnd=TInt::Rnd) |
Returns an ID of a random node in the network. | |
TNodeI | GetRndNI (TRnd &Rnd=TInt::Rnd) |
Returns an interator referring to a random node in the network. | |
int | GetRndEId (TRnd &Rnd=TInt::Rnd) |
Returns an ID of a random edge in the network. | |
TEdgeI | GetRndEI (TRnd &Rnd=TInt::Rnd) |
Returns an interator referring to a random edge in the network. | |
void | GetNIdV (TIntV &NIdV) const |
Returns a vector of all node IDs in the network. | |
void | GetEIdV (TIntV &EIdV) const |
Returns a vector of all edge IDs in the network. | |
bool | Empty () const |
Tests whether the network is empty (has zero nodes). | |
void | Clr () |
Deletes all nodes and edges from the network. | |
void | Reserve (const int &Nodes, const int &Edges) |
Reserves memory for a network of Nodes nodes and Edges edges. | |
void | SortNIdById (const bool &Asc=true) |
Sorts nodes by node IDs. | |
void | SortNIdByDat (const bool &Asc=true) |
Sorts nodes by node data. | |
void | SortEIdById (const bool &Asc=true) |
Sorts edges by edge IDs. | |
void | SortEIdByDat (const bool &Asc=true) |
Sorts edges by edge data. | |
void | Defrag (const bool &OnlyNodeLinks=false) |
Defragments the network. | |
bool | IsOk (const bool &ThrowExcept=true) const |
Checks the network data structure for internal consistency. | |
Static Public Member Functions | |
static PNet | New () |
Static constructor that returns a pointer to the network. Call: TPt <TNodeEdgeNet<TNodeData, TEdgeData> > Net = TNodeEdgeNet<TNodeData, TEdgeData>::New(). | |
static PNet | Load (TSIn &SIn) |
Static constructor that loads the network from a stream SIn and returns a pointer to it. | |
Protected Attributes | |
TCRef | CRef |
TInt | MxNId |
TInt | MxEId |
THash< TInt, TNode > | NodeH |
THash< TInt, TEdge > | EdgeH |
Private Member Functions | |
TNode & | GetNode (const int &NId) |
const TNode & | GetNode (const int &NId) const |
const TNode & | GetNodeKId (const int &NodeKeyId) const |
TEdge & | GetEdge (const int &EId) |
const TEdge & | GetEdge (const int &EId) const |
const TEdge & | GetEdgeKId (const int &EdgeKeyId) const |
Friends | |
class | TPt< TNodeEdgeNet< TNodeData, TEdgeData > > |
Node Edge Network (directed multigraph, TNEGraph with data on nodes and edges).
typedef TPt<TNet> TNodeEdgeNet< TNodeData, TEdgeData >::PNet |
Reimplemented in TTimeNENet.
typedef TEdgeData TNodeEdgeNet< TNodeData, TEdgeData >::TEdgeDat |
typedef TNodeEdgeNet<TNodeData, TEdgeData> TNodeEdgeNet< TNodeData, TEdgeData >::TNet |
Reimplemented in TTimeNENet.
typedef TNodeData TNodeEdgeNet< TNodeData, TEdgeData >::TNodeDat |
TNodeEdgeNet< TNodeData, TEdgeData >::TNodeEdgeNet | ( | ) | [inline] |
TNodeEdgeNet< TNodeData, TEdgeData >::TNodeEdgeNet | ( | const int & | Nodes, |
const int & | Edges | ||
) | [inline, explicit] |
TNodeEdgeNet< TNodeData, TEdgeData >::TNodeEdgeNet | ( | const TNodeEdgeNet< TNodeData, TEdgeData > & | Net | ) | [inline] |
TNodeEdgeNet< TNodeData, TEdgeData >::TNodeEdgeNet | ( | TSIn & | SIn | ) | [inline] |
virtual TNodeEdgeNet< TNodeData, TEdgeData >::~TNodeEdgeNet | ( | ) | [inline, virtual] |
int TNodeEdgeNet< TNodeData, TEdgeData >::AddEdge | ( | const int & | SrcNId, |
const int & | DstNId, | ||
int | EId = -1 |
||
) |
Adds an edge between node IDs SrcNId and DstNId to the graph.
Returns the ID of the edge being added. If EId is -1, edge ID is automatically assigned. Aborts, if an edge with ID EId already exists. Aborts, if SrcNId or DstNId are not nodes in the graph.
Definition at line 1403 of file network.h.
References THash< TKey, TDat, THashFunc >::AddDat(), TVec< TVal >::AddSorted(), TNodeEdgeNet< TNodeData, TEdgeData >::EdgeH, TStr::Fmt(), TNodeEdgeNet< TNodeData, TEdgeData >::GetNode(), IAssertR, TNodeEdgeNet< TNodeData, TEdgeData >::TNode::InEIdV, TNodeEdgeNet< TNodeData, TEdgeData >::IsEdge(), TNodeEdgeNet< TNodeData, TEdgeData >::IsNode(), TMath::Mx(), TNodeEdgeNet< TNodeData, TEdgeData >::MxEId, and TNodeEdgeNet< TNodeData, TEdgeData >::TNode::OutEIdV.
Referenced by TTimeNENet::GetESubGraph(), TTimeNENet::GetGraphUpToTm(), and TTimeNENet::GetSubGraph().
{ if (EId == -1) { EId = MxEId; MxEId++; } else { MxEId = TMath::Mx(EId+1, MxEId()); } IAssertR(!IsEdge(EId), TStr::Fmt("EdgeId %d already exists", EId)); IAssertR(IsNode(SrcNId) && IsNode(DstNId), TStr::Fmt("%d or %d not a node.", SrcNId, DstNId).CStr()); EdgeH.AddDat(EId, TEdge(EId, SrcNId, DstNId)); GetNode(SrcNId).OutEIdV.AddSorted(EId); GetNode(DstNId).InEIdV.AddSorted(EId); return EId; }
int TNodeEdgeNet< TNodeData, TEdgeData >::AddEdge | ( | const int & | SrcNId, |
const int & | DstNId, | ||
int | EId, | ||
const TEdgeData & | EdgeDat | ||
) |
Adds an edge and edge data from node IDs SrcNId to node DstNId.
Returns the ID of the edge being added. If EId is -1, edge ID is automatically assigned. Aborts, if an edge with ID EId already exists. Aborts, if SrcNId or DstNId are not nodes in the graph.
Definition at line 1415 of file network.h.
References THash< TKey, TDat, THashFunc >::AddDat(), TVec< TVal >::AddSorted(), TNodeEdgeNet< TNodeData, TEdgeData >::EdgeH, TStr::Fmt(), TNodeEdgeNet< TNodeData, TEdgeData >::GetNode(), IAssertR, TNodeEdgeNet< TNodeData, TEdgeData >::TNode::InEIdV, TNodeEdgeNet< TNodeData, TEdgeData >::IsEdge(), TNodeEdgeNet< TNodeData, TEdgeData >::IsNode(), TMath::Mx(), TNodeEdgeNet< TNodeData, TEdgeData >::MxEId, and TNodeEdgeNet< TNodeData, TEdgeData >::TNode::OutEIdV.
{ if (EId == -1) { EId = MxEId; MxEId++; } else { MxEId = TMath::Mx(EId+1, MxEId()); } IAssertR(!IsEdge(EId), TStr::Fmt("EdgeId %d already exists", EId)); IAssertR(IsNode(SrcNId) && IsNode(DstNId), TStr::Fmt("%d or %d not a node.", SrcNId, DstNId).CStr()); EdgeH.AddDat(EId, TEdge(EId, SrcNId, DstNId, EdgeDat)); GetNode(SrcNId).OutEIdV.AddSorted(EId); GetNode(DstNId).InEIdV.AddSorted(EId); return EId; }
int TNodeEdgeNet< TNodeData, TEdgeData >::AddEdge | ( | const TEdgeI & | EdgeI | ) | [inline] |
Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() and its edge data to the network.
Definition at line 1230 of file network.h.
Referenced by TNodeEdgeNet< TSecTm, TSecTm >::AddEdge().
{ return AddEdge(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), EdgeI.GetId(), EdgeI.GetDat()); }
int TNodeEdgeNet< TNodeData, TEdgeData >::AddNode | ( | int | NId = -1 | ) |
Adds a node of ID NId to the network.
Returns the ID of the node being added. If NId is -1, node ID is automatically assigned. Aborts, if a node with ID NId already exists.
Definition at line 1341 of file network.h.
References THash< TKey, TDat, THashFunc >::AddDat(), TStr::Fmt(), IAssertR, TNodeEdgeNet< TNodeData, TEdgeData >::IsNode(), TMath::Mx(), TNodeEdgeNet< TNodeData, TEdgeData >::MxNId, and TNodeEdgeNet< TNodeData, TEdgeData >::NodeH.
Referenced by TTimeNENet::GetESubGraph(), TTimeNENet::GetGraphUpToTm(), and TTimeNENet::GetSubGraph().
{ if (NId == -1) { NId = MxNId; MxNId++; } else { IAssertR(!IsNode(NId), TStr::Fmt("NodeId %d already exists", NId)); MxNId = TMath::Mx(NId+1, MxNId()); } NodeH.AddDat(NId, TNode(NId)); return NId; }
int TNodeEdgeNet< TNodeData, TEdgeData >::AddNode | ( | int | NId, |
const TNodeData & | NodeDat | ||
) |
Adds node data to node with ID NId.
Returns the ID of the node being added. If NId is -1, node ID is automatically assigned. Aborts, if a node with ID NId already exists.
Definition at line 1353 of file network.h.
References THash< TKey, TDat, THashFunc >::AddDat(), TStr::Fmt(), IAssertR, TNodeEdgeNet< TNodeData, TEdgeData >::IsNode(), TMath::Mx(), TNodeEdgeNet< TNodeData, TEdgeData >::MxNId, and TNodeEdgeNet< TNodeData, TEdgeData >::NodeH.
{ if (NId == -1) { NId = MxNId; MxNId++; } else { IAssertR(!IsNode(NId), TStr::Fmt("NodeId %d already exists", NId)); MxNId = TMath::Mx(NId+1, MxNId()); } NodeH.AddDat(NId, TNode(NId, NodeDat)); return NId; }
int TNodeEdgeNet< TNodeData, TEdgeData >::AddNode | ( | const TNodeI & | NodeId | ) | [inline] |
Adds a node NodeId and its node data to the network.
Definition at line 1186 of file network.h.
Referenced by TNodeEdgeNet< TSecTm, TSecTm >::AddNode().
{ return AddNode(NodeId.GetId(), NodeId.GetDat()); }
TEdgeI TNodeEdgeNet< TNodeData, TEdgeData >::BegEI | ( | ) | const [inline] |
Returns an iterator referring to the first edge in the network.
Definition at line 1247 of file network.h.
Referenced by TNodeEdgeNet< TNodeData, TEdgeData >::GetUniqEdges(), and TNodeEdgeNet< TNodeData, TEdgeData >::SetAllEDat().
TNodeI TNodeEdgeNet< TNodeData, TEdgeData >::BegNI | ( | ) | const [inline] |
void TNodeEdgeNet< TNodeData, TEdgeData >::Clr | ( | ) | [inline] |
void TNodeEdgeNet< TNodeData, TEdgeData >::Defrag | ( | const bool & | OnlyNodeLinks = false | ) |
Defragments the network.
After performing many node and edge insertions and deletions to a network, the network data structure will be fragmented in memory. This function compacts down the network data structure and frees unneeded memory.
Definition at line 1496 of file network.h.
References THash< TKey, TDat, THashFunc >::Defrag(), TNodeEdgeNet< TNodeData, TEdgeData >::EdgeH, THash< TKey, TDat, THashFunc >::FFirstKeyId(), THash< TKey, TDat, THashFunc >::FNextKeyId(), TNodeEdgeNet< TNodeData, TEdgeData >::TNode::InEIdV, THash< TKey, TDat, THashFunc >::IsKeyIdEqKeyN(), TNodeEdgeNet< TNodeData, TEdgeData >::NodeH, TNodeEdgeNet< TNodeData, TEdgeData >::TNode::OutEIdV, and TVec< TVal >::Pack().
Referenced by TTimeNENet::GetESubGraph(), TTimeNENet::GetGraphUpToTm(), and TTimeNENet::GetSubGraph().
{ for (int kid = NodeH.FFirstKeyId(); NodeH.FNextKeyId(kid);) { TNode& Node = NodeH[kid]; Node.InEIdV.Pack(); Node.OutEIdV.Pack(); } if (! OnlyNodeLinks && ! NodeH.IsKeyIdEqKeyN()) { NodeH.Defrag(); } if (! OnlyNodeLinks && ! EdgeH.IsKeyIdEqKeyN()) { EdgeH.Defrag(); } }
void TNodeEdgeNet< TNodeData, TEdgeData >::DelEdge | ( | const int & | EId | ) |
Deletes an edge with ID EId from the network.
Definition at line 1427 of file network.h.
References TVec< TVal >::DelIfIn(), THash< TKey, TDat, THashFunc >::DelKey(), TNodeEdgeNet< TNodeData, TEdgeData >::EdgeH, TNodeEdgeNet< TNodeData, TEdgeData >::TEdge::GetDstNId(), TNodeEdgeNet< TNodeData, TEdgeData >::GetEdge(), TNodeEdgeNet< TNodeData, TEdgeData >::GetNode(), TNodeEdgeNet< TNodeData, TEdgeData >::TEdge::GetSrcNId(), IAssert, TNodeEdgeNet< TNodeData, TEdgeData >::TNode::InEIdV, TNodeEdgeNet< TNodeData, TEdgeData >::IsEdge(), and TNodeEdgeNet< TNodeData, TEdgeData >::TNode::OutEIdV.
{ IAssert(IsEdge(EId)); const int SrcNId = GetEdge(EId).GetSrcNId(); const int DstNId = GetEdge(EId).GetDstNId(); GetNode(SrcNId).OutEIdV.DelIfIn(EId); GetNode(DstNId).InEIdV.DelIfIn(EId); EdgeH.DelKey(EId); }
void TNodeEdgeNet< TNodeData, TEdgeData >::DelEdge | ( | const int & | SrcNId, |
const int & | DstNId, | ||
const bool & | IsDir = true |
||
) |
Deletes an edge from node IDs SrcNId to DstNId from the network.
If the edge (SrcNId, DstNId) does not exist in the network function still completes. But the function aborts if SrcNId or DstNId are not nodes in the network.
Definition at line 1437 of file network.h.
References TVec< TVal >::DelIfIn(), THash< TKey, TDat, THashFunc >::DelKey(), TNodeEdgeNet< TNodeData, TEdgeData >::EdgeH, TNodeEdgeNet< TNodeData, TEdgeData >::GetNode(), IAssert, TNodeEdgeNet< TNodeData, TEdgeData >::TNode::InEIdV, TNodeEdgeNet< TNodeData, TEdgeData >::IsEdge(), and TNodeEdgeNet< TNodeData, TEdgeData >::TNode::OutEIdV.
{ int EId; IAssert(IsEdge(SrcNId, DstNId, EId, IsDir)); GetNode(SrcNId).OutEIdV.DelIfIn(EId); GetNode(DstNId).InEIdV.DelIfIn(EId); EdgeH.DelKey(EId); }
void TNodeEdgeNet< TNodeData, TEdgeData >::DelNode | ( | const int & | NId | ) |
Deletes node of ID NId from the network.
If the node of ID NId does not exist the function aborts.
Definition at line 1365 of file network.h.
References THash< TKey, TDat, THashFunc >::DelKey(), TNodeEdgeNet< TNodeData, TEdgeData >::EdgeH, TNodeEdgeNet< TNodeData, TEdgeData >::TEdge::GetDstNId(), TNodeEdgeNet< TNodeData, TEdgeData >::GetEdge(), TNodeEdgeNet< TNodeData, TEdgeData >::TNode::GetInDeg(), TNodeEdgeNet< TNodeData, TEdgeData >::TNode::GetInEId(), TNodeEdgeNet< TNodeData, TEdgeData >::GetNode(), TNodeEdgeNet< TNodeData, TEdgeData >::TNode::GetOutDeg(), TNodeEdgeNet< TNodeData, TEdgeData >::TNode::GetOutEId(), TNodeEdgeNet< TNodeData, TEdgeData >::TEdge::GetSrcNId(), IAssert, and TNodeEdgeNet< TNodeData, TEdgeData >::NodeH.
{ const TNode& Node = GetNode(NId); for (int out = 0; out < Node.GetOutDeg(); out++) { const int EId = Node.GetOutEId(out); const TEdge& Edge = GetEdge(EId); IAssert(Edge.GetSrcNId() == NId); GetNode(Edge.GetDstNId()).InEIdV.DelIfIn(EId); EdgeH.DelKey(EId); } for (int in = 0; in < Node.GetInDeg(); in++) { const int EId = Node.GetInEId(in); const TEdge& Edge = GetEdge(EId); IAssert(Edge.GetDstNId() == NId); GetNode(Edge.GetSrcNId()).OutEIdV.DelIfIn(EId); EdgeH.DelKey(EId); } NodeH.DelKey(NId); }
void TNodeEdgeNet< TNodeData, TEdgeData >::DelNode | ( | const TNode & | NodeI | ) | [inline] |
Deletes node of ID NodeI.GetId() from the network.
Definition at line 1192 of file network.h.
Referenced by TNodeEdgeNet< TSecTm, TSecTm >::DelNode().
{ DelNode(NodeI.GetId()); }
bool TNodeEdgeNet< TNodeData, TEdgeData >::Empty | ( | ) | const [inline] |
TEdgeI TNodeEdgeNet< TNodeData, TEdgeData >::EndEI | ( | ) | const [inline] |
Returns an iterator referring to the past-the-end edge in the network.
Definition at line 1249 of file network.h.
Referenced by TNodeEdgeNet< TNodeData, TEdgeData >::GetUniqEdges(), and TNodeEdgeNet< TNodeData, TEdgeData >::SetAllEDat().
TNodeI TNodeEdgeNet< TNodeData, TEdgeData >::EndNI | ( | ) | const [inline] |
TEdgeData& TNodeEdgeNet< TNodeData, TEdgeData >::GetEDat | ( | const int & | EId | ) | [inline] |
Returns edge data for the edge with ID EId.
Definition at line 1257 of file network.h.
Referenced by TNodeEdgeNet< TNodeData, TEdgeData >::TNodeI::GetInEDat(), TNodeEdgeNet< TNodeData, TEdgeData >::TNodeI::GetNbrEDat(), and TNodeEdgeNet< TNodeData, TEdgeData >::TNodeI::GetOutEDat().
const TEdgeData& TNodeEdgeNet< TNodeData, TEdgeData >::GetEDat | ( | const int & | EId | ) | const [inline] |
TEdge& TNodeEdgeNet< TNodeData, TEdgeData >::GetEdge | ( | const int & | EId | ) | [inline, private] |
Definition at line 1144 of file network.h.
Referenced by TNodeEdgeNet< TNodeData, TEdgeData >::DelEdge(), TNodeEdgeNet< TNodeData, TEdgeData >::DelNode(), TNodeEdgeNet< TNodeData, TEdgeData >::TNodeI::GetInNId(), TNodeEdgeNet< TNodeData, TEdgeData >::TNodeI::GetNbrNId(), TNodeEdgeNet< TNodeData, TEdgeData >::TNodeI::GetOutNId(), TNodeEdgeNet< TNodeData, TEdgeData >::IsEdge(), and TNodeEdgeNet< TNodeData, TEdgeData >::TNodeI::IsInNId().
const TEdge& TNodeEdgeNet< TNodeData, TEdgeData >::GetEdge | ( | const int & | EId | ) | const [inline, private] |
const TEdge& TNodeEdgeNet< TNodeData, TEdgeData >::GetEdgeKId | ( | const int & | EdgeKeyId | ) | const [inline, private] |
int TNodeEdgeNet< TNodeData, TEdgeData >::GetEdges | ( | ) | const [inline] |
Returns the number of edges in the network.
Definition at line 1212 of file network.h.
Referenced by TNodeEdgeNet< TNodeData, TEdgeData >::GetEIdV(), and TNodeEdgeNet< TNodeData, TEdgeData >::GetUniqEdges().
TEdgeI TNodeEdgeNet< TNodeData, TEdgeData >::GetEI | ( | const int & | EId | ) | const [inline] |
Definition at line 1251 of file network.h.
Referenced by TNodeEdgeNet< TSecTm, TSecTm >::GetRndEI(), and TNodeEdgeNet< TNodeData, TEdgeData >::SetEDat().
TEdgeI TNodeEdgeNet< TNodeData, TEdgeData >::GetEI | ( | const int & | SrcNId, |
const int & | DstNId | ||
) | const [inline] |
Definition at line 1253 of file network.h.
Referenced by TNodeEdgeNet< TSecTm, TSecTm >::GetEI().
int TNodeEdgeNet< TNodeData, TEdgeData >::GetEId | ( | const int & | SrcNId, |
const int & | DstNId | ||
) | const [inline] |
Definition at line 1245 of file network.h.
Referenced by TNodeEdgeNet< TSecTm, TSecTm >::GetEI().
{ int EId; return IsEdge(SrcNId, DstNId, EId)?EId:-1; }
void TNodeEdgeNet< TNodeData, TEdgeData >::GetEIdV | ( | TIntV & | EIdV | ) | const |
Returns a vector of all edge IDs in the network.
Definition at line 1488 of file network.h.
References TVec< TVal >::Add(), TNodeEdgeNet< TNodeData, TEdgeData >::EdgeH, THash< TKey, TDat, THashFunc >::FFirstKeyId(), THash< TKey, TDat, THashFunc >::FNextKeyId(), TVec< TVal >::Gen(), TNodeEdgeNet< TNodeData, TEdgeData >::GetEdges(), and THash< TKey, TDat, THashFunc >::GetKey().
{ EIdV.Gen(GetEdges(), 0); for (int E=EdgeH.FFirstKeyId(); EdgeH.FNextKeyId(E);) { EIdV.Add(EdgeH.GetKey(E)); } }
int TNodeEdgeNet< TNodeData, TEdgeData >::GetMxNId | ( | ) | const [inline] |
TNodeData& TNodeEdgeNet< TNodeData, TEdgeData >::GetNDat | ( | const int & | NId | ) | [inline] |
Returns node data for the node of ID NId in the network.
Definition at line 1204 of file network.h.
Referenced by TNodeEdgeNet< TNodeData, TEdgeData >::TEdgeI::GetDstNDat(), TNodeEdgeNet< TNodeData, TEdgeData >::TNodeI::GetInNDat(), TNodeEdgeNet< TNodeData, TEdgeData >::TNodeI::GetNbrNDat(), TNodeEdgeNet< TNodeData, TEdgeData >::TNodeI::GetOutNDat(), and TNodeEdgeNet< TNodeData, TEdgeData >::TEdgeI::GetSrcNDat().
const TNodeData& TNodeEdgeNet< TNodeData, TEdgeData >::GetNDat | ( | const int & | NId | ) | const [inline] |
TNodeI TNodeEdgeNet< TNodeData, TEdgeData >::GetNI | ( | const int & | NId | ) | const [inline] |
Returns an iterator referring to the node of ID NId in the network.
Definition at line 1200 of file network.h.
Referenced by TNodeEdgeNet< TSecTm, TSecTm >::GetRndNI().
void TNodeEdgeNet< TNodeData, TEdgeData >::GetNIdV | ( | TIntV & | NIdV | ) | const |
Returns a vector of all node IDs in the network.
Definition at line 1480 of file network.h.
References TVec< TVal >::Add(), THash< TKey, TDat, THashFunc >::FFirstKeyId(), THash< TKey, TDat, THashFunc >::FNextKeyId(), TVec< TVal >::Gen(), THash< TKey, TDat, THashFunc >::GetKey(), TNodeEdgeNet< TNodeData, TEdgeData >::GetNodes(), and TNodeEdgeNet< TNodeData, TEdgeData >::NodeH.
{ NIdV.Gen(GetNodes(), 0); for (int N=NodeH.FFirstKeyId(); NodeH.FNextKeyId(N);) { NIdV.Add(NodeH.GetKey(N)); } }
TNode& TNodeEdgeNet< TNodeData, TEdgeData >::GetNode | ( | const int & | NId | ) | [inline, private] |
Definition at line 1141 of file network.h.
Referenced by TNodeEdgeNet< TNodeData, TEdgeData >::AddEdge(), TNodeEdgeNet< TNodeData, TEdgeData >::DelEdge(), TNodeEdgeNet< TNodeData, TEdgeData >::DelNode(), and TNodeEdgeNet< TNodeData, TEdgeData >::IsEdge().
const TNode& TNodeEdgeNet< TNodeData, TEdgeData >::GetNode | ( | const int & | NId | ) | const [inline, private] |
const TNode& TNodeEdgeNet< TNodeData, TEdgeData >::GetNodeKId | ( | const int & | NodeKeyId | ) | const [inline, private] |
int TNodeEdgeNet< TNodeData, TEdgeData >::GetNodes | ( | ) | const [inline] |
Returns the number of nodes in the network.
Definition at line 1172 of file network.h.
Referenced by TNodeEdgeNet< TSecTm, TSecTm >::Empty(), and TNodeEdgeNet< TNodeData, TEdgeData >::GetNIdV().
TEdgeI TNodeEdgeNet< TNodeData, TEdgeData >::GetRndEI | ( | TRnd & | Rnd = TInt::Rnd | ) | [inline] |
int TNodeEdgeNet< TNodeData, TEdgeData >::GetRndEId | ( | TRnd & | Rnd = TInt::Rnd | ) | [inline] |
Returns an ID of a random edge in the network.
Definition at line 1268 of file network.h.
Referenced by TNodeEdgeNet< TSecTm, TSecTm >::GetRndEI().
{ return EdgeH.GetKey(EdgeH.GetRndKeyId(Rnd, 0.8)); }
TNodeI TNodeEdgeNet< TNodeData, TEdgeData >::GetRndNI | ( | TRnd & | Rnd = TInt::Rnd | ) | [inline] |
int TNodeEdgeNet< TNodeData, TEdgeData >::GetRndNId | ( | TRnd & | Rnd = TInt::Rnd | ) | [inline] |
Returns an ID of a random node in the network.
Definition at line 1264 of file network.h.
Referenced by TNodeEdgeNet< TSecTm, TSecTm >::GetRndNI().
{ return NodeH.GetKey(NodeH.GetRndKeyId(Rnd, 0.8)); }
int TNodeEdgeNet< TNodeData, TEdgeData >::GetUniqEdges | ( | const bool & | IsDir = true | ) | const |
Returns the number of edges in the network with a unique pair of nodes.
Definition at line 1391 of file network.h.
References THashSet< TKey, THashFunc >::AddKey(), TNodeEdgeNet< TNodeData, TEdgeData >::BegEI(), TNodeEdgeNet< TNodeData, TEdgeData >::EndEI(), TNodeEdgeNet< TNodeData, TEdgeData >::GetEdges(), THashSet< TKey, THashFunc >::Len(), TMath::Mn(), and TMath::Mx().
{ TIntPrSet UniqESet(GetEdges()); for (TEdgeI EI = BegEI(); EI < EndEI(); EI++) { const int Src = EI.GetSrcNId(); const int Dst = EI.GetDstNId(); if (IsDir) { UniqESet.AddKey(TIntPr(Src, Dst)); } else { UniqESet.AddKey(TIntPr(TMath::Mn(Src, Dst), TMath::Mx(Src, Dst))); } } return UniqESet.Len(); }
bool TNodeEdgeNet< TNodeData, TEdgeData >::HasFlag | ( | const TGraphFlag & | Flag | ) | const |
Allows for run-time checking the type of the network (see the TGraphFlag for flags).
Definition at line 1316 of file network.h.
References HasGraphFlag.
{ return HasGraphFlag(typename TNet, Flag); }
bool TNodeEdgeNet< TNodeData, TEdgeData >::IsEdge | ( | const int & | EId | ) | const [inline] |
Tests whether an edge with ID EId exists in the network.
Definition at line 1240 of file network.h.
Referenced by TNodeEdgeNet< TNodeData, TEdgeData >::AddEdge(), TNodeEdgeNet< TNodeData, TEdgeData >::DelEdge(), TNodeEdgeNet< TSecTm, TSecTm >::GetEId(), TNodeEdgeNet< TNodeData, TEdgeData >::IsOk(), and TNodeEdgeNet< TNodeData, TEdgeData >::SetEDat().
bool TNodeEdgeNet< TNodeData, TEdgeData >::IsEdge | ( | const int & | SrcNId, |
const int & | DstNId, | ||
const bool & | IsDir = true |
||
) | const [inline] |
Tests whether an edge from node IDs SrcNId to DstNId exists in the network.
Definition at line 1242 of file network.h.
Referenced by TNodeEdgeNet< TSecTm, TSecTm >::IsEdge().
{ int EId; return IsEdge(SrcNId, DstNId, EId, IsDir); }
bool TNodeEdgeNet< TNodeData, TEdgeData >::IsEdge | ( | const int & | SrcNId, |
const int & | DstNId, | ||
int & | EId, | ||
const bool & | IsDir = true |
||
) | const |
Tests whether an edge from node IDs SrcNId to DstNId with edge ID EId exists in the network.
Definition at line 1446 of file network.h.
References TNodeEdgeNet< TNodeData, TEdgeData >::TEdge::GetDstNId(), TNodeEdgeNet< TNodeData, TEdgeData >::GetEdge(), TNodeEdgeNet< TNodeData, TEdgeData >::TEdge::GetId(), TNodeEdgeNet< TNodeData, TEdgeData >::TNode::GetInDeg(), TNodeEdgeNet< TNodeData, TEdgeData >::TNode::GetInEId(), TNodeEdgeNet< TNodeData, TEdgeData >::GetNode(), TNodeEdgeNet< TNodeData, TEdgeData >::TNode::GetOutDeg(), TNodeEdgeNet< TNodeData, TEdgeData >::TNode::GetOutEId(), TNodeEdgeNet< TNodeData, TEdgeData >::TEdge::GetSrcNId(), and TNodeEdgeNet< TNodeData, TEdgeData >::IsNode().
{ if (! IsNode(SrcNId)) { return false; } if (! IsNode(DstNId)) { return false; } const TNode& SrcNode = GetNode(SrcNId); for (int edge = 0; edge < SrcNode.GetOutDeg(); edge++) { const TEdge& Edge = GetEdge(SrcNode.GetOutEId(edge)); if (DstNId == Edge.GetDstNId()) { EId = Edge.GetId(); return true; } } if (! IsDir) { for (int edge = 0; edge < SrcNode.GetInDeg(); edge++) { const TEdge& Edge = GetEdge(SrcNode.GetInEId(edge)); if (DstNId == Edge.GetSrcNId()) { EId = Edge.GetId(); return true; } } } return false; }
bool TNodeEdgeNet< TNodeData, TEdgeData >::IsNode | ( | const int & | NId | ) | const [inline] |
Tests whether ID NId is a node.
Definition at line 1194 of file network.h.
Referenced by TNodeEdgeNet< TNodeData, TEdgeData >::AddEdge(), TNodeEdgeNet< TNodeData, TEdgeData >::AddNode(), TTimeNENet::GetESubGraph(), TTimeNENet::GetGraphUpToTm(), TTimeNENet::GetSubGraph(), TNodeEdgeNet< TNodeData, TEdgeData >::IsEdge(), TNodeEdgeNet< TNodeData, TEdgeData >::IsOk(), and TNodeEdgeNet< TNodeData, TEdgeData >::SetNDat().
bool TNodeEdgeNet< TNodeData, TEdgeData >::IsOk | ( | const bool & | ThrowExcept = true | ) | const |
Checks the network data structure for internal consistency.
For each node in the network check that its neighbors are also nodes in the network.
Definition at line 1506 of file network.h.
References TStr::CStr(), EAssertR, TNodeEdgeNet< TNodeData, TEdgeData >::EdgeH, ErrNotify(), THash< TKey, TDat, THashFunc >::FFirstKeyId(), TStr::Fmt(), THash< TKey, TDat, THashFunc >::FNextKeyId(), TNodeEdgeNet< TNodeData, TEdgeData >::TEdge::GetDstNId(), TNodeEdgeNet< TNodeData, TEdgeData >::TNode::GetId(), TNodeEdgeNet< TNodeData, TEdgeData >::TEdge::GetId(), TNodeEdgeNet< TNodeData, TEdgeData >::TNode::GetInDeg(), TNodeEdgeNet< TNodeData, TEdgeData >::TNode::GetInEId(), TNodeEdgeNet< TNodeData, TEdgeData >::TNode::GetOutDeg(), TNodeEdgeNet< TNodeData, TEdgeData >::TNode::GetOutEId(), TNodeEdgeNet< TNodeData, TEdgeData >::TEdge::GetSrcNId(), TNodeEdgeNet< TNodeData, TEdgeData >::TNode::InEIdV, TNodeEdgeNet< TNodeData, TEdgeData >::IsEdge(), TNodeEdgeNet< TNodeData, TEdgeData >::IsNode(), TVec< TVal >::IsSorted(), TNodeEdgeNet< TNodeData, TEdgeData >::NodeH, and TNodeEdgeNet< TNodeData, TEdgeData >::TNode::OutEIdV.
{ bool RetVal = true; for (int N = NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) { const TNode& Node = NodeH[N]; if (! Node.OutEIdV.IsSorted()) { const TStr Msg = TStr::Fmt("Out-edge list of node %d is not sorted.", Node.GetId()); if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false; } if (! Node.InEIdV.IsSorted()) { const TStr Msg = TStr::Fmt("In-edge list of node %d is not sorted.", Node.GetId()); if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false; } // check out-edge ids int prevEId = -1; for (int e = 0; e < Node.GetOutDeg(); e++) { if (! IsEdge(Node.GetOutEId(e))) { const TStr Msg = TStr::Fmt("Out-edge id %d of node %d does not exist.", Node.GetOutEId(e), Node.GetId()); if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false; } if (e > 0 && prevEId == Node.GetOutEId(e)) { const TStr Msg = TStr::Fmt("Node %d has duplidate out-edge id %d.", Node.GetId(), Node.GetOutEId(e)); if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false; } prevEId = Node.GetOutEId(e); } // check in-edge ids prevEId = -1; for (int e = 0; e < Node.GetInDeg(); e++) { if (! IsEdge(Node.GetInEId(e))) { const TStr Msg = TStr::Fmt("Out-edge id %d of node %d does not exist.", Node.GetInEId(e), Node.GetId()); if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false; } if (e > 0 && prevEId == Node.GetInEId(e)) { const TStr Msg = TStr::Fmt("Node %d has duplidate out-edge id %d.", Node.GetId(), Node.GetInEId(e)); if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false; } prevEId = Node.GetInEId(e); } } for (int E = EdgeH.FFirstKeyId(); EdgeH.FNextKeyId(E); ) { const TEdge& Edge = EdgeH[E]; if (! IsNode(Edge.GetSrcNId())) { const TStr Msg = TStr::Fmt("Edge %d source node %d does not exist.", Edge.GetId(), Edge.GetSrcNId()); if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false; } if (! IsNode(Edge.GetDstNId())) { const TStr Msg = TStr::Fmt("Edge %d destination node %d does not exist.", Edge.GetId(), Edge.GetDstNId()); if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false; } } return RetVal; }
static PNet TNodeEdgeNet< TNodeData, TEdgeData >::Load | ( | TSIn & | SIn | ) | [inline, static] |
Static constructor that loads the network from a stream SIn and returns a pointer to it.
Reimplemented in TTimeNENet.
static PNet TNodeEdgeNet< TNodeData, TEdgeData >::New | ( | ) | [inline, static] |
Static constructor that returns a pointer to the network. Call: TPt <TNodeEdgeNet<TNodeData, TEdgeData> > Net = TNodeEdgeNet<TNodeData, TEdgeData>::New().
Reimplemented in TTimeNENet.
TNodeEdgeNet& TNodeEdgeNet< TNodeData, TEdgeData >::operator= | ( | const TNodeEdgeNet< TNodeData, TEdgeData > & | Net | ) | [inline] |
void TNodeEdgeNet< TNodeData, TEdgeData >::Reserve | ( | const int & | Nodes, |
const int & | Edges | ||
) | [inline] |
Reserves memory for a network of Nodes nodes and Edges edges.
Definition at line 1281 of file network.h.
Referenced by TTimeNENet::GetESubGraph(), TTimeNENet::GetSubGraph(), and TNodeEdgeNet< TSecTm, TSecTm >::TNodeEdgeNet().
virtual void TNodeEdgeNet< TNodeData, TEdgeData >::Save | ( | TSOut & | SOut | ) | const [inline, virtual] |
void TNodeEdgeNet< TNodeData, TEdgeData >::SetAllEDat | ( | const TEdgeData & | EdgeDat | ) |
Sets edge data for all the edges in the network to EDat.
Definition at line 1472 of file network.h.
References TNodeEdgeNet< TNodeData, TEdgeData >::BegEI(), and TNodeEdgeNet< TNodeData, TEdgeData >::EndEI().
void TNodeEdgeNet< TNodeData, TEdgeData >::SetEDat | ( | const int & | EId, |
const TEdgeData & | EdgeDat | ||
) |
Sets edge data for the edge of ID NId in the network.
Definition at line 1466 of file network.h.
References TStr::Fmt(), TNodeEdgeNet< TNodeData, TEdgeData >::TEdgeI::GetDat(), TNodeEdgeNet< TNodeData, TEdgeData >::GetEI(), IAssertR, and TNodeEdgeNet< TNodeData, TEdgeData >::IsEdge().
{ IAssertR(IsEdge(EId), TStr::Fmt("EdgeId %d does not exist.", EId).CStr()); GetEI(EId).GetDat() = EdgeDat; }
void TNodeEdgeNet< TNodeData, TEdgeData >::SetNDat | ( | const int & | NId, |
const TNodeData & | NodeDat | ||
) |
Sets node data for the node of ID NId in the network.
Definition at line 1385 of file network.h.
References TStr::Fmt(), THash< TKey, TDat, THashFunc >::GetDat(), IAssertR, TNodeEdgeNet< TNodeData, TEdgeData >::IsNode(), TNodeEdgeNet< TNodeData, TEdgeData >::TNode::NodeDat, and TNodeEdgeNet< TNodeData, TEdgeData >::NodeH.
{ IAssertR(IsNode(NId), TStr::Fmt("NodeId %d does not exist.", NId).CStr()); NodeH.GetDat(NId).NodeDat = NodeDat; }
void TNodeEdgeNet< TNodeData, TEdgeData >::SortEIdByDat | ( | const bool & | Asc = true | ) | [inline] |
void TNodeEdgeNet< TNodeData, TEdgeData >::SortEIdById | ( | const bool & | Asc = true | ) | [inline] |
void TNodeEdgeNet< TNodeData, TEdgeData >::SortNIdByDat | ( | const bool & | Asc = true | ) | [inline] |
void TNodeEdgeNet< TNodeData, TEdgeData >::SortNIdById | ( | const bool & | Asc = true | ) | [inline] |
friend class TPt< TNodeEdgeNet< TNodeData, TEdgeData > > [friend] |
TCRef TNodeEdgeNet< TNodeData, TEdgeData >::CRef [protected] |
THash<TInt, TEdge> TNodeEdgeNet< TNodeData, TEdgeData >::EdgeH [protected] |
Definition at line 1151 of file network.h.
Referenced by TNodeEdgeNet< TNodeData, TEdgeData >::AddEdge(), TNodeEdgeNet< TSecTm, TSecTm >::BegEI(), TNodeEdgeNet< TSecTm, TSecTm >::Clr(), TNodeEdgeNet< TNodeData, TEdgeData >::Defrag(), TNodeEdgeNet< TNodeData, TEdgeData >::DelEdge(), TNodeEdgeNet< TNodeData, TEdgeData >::DelNode(), TNodeEdgeNet< TSecTm, TSecTm >::EndEI(), TNodeEdgeNet< TSecTm, TSecTm >::GetEDat(), TNodeEdgeNet< TSecTm, TSecTm >::GetEdge(), TNodeEdgeNet< TSecTm, TSecTm >::GetEdgeKId(), TNodeEdgeNet< TSecTm, TSecTm >::GetEdges(), TNodeEdgeNet< TSecTm, TSecTm >::GetEI(), TNodeEdgeNet< TNodeData, TEdgeData >::GetEIdV(), TNodeEdgeNet< TSecTm, TSecTm >::GetRndEId(), TNodeEdgeNet< TSecTm, TSecTm >::IsEdge(), TNodeEdgeNet< TNodeData, TEdgeData >::IsOk(), TNodeEdgeNet< TSecTm, TSecTm >::operator=(), TNodeEdgeNet< TSecTm, TSecTm >::Reserve(), TNodeEdgeNet< TSecTm, TSecTm >::Save(), TNodeEdgeNet< TSecTm, TSecTm >::SortEIdByDat(), and TNodeEdgeNet< TSecTm, TSecTm >::SortEIdById().
TInt TNodeEdgeNet< TNodeData, TEdgeData >::MxEId [protected] |
Definition at line 1149 of file network.h.
Referenced by TNodeEdgeNet< TNodeData, TEdgeData >::AddEdge(), TNodeEdgeNet< TSecTm, TSecTm >::Clr(), TNodeEdgeNet< TSecTm, TSecTm >::operator=(), and TNodeEdgeNet< TSecTm, TSecTm >::Save().
TInt TNodeEdgeNet< TNodeData, TEdgeData >::MxNId [protected] |
Definition at line 1149 of file network.h.
Referenced by TNodeEdgeNet< TNodeData, TEdgeData >::AddNode(), TNodeEdgeNet< TSecTm, TSecTm >::Clr(), TNodeEdgeNet< TSecTm, TSecTm >::GetMxNId(), TNodeEdgeNet< TSecTm, TSecTm >::operator=(), and TNodeEdgeNet< TSecTm, TSecTm >::Save().
THash<TInt, TNode> TNodeEdgeNet< TNodeData, TEdgeData >::NodeH [protected] |
Definition at line 1150 of file network.h.
Referenced by TNodeEdgeNet< TNodeData, TEdgeData >::AddNode(), TNodeEdgeNet< TSecTm, TSecTm >::BegNI(), TNodeEdgeNet< TSecTm, TSecTm >::Clr(), TNodeEdgeNet< TNodeData, TEdgeData >::Defrag(), TNodeEdgeNet< TNodeData, TEdgeData >::DelNode(), TNodeEdgeNet< TSecTm, TSecTm >::EndNI(), TNodeEdgeNet< TSecTm, TSecTm >::GetNDat(), TNodeEdgeNet< TSecTm, TSecTm >::GetNI(), TNodeEdgeNet< TNodeData, TEdgeData >::GetNIdV(), TNodeEdgeNet< TSecTm, TSecTm >::GetNode(), TNodeEdgeNet< TSecTm, TSecTm >::GetNodeKId(), TNodeEdgeNet< TSecTm, TSecTm >::GetNodes(), TNodeEdgeNet< TSecTm, TSecTm >::GetRndNId(), TNodeEdgeNet< TSecTm, TSecTm >::IsNode(), TNodeEdgeNet< TNodeData, TEdgeData >::IsOk(), TNodeEdgeNet< TSecTm, TSecTm >::operator=(), TNodeEdgeNet< TSecTm, TSecTm >::Reserve(), TNodeEdgeNet< TSecTm, TSecTm >::Save(), TNodeEdgeNet< TNodeData, TEdgeData >::SetNDat(), TNodeEdgeNet< TSecTm, TSecTm >::SortNIdByDat(), and TNodeEdgeNet< TSecTm, TSecTm >::SortNIdById().