SNAP Library 6.0, Developer Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
TNodeEDatNet< TNodeData, TEdgeData > Class Template Reference

Node Edge Network (directed graph, TNGraph with data on nodes and edges). More...

#include <network.h>

Collaboration diagram for TNodeEDatNet< TNodeData, TEdgeData >:

Classes

class  TEdgeI
 Edge iterator. Only forward iteration (operator++) is supported. More...
 
class  TNode
 
class  TNodeFunctor
 
class  TNodeI
 Node iterator. Only forward iteration (operator++) is supported. More...
 

Public Types

typedef TNodeData TNodeDat
 
typedef TEdgeData TEdgeDat
 
typedef TNodeEDatNet< TNodeData, TEdgeData > TNet
 
typedef TPt< TNetPNet
 
typedef TVec< TPair< TInt, TEdgeData > > TNIdDatPrV
 

Public Member Functions

 TNodeEDatNet ()
 
 TNodeEDatNet (const int &Nodes, const int &Edges)
 Constructor that reserves enough memory for a network of Nodes nodes and Edges edges. More...
 
 TNodeEDatNet (const TNodeEDatNet &NodeNet)
 
 TNodeEDatNet (TSIn &SIn)
 Constructor that loads the network from a (binary) stream SIn. More...
 
virtual ~TNodeEDatNet ()
 
virtual void Save (TSOut &SOut) const
 Saves the network to a (binary) stream SOut. More...
 
bool HasFlag (const TGraphFlag &Flag) const
 Allows for run-time checking the type of the network (see the TGraphFlag for flags). More...
 
TNodeEDatNetoperator= (const TNodeEDatNet &NodeNet)
 
int GetNodes () const
 Returns the number of nodes in the network. More...
 
int AddNode (int NId=-1)
 Adds a node of ID NId to the network. More...
 
int AddNodeUnchecked (int NId=-1)
 Adds a node of ID NId to the network, noop if the node already exists. More...
 
int AddNode (int NId, const TNodeData &NodeDat)
 Adds a node of ID NId and node data NodeDat to the network. More...
 
int AddNode (const TNodeI &NodeI)
 Adds a node NodeI and its node data to the network. More...
 
void DelNode (const int &NId)
 Deletes node of ID NId from the network. More...
 
void DelNode (const TNode &NodeI)
 Deletes node of ID NodeI.GetId() from the network. More...
 
bool IsNode (const int &NId) const
 Tests whether ID NId is a node. More...
 
TNodeI BegNI () const
 Returns an iterator referring to the first node in the network. More...
 
TNodeI EndNI () const
 Returns an iterator referring to the past-the-end node in the network. More...
 
TNodeI GetNI (const int &NId) const
 Returns an iterator referring to the node of ID NId in the network. More...
 
const TNodeGetNode (const int &NId) const
 Returns node element for the node of ID NId in the network. More...
 
void SetNDat (const int &NId, const TNodeData &NodeDat)
 Sets node data for the node of ID NId in the network. More...
 
TNodeData & GetNDat (const int &NId)
 Returns node data for the node of ID NId in the network. More...
 
const TNodeData & GetNDat (const int &NId) const
 Returns node data for the node of ID NId in the network. More...
 
int GetMxNId () const
 Returns an ID that is larger than any node ID in the network. More...
 
int GetEdges () const
 Returns the number of edges in the network. More...
 
int AddEdge (const int &SrcNId, const int &DstNId)
 Adds an edge from node SrcNId to node DstNId to the network. More...
 
int AddEdge (const int &SrcNId, const int &DstNId, const TEdgeData &EdgeDat)
 Adds an edge and edge data from node IDs SrcNId to node DstNId. More...
 
int AddEdge (const TEdgeI &EdgeI)
 Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() and its edge data to the network. More...
 
void DelEdge (const int &SrcNId, const int &DstNId, const bool &IsDir=true)
 Deletes an edge from node IDs SrcNId to DstNId from the network. More...
 
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. More...
 
TEdgeI BegEI () const
 Returns an iterator referring to the first edge in the network. More...
 
TEdgeI EndEI () const
 Returns an iterator referring to the past-the-end edge in the network. More...
 
TEdgeI GetEI (const int &EId) const
 Not supported/implemented! More...
 
TEdgeI GetEI (const int &SrcNId, const int &DstNId) const
 Returns an iterator referring to edge (SrcNId, DstNId) in the network. More...
 
void SetEDat (const int &SrcNId, const int &DstNId, const TEdgeData &EdgeDat)
 Sets edge data for the edge between nodes SrcNId and DstNId in the network. More...
 
bool GetEDat (const int &SrcNId, const int &DstNId, TEdgeData &EdgeDat) const
 Returns edge data in Data for the edge from node IDs SrcNId to DstNId. More...
 
TEdgeData & GetEDat (const int &SrcNId, const int &DstNId)
 Returns edge data for the edge from node IDs SrcNId to DstNId. More...
 
const TEdgeData & GetEDat (const int &SrcNId, const int &DstNId) const
 Returns edge data for the edge from node IDs SrcNId to DstNId. More...
 
void SetAllEDat (const TEdgeData &EdgeDat)
 Sets edge data for all the edges in the network to EDat. More...
 
int GetRndNId (TRnd &Rnd=TInt::Rnd)
 Returns an ID of a random node in the network. More...
 
TNodeI GetRndNI (TRnd &Rnd=TInt::Rnd)
 Returns an interator referring to a random node in the network. More...
 
void GetNIdV (TIntV &NIdV) const
 Gets a vector IDs of all nodes in the network. More...
 
bool Empty () const
 Tests whether the network is empty (has zero nodes). More...
 
void Clr (const bool &DoDel=true, const bool &ResetDat=true)
 Deletes all nodes and edges from the network. More...
 
void Reserve (const int &Nodes, const int &Edges)
 Reserves memory for a network of Nodes nodes and Edges edges. More...
 
void SortNIdById (const bool &Asc=true)
 Sorts nodes by node IDs. More...
 
void SortNIdByDat (const bool &Asc=true)
 Sorts nodes by node data. More...
 
void Defrag (const bool &OnlyNodeLinks=false)
 Defragments the network. More...
 
bool IsOk (const bool &ThrowExcept=true) const
 Checks the network data structure for internal consistency. More...
 

Static Public Member Functions

static PNet New ()
 Static constructor that returns a pointer to the network. Call: TPt <TNodeEDatNet<TNodeData, TEdgeData> > Net = TNodeEDatNet<TNodeData, TEdgeData>::New(). More...
 
static PNet Load (TSIn &SIn)
 Static constructor that loads the network from a stream SIn and returns a pointer to it. More...
 
