SNAP Library 2.0, User Reference
2013-05-13 16:33:57
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <ds.h>
Public Member Functions | |
TTree () | |
TTree (const TTree &Tree) | |
TTree (TSIn &SIn) | |
void | Save (TSOut &SOut) const |
void | LoadXml (const PXmlTok &XmlTok, const TStr &Nm="") |
void | SaveXml (TSOut &SOut, const TStr &Nm) const |
TTree & | operator= (const TTree &Tree) |
bool | operator== (const TTree &Tree) const |
bool | operator< (const TTree &Tree) const |
int | GetPrimHashCd () const |
int | GetSecHashCd () const |
int | GetMemUsed () const |
void | Clr () |
int | AddNode (const int &ParentNodeId, const TVal &NodeVal=TVal()) |
int | AddRoot (const TVal &NodeVal=TVal()) |
int | GetNodes () const |
void | GetNodeIdV (TIntV &NodeIdV, const int &NodeId=0) |
int | GetParentNodeId (const int &NodeId) const |
int | GetChildren (const int &NodeId) const |
int | GetChildNodeId (const int &NodeId, const int &ChildN) const |
TVal & | GetNodeVal (const int &NodeId) |
void | GenRandomTree (const int &Nodes, TRnd &Rnd) |
void | DelNode (const int &NodeId) |
void | CopyTree (const int &SrcNodeId, TTree &DstTree, const int &DstParentNodeId=-1) |
void | WrTree (const int &NodeId=0, const int &Lev=0) |
Private Attributes | |
TVec< TTriple< TInt, TIntV, TVal > > | NodeV |
void TTree< TVal >::CopyTree | ( | const int & | SrcNodeId, |
TTree< TVal > & | DstTree, | ||
const int & | DstParentNodeId = -1 |
||
) |
Definition at line 3405 of file ds.h.
{ int DstNodeId=DstTree.AddNode(DstParentNodeId, GetNodeVal(SrcNodeId)); for (int ChildN=0; ChildN<GetChildren(SrcNodeId); ChildN++){ int ChildNodeId=GetChildNodeId(SrcNodeId, ChildN); if (ChildNodeId!=-1){ CopyTree(ChildNodeId, DstTree, DstNodeId); } } }
Definition at line 3394 of file ds.h.
{ if (NodeId==0){ Clr(); } else { TIntV& ChildNodeIdV=NodeV[GetParentNodeId(NodeId)].Val2; int ChildNodeIdN=ChildNodeIdV.SearchForw(NodeId); ChildNodeIdV[ChildNodeIdN]=-1; } }
void TTree< TVal >::GenRandomTree | ( | const int & | Nodes, |
TRnd & | Rnd | ||
) |
int TTree< TVal >::GetChildNodeId | ( | const int & | NodeId, |
const int & | ChildN | ||
) | const [inline] |
int TTree< TVal >::GetChildren | ( | const int & | NodeId | ) | const [inline] |
int TTree< TVal >::GetMemUsed | ( | ) | const [inline] |
Definition at line 3342 of file ds.h.
{return NodeV.GetMemUsed();}
void TTree< TVal >::GetNodeIdV | ( | TIntV & | NodeIdV, |
const int & | NodeId = 0 |
||
) |
Definition at line 3369 of file ds.h.
{ if (NodeId==0){NodeIdV.Clr(); if (GetNodes()==0){return;}} else if (GetParentNodeId(NodeId)==-1){return;} NodeIdV.Add(NodeId); for (int ChildN=0; ChildN<GetChildren(NodeId); ChildN++){ int ChildNodeId=GetChildNodeId(NodeId, ChildN); if (ChildNodeId!=-1){ GetNodeIdV(NodeIdV, ChildNodeId); } } }
TVal& TTree< TVal >::GetNodeVal | ( | const int & | NodeId | ) | [inline] |
int TTree< TVal >::GetParentNodeId | ( | const int & | NodeId | ) | const [inline] |
int TTree< TVal >::GetPrimHashCd | ( | ) | const [inline] |
Definition at line 3339 of file ds.h.
{return NodeV.GetPrimHashCd();}
int TTree< TVal >::GetSecHashCd | ( | ) | const [inline] |
Definition at line 3340 of file ds.h.
{return NodeV.GetSecHashCd();}
Definition at line 3416 of file ds.h.
{ for (int LevN=0; LevN<Lev; LevN++){printf("| ");} printf("%d (%d)\n", NodeId, GetChildren(NodeId)); for (int ChildN=0; ChildN<GetChildren(NodeId); ChildN++){ int ChildNodeId=GetChildNodeId(NodeId, ChildN); if (ChildNodeId!=-1){ WrTree(ChildNodeId, Lev+1); } } }