static PNet LoadShM (TShMIn &ShMIn)
 Static constructor that loads the network from shared memory. More...
 

Protected Member Functions

TNodeGetNode (const int &NId)
 

Static Protected Member Functions

static int GetNIdPos (const TVec< TPair< TInt, TEdgeData > > &NIdV, const int &NId)
 

Protected Attributes

TCRef CRef
 
TInt MxNId
 
THash< TInt, TNodeNodeH
 

Private Member Functions

void LoadNetworkShM (TShMIn &ShMIn)
 

Friends

class TPt< TNodeEDatNet< TNodeData, TEdgeData > >
 

Detailed Description

template<class TNodeData, class TEdgeData>
class TNodeEDatNet< TNodeData, TEdgeData >

Node Edge Network (directed graph, TNGraph with data on nodes and edges).

Definition at line 491 of file network.h.

Member Typedef Documentation

template<class TNodeData, class TEdgeData>
typedef TPt<TNet> TNodeEDatNet< TNodeData, TEdgeData >::PNet

Definition at line 496 of file network.h.

template<class TNodeData, class TEdgeData>
typedef TEdgeData TNodeEDatNet< TNodeData, TEdgeData >::TEdgeDat

Definition at line 494 of file network.h.

template<class TNodeData, class TEdgeData>
typedef TNodeEDatNet<TNodeData, TEdgeData> TNodeEDatNet< TNodeData, TEdgeData >::TNet

Definition at line 495 of file network.h.

template<class TNodeData, class TEdgeData>
typedef TVec<TPair<TInt, TEdgeData> > TNodeEDatNet< TNodeData, TEdgeData >::TNIdDatPrV

Definition at line 497 of file network.h.

template<class TNodeData, class TEdgeData>
typedef TNodeData TNodeEDatNet< TNodeData, TEdgeData >::TNodeDat

Definition at line 493 of file network.h.

Constructor & Destructor Documentation

template<class TNodeData, class TEdgeData>
TNodeEDatNet< TNodeData, TEdgeData >::TNodeEDatNet ( )
inline

Definition at line 651 of file network.h.

651 : CRef(), MxNId(0), NodeH() { }
TCRef CRef
Definition: network.h:635
THash< TInt, TNode > NodeH
Definition: network.h:637
TInt MxNId
Definition: network.h:636
template<class TNodeData, class TEdgeData>
TNodeEDatNet< TNodeData, TEdgeData >::TNodeEDatNet ( const int &  Nodes,
const int &  Edges 
)
inlineexplicit

Constructor that reserves enough memory for a network of Nodes nodes and Edges edges.

Definition at line 653 of file network.h.

653 : MxNId(0) { Reserve(Nodes, Edges); }
TInt MxNId
Definition: network.h:636
void Reserve(const int &Nodes, const int &Edges)
Reserves memory for a network of Nodes nodes and Edges edges.
Definition: network.h:789
template<class TNodeData, class TEdgeData>
TNodeEDatNet< TNodeData, TEdgeData >::TNodeEDatNet ( const TNodeEDatNet< TNodeData, TEdgeData > &  NodeNet)
inline

Definition at line 654 of file network.h.

654 : MxNId(NodeNet.MxNId), NodeH(NodeNet.NodeH) { }
THash< TInt, TNode > NodeH
Definition: network.h:637
TInt MxNId
Definition: network.h:636
template<class TNodeData, class TEdgeData>
TNodeEDatNet< TNodeData, TEdgeData >::TNodeEDatNet ( TSIn SIn)
inline

Constructor that loads the network from a (binary) stream SIn.

Definition at line 656 of file network.h.

656 : MxNId(SIn), NodeH(SIn) { }
THash< TInt, TNode > NodeH
Definition: network.h:637
TInt MxNId
Definition: network.h:636
template<class TNodeData, class TEdgeData>
virtual TNodeEDatNet< TNodeData, TEdgeData >::~TNodeEDatNet ( )
inlinevirtual

Definition at line 657 of file network.h.

657 { }

Member Function Documentation

template<class TNodeData , class TEdgeData >
int TNodeEDatNet< TNodeData, TEdgeData >::AddEdge ( const int &  SrcNId,
const int &  DstNId 
)

Adds an edge from node SrcNId to node DstNId to the network.

If the edge already exists return -2. If the edge does not exist and was successfully added return -1. Normally the function should return an ID of the edge added but since edges in TNodeEDatNet have no IDs we return -1. Function aborts if SrcNId or DstNId are not nodes in the network.

Definition at line 906 of file network.h.

Referenced by TNIBs::LoadGroundTruthTxt(), TNIBs::LoadInferredTxt(), and TNIBs::UpdateDiff().

906  {
907  return AddEdge(SrcNId, DstNId, TEdgeData());
908 }
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge from node SrcNId to node DstNId to the network.
Definition: network.h:906

Here is the caller graph for this function:

template<class TNodeData , class TEdgeData>
int TNodeEDatNet< TNodeData, TEdgeData >::AddEdge ( const int &  SrcNId,
const int &  DstNId,
const TEdgeData &  EdgeDat 
)

Adds an edge and edge data from node IDs SrcNId to node DstNId.

If the edge already exists, set edges data and returns -2. If the edge does not exist and was successfully added returns -1. Normally the function should return an ID of the edge added but since edges in TNodeEDatNet have no IDs it returns -1. Function aborts if SrcNId or DstNId are not nodes in the network.

Definition at line 911 of file network.h.

References TStr::Fmt(), and IAssertR.

911  {
912  IAssertR(IsNode(SrcNId) && IsNode(DstNId), TStr::Fmt("%d or %d not a node.", SrcNId, DstNId).CStr());
913  //IAssert(! IsEdge(SrcNId, DstNId));
914  if (IsEdge(SrcNId, DstNId)) {
915  GetEDat(SrcNId, DstNId) = EdgeDat;
916  return -2;
917  }
918  GetNode(SrcNId).OutNIdV.AddSorted(TPair<TInt, TEdgeData>(DstNId, EdgeDat));
919  GetNode(DstNId).InNIdV.AddSorted(SrcNId);
920  return -1; // no edge id
921 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:708
#define IAssertR(Cond, Reason)
Definition: bd.h:265
bool GetEDat(const int &SrcNId, const int &DstNId, TEdgeData &EdgeDat) const
Returns edge data in Data for the edge from node IDs SrcNId to DstNId.
Definition: network.h:953
TSizeTy AddSorted(const TVal &Val, const bool &Asc=true, const TSizeTy &_MxVals=-1)
Adds element Val to a sorted vector.
Definition: ds.h:1117
TNode & GetNode(const int &NId)
Definition: network.h:632
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.
Definition: network.h:939
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TNIdDatPrV OutNIdV
Definition: network.h:504

Here is the call graph for this function:

template<class TNodeData, class TEdgeData>
int TNodeEDatNet< 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 746 of file network.h.

Referenced by TNodeEDatNet< TStr, TFltFltH >::AddEdge().

746 { return AddEdge(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), EdgeI()); }
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge from node SrcNId to node DstNId to the network.
Definition: network.h:906

Here is the caller graph for this function:

template<class TNodeData , class TEdgeData >
int TNodeEDatNet< 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 836 of file network.h.

References TStr::Fmt(), IAssertR, and TMath::Mx().

Referenced by TNIBs::Init(), TNIBs::LoadGroundTruthNodesTxt(), TNIBs::LoadGroundTruthTxt(), TNIBs::LoadInferredNodesTxt(), and TNIBs::LoadInferredTxt().

836  {
837  if (NId == -1) {
838  NId = MxNId; MxNId++;
839  } else {
840  IAssertR(!IsNode(NId), TStr::Fmt("NodeId %d already exists", NId));
841  MxNId = TMath::Mx(NId+1, MxNId());
842  }
843  NodeH.AddDat(NId, TNode(NId));
844  return NId;
845 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:708
#define IAssertR(Cond, Reason)
Definition: bd.h:265
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32
THash< TInt, TNode > NodeH
Definition: network.h:637
TInt MxNId
Definition: network.h:636
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TDat & AddDat(const TKey &Key)
Definition: hash.h:238

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TNodeData, class TEdgeData >
int TNodeEDatNet< TNodeData, TEdgeData >::AddNode ( int  NId,
const TNodeData &  NodeDat 
)

Adds a node of ID NId and node data NodeDat 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 860 of file network.h.

References TStr::Fmt(), IAssertR, and TMath::Mx().

860  {
861  if (NId == -1) {
862  NId = MxNId; MxNId++;
863  } else {
864  IAssertR(!IsNode(NId), TStr::Fmt("NodeId %d already exists", NId));
865  MxNId = TMath::Mx(NId+1, MxNId());
866  }
867  NodeH.AddDat(NId, TNode(NId, NodeDat));
868  return NId;
869 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:708
#define IAssertR(Cond, Reason)
Definition: bd.h:265
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32
THash< TInt, TNode > NodeH
Definition: network.h:637
TInt MxNId
Definition: network.h:636
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TDat & AddDat(const TKey &Key)
Definition: hash.h:238

Here is the call graph for this function:

template<class TNodeData, class TEdgeData>
int TNodeEDatNet< TNodeData, TEdgeData >::AddNode ( const TNodeI NodeI)
inline

Adds a node NodeI and its node data to the network.

Definition at line 700 of file network.h.

Referenced by TNodeEDatNet< TStr, TFltFltH >::AddNode().

700 { return AddNode(NodeI.GetId(), NodeI.GetDat()); }
int AddNode(int NId=-1)
Adds a node of ID NId to the network.
Definition: network.h:836

Here is the caller graph for this function:

template<class TNodeData , class TEdgeData >
int TNodeEDatNet< TNodeData, TEdgeData >::AddNodeUnchecked ( int  NId = -1)

Adds a node of ID NId to the network, noop if the node already exists.

Returns -1, if the node NId already exists. Otherwise, it returns the ID of the node being added. If NId is -1, node ID is automatically assigned.

Definition at line 848 of file network.h.

References TMath::Mx().

848  {
849  if (NId == -1) {
850  NId = MxNId; MxNId++;
851  } else {
852  if (IsNode(NId)) { return -1;}
853  MxNId = TMath::Mx(NId+1, MxNId());
854  }
855  NodeH.AddDat(NId, TNode(NId));
856  return NId;
857 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:708
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32
THash< TInt, TNode > NodeH
Definition: network.h:637
TInt MxNId
Definition: network.h:636
TDat & AddDat(const TKey &Key)
Definition: hash.h:238

Here is the call graph for this function:

template<class TNodeData, class TEdgeData>
TEdgeI TNodeEDatNet< TNodeData, TEdgeData >::BegEI ( ) const
inline

Returns an iterator referring to the first edge in the network.

Definition at line 756 of file network.h.

Referenced by TNIBs::BSG(), TNIBs::FG(), TNIBs::GetGroundTruthGraphAtT(), TNIBs::GetGroundTruthNetworkAtT(), TNIBs::GetInferredGraphAtT(), TNIBs::GetInferredNetworkAtT(), TNIBs::SaveGroundTruth(), TNIBs::SaveGroundTruthPajek(), TNIBs::SaveInferred(), TNIBs::SaveInferredEdges(), TNIBs::SaveInferredPajek(), and TNIBs::SG().

756 { TNodeI NI=BegNI(); while(NI<EndNI() && NI.GetOutDeg()==0) NI++; return TEdgeI(NI, EndNI()); }
int GetOutDeg() const
Returns out-degree of the current node.
Definition: network.h:559
TNodeI BegNI() const
Returns an iterator referring to the first node in the network.
Definition: network.h:710
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:712

Here is the caller graph for this function:

template<class TNodeData, class TEdgeData>
TNodeI TNodeEDatNet< TNodeData, TEdgeData >::BegNI ( ) const
inline

Returns an iterator referring to the first node in the network.

Definition at line 710 of file network.h.

Referenced by TNodeEDatNet< TStr, TFltFltH >::BegEI().

710 { return TNodeI(NodeH.BegI(), this); }
TIter BegI() const
Definition: hash.h:213
THash< TInt, TNode > NodeH
Definition: network.h:637

Here is the caller graph for this function:

template<class TNodeData, class TEdgeData>
void TNodeEDatNet< TNodeData, TEdgeData >::Clr ( const bool &  DoDel = true,
const bool &  ResetDat = true 
)
inline

Deletes all nodes and edges from the network.

Definition at line 786 of file network.h.

Referenced by TNIBs::Init(), TNIBs::LoadGroundTruthNodesTxt(), TNIBs::LoadGroundTruthTxt(), TNIBs::LoadInferredNodesTxt(), and TNIBs::LoadInferredTxt().

786  {
787  MxNId = 0; NodeH.Clr(DoDel, -1, ResetDat); }
THash< TInt, TNode > NodeH
Definition: network.h:637
TInt MxNId
Definition: network.h:636
void Clr(const bool &DoDel=true, const int &NoDelLim=-1, const bool &ResetDat=true)
Definition: hash.h:361

Here is the caller graph for this function:

template<class TNodeData , class TEdgeData >
void TNodeEDatNet< 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 1005 of file network.h.

References TNodeEDatNet< TNodeData, TEdgeData >::TNode::InNIdV, TNodeEDatNet< TNodeData, TEdgeData >::TNode::OutNIdV, and TVec< TVal, TSizeTy >::Pack().

1005  {
1006  for (int n = NodeH.FFirstKeyId(); NodeH.FNextKeyId(n);) {
1007  TNode& Node = NodeH[n];
1008  Node.InNIdV.Pack(); Node.OutNIdV.Pack();
1009  }
1010  if (! OnlyNodeLinks && ! NodeH.IsKeyIdEqKeyN()) {
1011  NodeH.Defrag();
1012  }
1013 }
bool IsKeyIdEqKeyN() const
Definition: hash.h:233
void Defrag()
Definition: hash.h:555
THash< TInt, TNode > NodeH
Definition: network.h:637
bool FNextKeyId(int &KeyId) const
Definition: hash.h:478
int FFirstKeyId() const
Definition: hash.h:278
void Pack()
Definition: hash.h:289

Here is the call graph for this function:

template<class TNodeData , class TEdgeData >
void TNodeEDatNet< 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 924 of file network.h.

References TStr::Fmt(), and IAssertR.

924  {
925  IAssertR(IsNode(SrcNId) && IsNode(DstNId), TStr::Fmt("%d or %d not a node.", SrcNId, DstNId).CStr());
926  int pos = GetNIdPos(GetNode(SrcNId).OutNIdV, DstNId);
927  if (pos != -1) { GetNode(SrcNId).OutNIdV.Del(pos); }
928  pos = GetNode(DstNId).InNIdV.SearchBin(SrcNId);
929  if (pos != -1) { GetNode(DstNId).InNIdV.Del(pos); }
930  if (! IsDir) {
931  pos = GetNIdPos(GetNode(DstNId).OutNIdV, SrcNId);
932  if (pos != -1) { GetNode(DstNId).OutNIdV.Del(pos); }
933  pos = GetNode(SrcNId).InNIdV.SearchBin(DstNId);
934  if (pos != -1) { GetNode(SrcNId).InNIdV.Del(pos); }
935  }
936 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:708
static int GetNIdPos(const TVec< TPair< TInt, TEdgeData > > &NIdV, const int &NId)
Definition: network.h:823
#define IAssertR(Cond, Reason)
Definition: bd.h:265
void Del(const TSizeTy &ValN)
Removes the element at position ValN.
Definition: ds.h:1189
TNode & GetNode(const int &NId)
Definition: network.h:632
TSizeTy SearchBin(const TVal &Val) const
Returns the position of an element with value Val.
Definition: ds.h:1519
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TNIdDatPrV OutNIdV
Definition: network.h:504

Here is the call graph for this function:

template<class TNodeData , class TEdgeData >
void TNodeEDatNet< 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 878 of file network.h.

References TVec< TVal, TSizeTy >::Del(), TNodeEDatNet< TNodeData, TEdgeData >::TNode::GetInDeg(), TNodeEDatNet< TNodeData, TEdgeData >::TNode::GetInNId(), TNodeEDatNet< TNodeData, TEdgeData >::TNode::GetOutDeg(), TNodeEDatNet< TNodeData, TEdgeData >::TNode::GetOutNId(), and TVec< TVal, TSizeTy >::SearchBin().

878  {
879  const TNode& Node = GetNode(NId);
880  for (int out = 0; out < Node.GetOutDeg(); out++) {
881  const int nbr = Node.GetOutNId(out);
882  if (nbr == NId) { continue; }
883  TIntV& NIdV = GetNode(nbr).InNIdV;
884  const int pos = NIdV.SearchBin(NId);
885  if (pos != -1) { NIdV.Del(pos); }
886  }
887  for (int in = 0; in < Node.GetInDeg(); in++) {
888  const int nbr = Node.GetInNId(in);
889  if (nbr == NId) { continue; }
890  TNIdDatPrV& NIdDatV = GetNode(nbr).OutNIdV;
891  const int pos = GetNIdPos(NIdDatV, NId);
892  if (pos != -1) { NIdDatV.Del(pos); }
893  }
894  NodeH.DelKey(NId);
895 }
static int GetNIdPos(const TVec< TPair< TInt, TEdgeData > > &NIdV, const int &NId)
Definition: network.h:823
void Del(const TSizeTy &ValN)
Removes the element at position ValN.
Definition: ds.h:1189
THash< TInt, TNode > NodeH
Definition: network.h:637
void DelKey(const TKey &Key)
Definition: hash.h:404
TNode & GetNode(const int &NId)
Definition: network.h:632
TVec< TPair< TInt, TEdgeData > > TNIdDatPrV
Definition: network.h:497
TSizeTy SearchBin(const TVal &Val) const
Returns the position of an element with value Val.
Definition: ds.h:1519
TNIdDatPrV OutNIdV
Definition: network.h:504

Here is the call graph for this function:

template<class TNodeData, class TEdgeData>
void TNodeEDatNet< TNodeData, TEdgeData >::DelNode ( const TNode NodeI)
inline

Deletes node of ID NodeI.GetId() from the network.

Definition at line 706 of file network.h.

Referenced by TNodeEDatNet< TStr, TFltFltH >::DelNode().

706 { DelNode(NodeI.GetId()); }
void DelNode(const int &NId)
Deletes node of ID NId from the network.
Definition: network.h:878

Here is the caller graph for this function:

template<class TNodeData, class TEdgeData>
bool TNodeEDatNet< TNodeData, TEdgeData >::Empty ( ) const
inline

Tests whether the network is empty (has zero nodes).

Definition at line 784 of file network.h.

784 { return GetNodes()==0; }
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:680
template<class TNodeData, class TEdgeData>
TEdgeI TNodeEDatNet< TNodeData, TEdgeData >::EndEI ( ) const
inline

Returns an iterator referring to the past-the-end edge in the network.

Definition at line 758 of file network.h.

Referenced by TNIBs::BSG(), TNIBs::FG(), TNIBs::GetGroundTruthGraphAtT(), TNIBs::GetGroundTruthNetworkAtT(), TNIBs::GetInferredGraphAtT(), TNIBs::GetInferredNetworkAtT(), TNIBs::SaveGroundTruth(), TNIBs::SaveGroundTruthPajek(), TNIBs::SaveInferred(), TNIBs::SaveInferredEdges(), TNIBs::SaveInferredPajek(), and TNIBs::SG().

758 { return TEdgeI(EndNI(), EndNI()); }
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:712

Here is the caller graph for this function:

template<class TNodeData, class TEdgeData>
TNodeI TNodeEDatNet< TNodeData, TEdgeData >::EndNI ( ) const
inline

Returns an iterator referring to the past-the-end node in the network.

Definition at line 712 of file network.h.

Referenced by TNodeEDatNet< TStr, TFltFltH >::BegEI(), and TNodeEDatNet< TStr, TFltFltH >::EndEI().

712 { return TNodeI(NodeH.EndI(), this); }
TIter EndI() const
Definition: hash.h:218
THash< TInt, TNode > NodeH
Definition: network.h:637

Here is the caller graph for this function:

template<class TNodeData , class TEdgeData>
bool TNodeEDatNet< TNodeData, TEdgeData >::GetEDat ( const int &  SrcNId,
const int &  DstNId,
TEdgeData &  EdgeDat 
) const

Returns edge data in Data for the edge from node IDs SrcNId to DstNId.

Returns true, if the edge was found. Otherwise, returns false.

Definition at line 953 of file network.h.

References TNodeEDatNet< TNodeData, TEdgeData >::TNode::GetOutEDat(), and TNodeEDatNet< TNodeData, TEdgeData >::TNode::OutNIdV.

Referenced by TNIBs::BSG(), TNIBs::ComputePerformanceNId(), TNIBs::FG(), TNIBs::GenCascade(), TNodeEDatNet< TNodeData, TEdgeData >::TNodeI::GetInEDat(), TNIBs::LabelBurstAutomaton(), TNIBs::LoadGroundTruthTxt(), TNIBs::LoadInferredTxt(), TNIBs::SG(), and TNIBs::UpdateDiff().

953  {
954  if (! IsEdge(SrcNId, DstNId)) { return false; }
955  const TNode& N = GetNode(SrcNId);
956  EdgeDat = N.GetOutEDat(GetNIdPos(N.OutNIdV, DstNId));
957  return true;
958 }
static int GetNIdPos(const TVec< TPair< TInt, TEdgeData > > &NIdV, const int &NId)
Definition: network.h:823
TNode & GetNode(const int &NId)
Definition: network.h:632
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.
Definition: network.h:939

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TNodeData , class TEdgeData>
TEdgeData & TNodeEDatNet< TNodeData, TEdgeData >::GetEDat ( const int &  SrcNId,
const int &  DstNId 
)

Returns edge data for the edge from node IDs SrcNId to DstNId.

Definition at line 961 of file network.h.

References Assert, TNodeEDatNet< TNodeData, TEdgeData >::TNode::GetOutEDat(), and TNodeEDatNet< TNodeData, TEdgeData >::TNode::OutNIdV.

961  {
962  Assert(IsEdge(SrcNId, DstNId));
963  TNode& N = GetNode(SrcNId);
964  return N.GetOutEDat(GetNIdPos(N.OutNIdV, DstNId));
965 }
static int GetNIdPos(const TVec< TPair< TInt, TEdgeData > > &NIdV, const int &NId)
Definition: network.h:823
TNode & GetNode(const int &NId)
Definition: network.h:632
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.
Definition: network.h:939
#define Assert(Cond)
Definition: bd.h:251

Here is the call graph for this function:

template<class TNodeData , class TEdgeData>
const TEdgeData & TNodeEDatNet< TNodeData, TEdgeData >::GetEDat ( const int &  SrcNId,
const int &  DstNId 
) const

Returns edge data for the edge from node IDs SrcNId to DstNId.

Definition at line 968 of file network.h.

References Assert, TNodeEDatNet< TNodeData, TEdgeData >::TNode::GetOutEDat(), and TNodeEDatNet< TNodeData, TEdgeData >::TNode::OutNIdV.

968  {
969  Assert(IsEdge(SrcNId, DstNId));
970  const TNode& N = GetNode(SrcNId);
971  return N.GetOutEDat(GetNIdPos(N.OutNIdV, DstNId));
972 }
static int GetNIdPos(const TVec< TPair< TInt, TEdgeData > > &NIdV, const int &NId)
Definition: network.h:823
TNode & GetNode(const int &NId)
Definition: network.h:632
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.
Definition: network.h:939
#define Assert(Cond)
Definition: bd.h:251

Here is the call graph for this function:

template<class TNodeData , class TEdgeData >
int TNodeEDatNet< TNodeData, TEdgeData >::GetEdges ( ) const

Returns the number of edges in the network.

Definition at line 898 of file network.h.

Referenced by TNIBs::LoadGroundTruthTxt(), and TNIBs::LoadInferredTxt().

898  {
899  int edges=0;
900  for (int N=NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
901  edges+=NodeH[N].GetOutDeg(); }
902  return edges;
903 }
THash< TInt, TNode > NodeH
Definition: network.h:637
bool FNextKeyId(int &KeyId) const
Definition: hash.h:478
int FFirstKeyId() const
Definition: hash.h:278

Here is the caller graph for this function:

template<class TNodeData, class TEdgeData>
TEdgeI TNodeEDatNet< TNodeData, TEdgeData >::GetEI ( const int &  EId) const

Not supported/implemented!

template<class TNodeData , class TEdgeData >
TNodeEDatNet< TNodeData, TEdgeData >::TEdgeI TNodeEDatNet< TNodeData, TEdgeData >::GetEI ( const int &  SrcNId,
const int &  DstNId 
) const

Returns an iterator referring to edge (SrcNId, DstNId) in the network.

Definition at line 982 of file network.h.

References TVec< TVal, TSizeTy >::Len(), and TNodeEDatNet< TNodeData, TEdgeData >::TNodeI::NodeHI.

982  {
983  const TNodeI SrcNI = GetNI(SrcNId);
984  int NodeN = -1;
985  //SrcNI.NodeHI.GetDat().OutNIdV.SearchBin(DstNId);
986  const TNIdDatPrV& NIdDatV = SrcNI.NodeHI.GetDat().OutNIdV;
987  int LValN=0, RValN=NIdDatV.Len()-1;
988  while (RValN>=LValN){
989  int ValN=(LValN+RValN)/2;
990  if (DstNId==NIdDatV[ValN].Val1){ NodeN=ValN; break; }
991  if (DstNId<NIdDatV[ValN].Val1){RValN=ValN-1;} else {LValN=ValN+1;}
992  }
993  if (NodeN == -1) { return EndEI(); }
994  else { return TEdgeI(SrcNI, EndNI(), NodeN); }
995 }
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the network.
Definition: network.h:758
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the network.
Definition: network.h:714
const TVal & GetDat(const TVal &Val) const
Returns reference to the first occurrence of element Val.
Definition: ds.h:838
TVec< TPair< TInt, TEdgeData > > TNIdDatPrV
Definition: network.h:497
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:712

Here is the call graph for this function:

template<class TNodeData, class TEdgeData>
int TNodeEDatNet< TNodeData, TEdgeData >::GetMxNId ( ) const
inline

Returns an ID that is larger than any node ID in the network.

Definition at line 724 of file network.h.

724 { return MxNId; }
TInt MxNId
Definition: network.h:636
template<class TNodeData, class TEdgeData>
TNodeData& TNodeEDatNet< TNodeData, TEdgeData >::GetNDat ( const int &  NId)
inline

Returns node data for the node of ID NId in the network.

Definition at line 720 of file network.h.

Referenced by TNodeEDatNet< TNodeData, TEdgeData >::TNodeI::GetInNDat(), TNodeEDatNet< TNodeData, TEdgeData >::TNodeI::GetNbrNDat(), and TNodeEDatNet< TNodeData, TEdgeData >::TNodeI::GetOutNDat().

720 { return NodeH.GetDat(NId).NodeDat; }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
THash< TInt, TNode > NodeH
Definition: network.h:637
TNodeData NodeDat
Definition: network.h:502

Here is the caller graph for this function:

template<class TNodeData, class TEdgeData>
const TNodeData& TNodeEDatNet< TNodeData, TEdgeData >::GetNDat ( const int &  NId) const
inline

Returns node data for the node of ID NId in the network.

Definition at line 722 of file network.h.

722 { return NodeH.GetDat(NId).NodeDat; }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
THash< TInt, TNode > NodeH
Definition: network.h:637
TNodeData NodeDat
Definition: network.h:502
template<class TNodeData, class TEdgeData>
TNodeI TNodeEDatNet< TNodeData, TEdgeData >::GetNI ( const int &  NId) const
inline

Returns an iterator referring to the node of ID NId in the network.

Definition at line 714 of file network.h.

Referenced by TNIBs::ComputePerformanceNId(), TNIBs::GenCascade(), and TNodeEDatNet< TStr, TFltFltH >::GetRndNI().

714 { return TNodeI(NodeH.GetI(NId), this); }
THash< TInt, TNode > NodeH
Definition: network.h:637
TIter GetI(const TKey &Key) const
Definition: hash.h:220

Here is the caller graph for this function:

template<class TNodeData , class TEdgeData>
int TNodeEDatNet< TNodeData, TEdgeData >::GetNIdPos ( const TVec< TPair< TInt, TEdgeData > > &  NIdV,
const int &  NId 
)
staticprotected

Definition at line 823 of file network.h.

Referenced by TNodeEDatNet< TNodeData, TEdgeData >::TNode::IsOutNId().

823  {
824  int LValN=0, RValN = NIdV.Len()-1;
825  while (RValN >= LValN) {
826  const int ValN = (LValN+RValN)/2;
827  const int CurNId = NIdV[ValN].Val1;
828  if (NId == CurNId) { return ValN; }
829  if (NId < CurNId) { RValN=ValN-1; }
830  else { LValN=ValN+1; }
831  }
832  return -1;
833 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575

Here is the caller graph for this function:

template<class TNodeData , class TEdgeData >
void TNodeEDatNet< TNodeData, TEdgeData >::GetNIdV ( TIntV NIdV) const

Gets a vector IDs of all nodes in the network.

Definition at line 998 of file network.h.

References TVec< TVal, TSizeTy >::Add(), and TVec< TVal, TSizeTy >::Reserve().

998  {
999  NIdV.Reserve(GetNodes(), 0);
1000  for (int N=NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
1001  NIdV.Add(NodeH.GetKey(N)); }
1002 }
THash< TInt, TNode > NodeH
Definition: network.h:637
bool FNextKeyId(int &KeyId) const
Definition: hash.h:478
int FFirstKeyId() const
Definition: hash.h:278
void Reserve(const TSizeTy &_MxVals)
Reserves enough memory for the vector to store _MxVals elements.
Definition: ds.h:543
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:252
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:680

Here is the call graph for this function:

template<class TNodeData, class TEdgeData>
TNode& TNodeEDatNet< TNodeData, TEdgeData >::GetNode ( const int &  NId)
inlineprotected

Definition at line 632 of file network.h.

632 { return NodeH.GetDat(NId); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
THash< TInt, TNode > NodeH
Definition: network.h:637
template<class TNodeData, class TEdgeData>
const TNode& TNodeEDatNet< TNodeData, TEdgeData >::GetNode ( const int &  NId) const
inline

Returns node element for the node of ID NId in the network.

Definition at line 716 of file network.h.

716 { return NodeH.GetDat(NId); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
THash< TInt, TNode > NodeH
Definition: network.h:637
template<class TNodeData, class TEdgeData>
int TNodeEDatNet< TNodeData, TEdgeData >::GetNodes ( ) const
inline

Returns the number of nodes in the network.

Definition at line 680 of file network.h.

Referenced by TNIBs::BSG(), TNIBs::ComputePerformanceNId(), TNodeEDatNet< TStr, TFltFltH >::Empty(), TNIBs::FG(), TNIBs::GenCascade(), TNIBs::GetNodes(), TNIBs::LoadGroundTruthNodesTxt(), TNIBs::LoadGroundTruthTxt(), TNIBs::LoadInferredNodesTxt(), and TNIBs::LoadInferredTxt().

680 { return NodeH.Len(); }
THash< TInt, TNode > NodeH
Definition: network.h:637
int Len() const
Definition: hash.h:228

Here is the caller graph for this function:

template<class TNodeData, class TEdgeData>
TNodeI TNodeEDatNet< TNodeData, TEdgeData >::GetRndNI ( TRnd Rnd = TInt::Rnd)
inline

Returns an interator referring to a random node in the network.

Definition at line 779 of file network.h.

779 { return GetNI(GetRndNId(Rnd)); }
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the network.
Definition: network.h:714
int GetRndNId(TRnd &Rnd=TInt::Rnd)
Returns an ID of a random node in the network.
Definition: network.h:777
template<class TNodeData, class TEdgeData>
int TNodeEDatNet< TNodeData, TEdgeData >::GetRndNId ( TRnd Rnd = TInt::Rnd)
inline

Returns an ID of a random node in the network.

Definition at line 777 of file network.h.

Referenced by TNIBs::GenCascade(), and TNodeEDatNet< TStr, TFltFltH >::GetRndNI().

777 { return NodeH.GetKey(NodeH.GetRndKeyId(Rnd, 0.8)); }
THash< TInt, TNode > NodeH
Definition: network.h:637
int GetRndKeyId(TRnd &Rnd) const
Get an index of a random element. If the hash table has many deleted keys, this may take a long time...
Definition: hash.h:444
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:252

Here is the caller graph for this function:

template<class TNodeData , class TEdgeData >
bool TNodeEDatNet< 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 818 of file network.h.

References HasGraphFlag.

818  {
819  return HasGraphFlag(typename TNet, Flag);
820 }
#define HasGraphFlag(TGraph, Flag)
For quick testing of the properties of the graph/network object (see TGraphFlag). ...
Definition: gbase.h:41
TNodeEDatNet< TNodeData, TEdgeData > TNet
Definition: network.h:495
template<class TNodeData , class TEdgeData >
bool TNodeEDatNet< TNodeData, TEdgeData >::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.

Definition at line 939 of file network.h.

Referenced by TNIBs::BSG(), TNIBs::ComputePerformanceNId(), TNIBs::FG(), TNIBs::SG(), and TNIBs::UpdateDiff().

939  {
940  if (! IsNode(SrcNId) || ! IsNode(DstNId)) { return false; }
941  if (IsDir) { return GetNode(SrcNId).IsOutNId(DstNId); }
942  else { return GetNode(SrcNId).IsOutNId(DstNId) || GetNode(DstNId).IsOutNId(SrcNId); }
943 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:708
bool IsOutNId(const int &NId) const
Definition: network.h:524
TNode & GetNode(const int &NId)
Definition: network.h:632

Here is the caller graph for this function:

template<class TNodeData, class TEdgeData>
bool TNodeEDatNet< TNodeData, TEdgeData >::IsNode ( const int &  NId) const
inline

Tests whether ID NId is a node.

Definition at line 708 of file network.h.

Referenced by TNIBs::UpdateDiff().

708 { return NodeH.IsKey(NId); }
THash< TInt, TNode > NodeH
Definition: network.h:637
bool IsKey(const TKey &Key) const
Definition: hash.h:258

Here is the caller graph for this function:

template<class TNodeData , class TEdgeData >
bool TNodeEDatNet< 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 1016 of file network.h.

References TStr::CStr(), EAssertR, ErrNotify(), TStr::Fmt(), TNodeEDatNet< TNodeData, TEdgeData >::TNode::GetId(), TNodeEDatNet< TNodeData, TEdgeData >::TNode::GetInDeg(), TNodeEDatNet< TNodeData, TEdgeData >::TNode::GetInNId(), TNodeEDatNet< TNodeData, TEdgeData >::TNode::GetOutDeg(), TNodeEDatNet< TNodeData, TEdgeData >::TNode::GetOutNId(), TNodeEDatNet< TNodeData, TEdgeData >::TNode::InNIdV, TVec< TVal, TSizeTy >::IsSorted(), and TNodeEDatNet< TNodeData, TEdgeData >::TNode::OutNIdV.

1016  {
1017  bool RetVal = true;
1018  for (int N = NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
1019  const TNode& Node = NodeH[N];
1020  if (! Node.OutNIdV.IsSorted()) {
1021  const TStr Msg = TStr::Fmt("Out-neighbor list of node %d is not sorted.", Node.GetId());
1022  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
1023  }
1024  if (! Node.InNIdV.IsSorted()) {
1025  const TStr Msg = TStr::Fmt("In-neighbor list of node %d is not sorted.", Node.GetId());
1026  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
1027  }
1028  // check out-edges
1029  int prevNId = -1;
1030  for (int e = 0; e < Node.GetOutDeg(); e++) {
1031  if (! IsNode(Node.GetOutNId(e))) {
1032  const TStr Msg = TStr::Fmt("Out-edge %d --> %d: node %d does not exist.",
1033  Node.GetId(), Node.GetOutNId(e), Node.GetOutNId(e));
1034  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
1035  }
1036  if (e > 0 && prevNId == Node.GetOutNId(e)) {
1037  const TStr Msg = TStr::Fmt("Node %d has duplidate out-edge %d --> %d.",
1038  Node.GetId(), Node.GetId(), Node.GetOutNId(e));
1039  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
1040  }
1041  prevNId = Node.GetOutNId(e);
1042  }
1043  // check in-edges
1044  prevNId = -1;
1045  for (int e = 0; e < Node.GetInDeg(); e++) {
1046  if (! IsNode(Node.GetInNId(e))) {
1047  const TStr Msg = TStr::Fmt("In-edge %d <-- %d: node %d does not exist.",
1048  Node.GetId(), Node.GetInNId(e), Node.GetInNId(e));
1049  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
1050  }
1051  if (e > 0 && prevNId == Node.GetInNId(e)) {
1052  const TStr Msg = TStr::Fmt("Node %d has duplidate in-edge %d <-- %d.",
1053  Node.GetId(), Node.GetId(), Node.GetInNId(e));
1054  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
1055  }
1056  prevNId = Node.GetInNId(e);
1057  }
1058  }
1059  return RetVal;
1060 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:708
void ErrNotify(const char *NotifyCStr)
Definition: bd.h:74
THash< TInt, TNode > NodeH
Definition: network.h:637
bool FNextKeyId(int &KeyId) const
Definition: hash.h:478
int FFirstKeyId() const
Definition: hash.h:278
Definition: dt.h:412
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
#define EAssertR(Cond, MsgStr)
Definition: bd.h:283
char * CStr()
Definition: dt.h:479

Here is the call graph for this function:

template<class TNodeData, class TEdgeData>
static PNet TNodeEDatNet< TNodeData, TEdgeData >::Load ( TSIn SIn)
inlinestatic

Static constructor that loads the network from a stream SIn and returns a pointer to it.

Definition at line 663 of file network.h.

663 { return PNet(new TNet(SIn)); }
TPt< TNet > PNet
Definition: network.h:496
TNodeEDatNet< TNodeData, TEdgeData > TNet
Definition: network.h:495
template<class TNodeData, class TEdgeData>
void TNodeEDatNet< TNodeData, TEdgeData >::LoadNetworkShM ( TShMIn ShMIn)
inlineprivate

Definition at line 645 of file network.h.

Referenced by TNodeEDatNet< TStr, TFltFltH >::LoadShM().

645  {
646  MxNId = TInt(ShMIn);
647  TNodeFunctor f;
648  NodeH.LoadShM(ShMIn, f);
649  }
void LoadShM(TShMIn &ShMIn)
Load THash from shared memory file. Copying/Deleting Keys is illegal.
Definition: hash.h:157
THash< TInt, TNode > NodeH
Definition: network.h:637
TInt MxNId
Definition: network.h:636
Definition: dt.h:1137

Here is the caller graph for this function:

template<class TNodeData, class TEdgeData>
static PNet TNodeEDatNet< TNodeData, TEdgeData >::LoadShM ( TShMIn ShMIn)
inlinestatic

Static constructor that loads the network from shared memory.

The object is read-only. It does not support operations that edit the edge vectors of nodes or perform illegal operations on the NodeH, EdgeH (deletion or swapping keys).

Definition at line 669 of file network.h.

669  {
670  TNet* Network = new TNet();
671  Network->LoadNetworkShM(ShMIn);
672  return PNet(Network);
673  }
TPt< TNet > PNet
Definition: network.h:496
TNodeEDatNet< TNodeData, TEdgeData > TNet
Definition: network.h:495
template<class TNodeData, class TEdgeData>
static PNet TNodeEDatNet< TNodeData, TEdgeData >::New ( )
inlinestatic

Static constructor that returns a pointer to the network. Call: TPt <TNodeEDatNet<TNodeData, TEdgeData> > Net = TNodeEDatNet<TNodeData, TEdgeData>::New().

Definition at line 661 of file network.h.

Referenced by TNIBs::GetGroundTruthNetworkAtT(), TNIBs::GetInferredNetworkAtT(), and main().

661 { return PNet(new TNet()); }
TPt< TNet > PNet
Definition: network.h:496
TNodeEDatNet< TNodeData, TEdgeData > TNet
Definition: network.h:495

Here is the caller graph for this function:

template<class TNodeData, class TEdgeData>
TNodeEDatNet& TNodeEDatNet< TNodeData, TEdgeData >::operator= ( const TNodeEDatNet< TNodeData, TEdgeData > &  NodeNet)
inline

Definition at line 676 of file network.h.

676  { if (this!=&NodeNet) {
677  NodeH=NodeNet.NodeH; MxNId=NodeNet.MxNId; } return *this; }
THash< TInt, TNode > NodeH
Definition: network.h:637
TInt MxNId
Definition: network.h:636
template<class TNodeData, class TEdgeData>
void TNodeEDatNet< TNodeData, TEdgeData >::Reserve ( const int &  Nodes,
const int &  Edges 
)
inline

Reserves memory for a network of Nodes nodes and Edges edges.

Definition at line 789 of file network.h.

Referenced by TNodeEDatNet< TStr, TFltFltH >::TNodeEDatNet().

789 { if (Nodes>0) { NodeH.Gen(Nodes/2); } }
THash< TInt, TNode > NodeH
Definition: network.h:637
void Gen(const int &ExpectVals)
Definition: hash.h:222

Here is the caller graph for this function:

template<class TNodeData, class TEdgeData>
virtual void TNodeEDatNet< TNodeData, TEdgeData >::Save ( TSOut SOut) const
inlinevirtual

Saves the network to a (binary) stream SOut.

Definition at line 659 of file network.h.

Referenced by TNIBs::Save().

659 { MxNId.Save(SOut); NodeH.Save(SOut); }
void Save(TSOut &SOut) const
Definition: dt.h:1153
void Save(TSOut &SOut) const
Definition: hash.h:183
THash< TInt, TNode > NodeH
Definition: network.h:637
TInt MxNId
Definition: network.h:636

Here is the caller graph for this function:

template<class TNodeData , class TEdgeData>
void TNodeEDatNet< TNodeData, TEdgeData >::SetAllEDat ( const TEdgeData &  EdgeDat)

Sets edge data for all the edges in the network to EDat.

Definition at line 975 of file network.h.

975  {
976  for (TEdgeI EI = BegEI(); EI < EndEI(); EI++) {
977  EI() = EdgeDat;
978  }
979 }
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the network.
Definition: network.h:758
TEdgeI BegEI() const
Returns an iterator referring to the first edge in the network.
Definition: network.h:756
template<class TNodeData , class TEdgeData>
void TNodeEDatNet< TNodeData, TEdgeData >::SetEDat ( const int &  SrcNId,
const int &  DstNId,
const TEdgeData &  EdgeDat 
)

Sets edge data for the edge between nodes SrcNId and DstNId in the network.

Definition at line 946 of file network.h.

References TStr::Fmt(), and IAssertR.

946  {
947  IAssertR(IsNode(SrcNId) && IsNode(DstNId), TStr::Fmt("%d or %d not a node.", SrcNId, DstNId).CStr());
948  IAssertR(IsEdge(SrcNId, DstNId), TStr::Fmt("Edge between %d and %d does not exist.", SrcNId, DstNId).CStr());
949  GetEDat(SrcNId, DstNId) = EdgeDat;
950 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:708
#define IAssertR(Cond, Reason)
Definition: bd.h:265
bool GetEDat(const int &SrcNId, const int &DstNId, TEdgeData &EdgeDat) const
Returns edge data in Data for the edge from node IDs SrcNId to DstNId.
Definition: network.h:953
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.
Definition: network.h:939
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599

Here is the call graph for this function:

template<class TNodeData, class TEdgeData >
void TNodeEDatNet< TNodeData, TEdgeData >::SetNDat ( const int &  NId,
const TNodeData &  NodeDat 
)

Sets node data for the node of ID NId in the network.

Definition at line 872 of file network.h.

References TStr::Fmt(), and IAssertR.

872  {
873  IAssertR(IsNode(NId), TStr::Fmt("NodeId %d does not exist.", NId).CStr());
874  NodeH.GetDat(NId).NodeDat = NodeDat;
875 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:708
#define IAssertR(Cond, Reason)
Definition: bd.h:265
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
THash< TInt, TNode > NodeH
Definition: network.h:637
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TNodeData NodeDat
Definition: network.h:502

Here is the call graph for this function:

template<class TNodeData, class TEdgeData>
void TNodeEDatNet< TNodeData, TEdgeData >::SortNIdByDat ( const bool &  Asc = true)
inline

Sorts nodes by node data.

Definition at line 793 of file network.h.

793 { NodeH.SortByDat(Asc); }
THash< TInt, TNode > NodeH
Definition: network.h:637
void SortByDat(const bool &Asc=true)
Definition: hash.h:292
template<class TNodeData, class TEdgeData>
void TNodeEDatNet< TNodeData, TEdgeData >::SortNIdById ( const bool &  Asc = true)
inline

Sorts nodes by node IDs.

Definition at line 791 of file network.h.

791 { NodeH.SortByKey(Asc); }
THash< TInt, TNode > NodeH
Definition: network.h:637
void SortByKey(const bool &Asc=true)
Definition: hash.h:291

Friends And Related Function Documentation

template<class TNodeData, class TEdgeData>
friend class TPt< TNodeEDatNet< TNodeData, TEdgeData > >
friend

Definition at line 807 of file network.h.

Member Data Documentation

template<class TNodeData, class TEdgeData>
TCRef TNodeEDatNet< TNodeData, TEdgeData >::CRef
protected

Definition at line 635 of file network.h.

template<class TNodeData, class TEdgeData>
TInt TNodeEDatNet< TNodeData, TEdgeData >::MxNId
protected
template<class TNodeData, class TEdgeData>
THash<TInt, TNode> TNodeEDatNet< TNodeData, TEdgeData >::NodeH
protected

The documentation for this class was generated from the following file: