SNAP Library 2.4, User Reference  2015-05-11 19:40:56
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TNEANet Class Reference

Directed multigraph with node edge attributes. More...

#include <network.h>

Classes

class  TAFltI
 Node/edge float attribute iterator. Iterates through all nodes/edges for one float attribute. More...
 
class  TAIntI
 Node/edge integer attribute iterator. Iterates through all nodes/edges for one integer attribute. More...
 
class  TAStrI
 Node/edge string attribute iterator. Iterates through all nodes/edges for one string attribute. More...
 
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 TNEANet TNet
 
typedef TPt< TNEANetPNet
 

Public Member Functions

 TNEANet ()
 
 TNEANet (const int &Nodes, const int &Edges)
 Constructor that reserves enough memory for a graph of nodes and edges. More...
 
 TNEANet (const TNEANet &Graph)
 
 TNEANet (TSIn &SIn)
 Constructor for loading the graph from a (binary) stream SIn. More...
 
void Save (TSOut &SOut) const
 Saves the graph to a (binary) stream SOut. More...
 
bool HasFlag (const TGraphFlag &Flag) const
 Allows for run-time checking the type of the graph (see the TGraphFlag for flags). More...
 
TNEANetoperator= (const TNEANet &Graph)
 
int GetNodes () const
 Returns the number of nodes in the graph. More...
 
int AddNode (int NId=-1)
 Adds a node of ID NId to the graph. More...
 
int AddNode (const TNodeI &NodeI)
 Adds a node of ID NodeI.GetId() to the graph. More...
 
void DelNode (const int &NId)
 Deletes node of ID NId from the graph. More...
 
void DelNode (const TNode &NodeI)
 Deletes node of ID NodeI.GetId() from the graph. 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 graph. More...
 
TNodeI EndNI () const
 Returns an iterator referring to the past-the-end node in the graph. More...
 
TNodeI GetNI (const int &NId) const
 Returns an iterator referring to the node of ID NId in the graph. More...
 
TAIntI BegNAIntI (const TStr &attr) const
 Returns an iterator referring to the first node's int attribute. More...
 
TAIntI EndNAIntI (const TStr &attr) const
 Returns an iterator referring to the past-the-end node's attribute. More...
 
TAIntI GetNAIntI (const TStr &attr, const int &NId) const
 Returns an iterator referring to the node of ID NId in the graph. More...
 
TAStrI BegNAStrI (const TStr &attr) const
 Returns an iterator referring to the first node's str attribute. More...
 
TAStrI EndNAStrI (const TStr &attr) const
 Returns an iterator referring to the past-the-end node's attribute. More...
 
TAStrI GetNAStrI (const TStr &attr, const int &NId) const
 Returns an iterator referring to the node of ID NId in the graph. More...
 
TAFltI BegNAFltI (const TStr &attr) const
 Returns an iterator referring to the first node's flt attribute. More...
 
TAFltI EndNAFltI (const TStr &attr) const
 Returns an iterator referring to the past-the-end node's attribute. More...
 
TAFltI GetNAFltI (const TStr &attr, const int &NId) const
 Returns an iterator referring to the node of ID NId in the graph. More...
 
void AttrNameNI (const TInt &NId, TStrV &Names) const
 Returns a vector of attr names for node NId. More...
 
void AttrNameNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TStrV &Names) const
 
void AttrValueNI (const TInt &NId, TStrV &Values) const
 Returns a vector of attr values for node NId. More...
 
void AttrValueNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TStrV &Values) const
 
void IntAttrNameNI (const TInt &NId, TStrV &Names) const
 Returns a vector of int attr names for node NId. More...
 
void IntAttrNameNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TStrV &Names) const
 
void IntAttrValueNI (const TInt &NId, TIntV &Values) const
 Returns a vector of attr values for node NId. More...
 
void IntAttrValueNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TIntV &Values) const
 
void StrAttrNameNI (const TInt &NId, TStrV &Names) const
 Returns a vector of str attr names for node NId. More...
 
void StrAttrNameNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TStrV &Names) const
 
void StrAttrValueNI (const TInt &NId, TStrV &Values) const
 Returns a vector of attr values for node NId. More...
 
void StrAttrValueNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TStrV &Values) const
 
void FltAttrNameNI (const TInt &NId, TStrV &Names) const
 Returns a vector of int attr names for node NId. More...
 
void FltAttrNameNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TStrV &Names) const
 
void FltAttrValueNI (const TInt &NId, TFltV &Values) const
 Returns a vector of attr values for node NId. More...
 
void FltAttrValueNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TFltV &Values) const
 
void AttrNameEI (const TInt &EId, TStrV &Names) const
 Returns a vector of attr names for edge EId. More...
 
void AttrNameEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TStrV &Names) const
 
void AttrValueEI (const TInt &EId, TStrV &Values) const
 Returns a vector of attr values for edge EId. More...
 
void AttrValueEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TStrV &Values) const
 
void IntAttrNameEI (const TInt &EId, TStrV &Names) const
 Returns a vector of int attr names for edge EId. More...
 
void IntAttrNameEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TStrV &Names) const
 
void IntAttrValueEI (const TInt &EId, TIntV &Values) const
 Returns a vector of attr values for edge EId. More...
 
void IntAttrValueEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TIntV &Values) const
 
void StrAttrNameEI (const TInt &EId, TStrV &Names) const
 Returns a vector of str attr names for node NId. More...
 
void StrAttrNameEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TStrV &Names) const
 
void StrAttrValueEI (const TInt &EId, TStrV &Values) const
 Returns a vector of attr values for node NId. More...
 
void StrAttrValueEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TStrV &Values) const
 
void FltAttrNameEI (const TInt &EId, TStrV &Names) const
 Returns a vector of int attr names for node NId. More...
 
void FltAttrNameEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TStrV &Names) const
 
void FltAttrValueEI (const TInt &EId, TFltV &Values) const
 Returns a vector of attr values for node NId. More...
 
void FltAttrValueEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TFltV &Values) const
 
TAIntI BegEAIntI (const TStr &attr) const
 Returns an iterator referring to the first edge's int attribute. More...
 
TAIntI EndEAIntI (const TStr &attr) const
 Returns an iterator referring to the past-the-end edge's attribute. More...
 
TAIntI GetEAIntI (const TStr &attr, const int &EId) const
 Returns an iterator referring to the edge of ID EId in the graph. More...
 
TAStrI BegEAStrI (const TStr &attr) const
 Returns an iterator referring to the first edge's str attribute. More...
 
TAStrI EndEAStrI (const TStr &attr) const
 Returns an iterator referring to the past-the-end edge's attribute. More...
 
TAStrI GetEAStrI (const TStr &attr, const int &EId) const
 Returns an iterator referring to the edge of ID EId in the graph. More...
 
TAFltI BegEAFltI (const TStr &attr) const
 Returns an iterator referring to the first edge's flt attribute. More...
 
TAFltI EndEAFltI (const TStr &attr) const
 Returns an iterator referring to the past-the-end edge's attribute. More...
 
TAFltI GetEAFltI (const TStr &attr, const int &EId) const
 Returns an iterator referring to the edge of ID EId in the graph. More...
 
int GetMxNId () const
 Returns an ID that is larger than any node ID in the network. More...
 
int GetMxEId () const
 Returns an ID that is larger than any edge ID in the network. More...
 
int GetEdges () const
 Returns the number of edges in the graph. More...
 
int AddEdge (const int &SrcNId, const int &DstNId, int EId=-1)
 Adds an edge with ID EId between node IDs SrcNId and DstNId to the graph. More...
 
int AddEdge (const TEdgeI &EdgeI)
 Adds an edge between EdgeI.GetSrcNId() and EdgeI.GetDstNId() to the graph. More...
 
void DelEdge (const int &EId)
 Deletes an edge with edge ID EId from the graph. More...
 
void DelEdge (const int &SrcNId, const int &DstNId, const bool &IsDir=true)
 Deletes all edges between node IDs SrcNId and DstNId from the graph. More...
 
bool IsEdge (const int &EId) const
 Tests whether an edge with edge ID EId exists in the graph. More...
 
bool IsEdge (const int &SrcNId, const int &DstNId, const bool &IsDir=true) const
 Tests whether an edge between node IDs SrcNId and DstNId exists in the graph. More...
 
bool IsEdge (const int &SrcNId, const int &DstNId, int &EId, const bool &IsDir=true) const
 Tests whether an edge between node IDs SrcNId and DstNId exists in the graph. if an edge exists, return its edge ID in EId. More...
 
int GetEId (const int &SrcNId, const int &DstNId) const
 Returns an edge ID between node IDs SrcNId and DstNId, if such an edge exists. Otherwise, return -1. More...
 
TEdgeI BegEI () const
 Returns an iterator referring to the first edge in the graph. More...
 
TEdgeI EndEI () const
 Returns an iterator referring to the past-the-end edge in the graph. More...
 
TEdgeI GetEI (const int &EId) const
 Returns an iterator referring to edge with edge ID EId. More...
 
TEdgeI GetEI (const int &SrcNId, const int &DstNId) const
 Returns an iterator referring to edge (SrcNId, DstNId) in the graph. More...
 
int GetRndNId (TRnd &Rnd=TInt::Rnd)
 Returns an ID of a random node in the graph. More...
 
TNodeI GetRndNI (TRnd &Rnd=TInt::Rnd)
 Returns an interator referring to a random node in the graph. More...
 
int GetRndEId (TRnd &Rnd=TInt::Rnd)
 Returns an ID of a random edge in the graph. More...
 
TEdgeI GetRndEI (TRnd &Rnd=TInt::Rnd)
 Returns an interator referring to a random edge in the graph. More...
 
void GetNIdV (TIntV &NIdV) const
 Gets a vector IDs of all nodes in the graph. More...
 
void GetEIdV (TIntV &EIdV) const
 Gets a vector IDs of all edges in the graph. More...
 
bool Empty () const
 Tests whether the graph is empty (has zero nodes). More...
 
void Clr ()
 Deletes all nodes and edges from the graph. More...
 
void Reserve (const int &Nodes, const int &Edges)
 Reserves memory for a graph of Nodes nodes and Edges edges. More...
 
void Defrag (const bool &OnlyNodeLinks=false)
 Defragments the graph. More...
 
bool IsOk (const bool &ThrowExcept=true) const
 Checks the graph data structure for internal consistency. More...
 
void Dump (FILE *OutF=stdout) const
 Print the graph in a human readable form to an output stream OutF. More...
 
int AddIntAttrDatN (const TNodeI &NodeI, const TInt &value, const TStr &attr)
 Attribute based add function for attr to Int value. More...
 
int AddIntAttrDatN (const int &NId, const TInt &value, const TStr &attr)
 
int AddStrAttrDatN (const TNodeI &NodeI, const TStr &value, const TStr &attr)
 Attribute based add function for attr to Str value. More...
 
int AddStrAttrDatN (const int &NId, const TStr &value, const TStr &attr)
 
int AddFltAttrDatN (const TNodeI &NodeI, const TFlt &value, const TStr &attr)
 Attribute based add function for attr to Flt value. More...
 
int AddFltAttrDatN (const int &NId, const TFlt &value, const TStr &attr)
 
int AddIntAttrDatE (const TEdgeI &EdgeI, const TInt &value, const TStr &attr)
 Attribute based add function for attr to Int value. More...
 
int AddIntAttrDatE (const int &EId, const TInt &value, const TStr &attr)
 
int AddStrAttrDatE (const TEdgeI &EdgeI, const TStr &value, const TStr &attr)
 Attribute based add function for attr to Str value. More...
 
int AddStrAttrDatE (const int &EId, const TStr &value, const TStr &attr)
 
int AddFltAttrDatE (const TEdgeI &EdgeI, const TFlt &value, const TStr &attr)
 Attribute based add function for attr to Flt value. More...
 
int AddFltAttrDatE (const int &EId, const TFlt &value, const TStr &attr)
 
TInt GetIntAttrDatN (const TNodeI &NodeI, const TStr &attr)
 Gets the value of int attr from the node attr value vector. More...
 
TInt GetIntAttrDatN (const int &NId, const TStr &attr)
 
TStr GetStrAttrDatN (const TNodeI &NodeI, const TStr &attr)
 Gets the value of str attr from the node attr value vector. More...
 
TStr GetStrAttrDatN (const int &NId, const TStr &attr)
 
TFlt GetFltAttrDatN (const TNodeI &NodeI, const TStr &attr)
 Gets the value of flt attr from the node attr value vector. More...
 
TFlt GetFltAttrDatN (const int &NId, const TStr &attr)
 
int GetIntAttrIndN (const TStr &attr)
 Gets the index of the node attr value vector specified by attr (same as GetAttrIndN for compatibility reasons). More...
 
int GetAttrIndN (const TStr &attr)
 Gets the index of the node attr value vector specified by attr. More...
 
TInt GetIntAttrIndDatN (const TNodeI &NodeI, const int &index)
 Gets the value of an int node attr specified by node iterator NodeI and the attr index. More...
 
TInt GetIntAttrIndDatN (const int &NId, const int &index)
 Gets the value of an int node attr specified by node ID NId and the attr index. More...
 
TStr GetStrAttrIndDatN (const TNodeI &NodeI, const int &index)
 Gets the value of a string node attr specified by node iterator NodeI and the attr index. More...
 
TStr GetStrAttrIndDatN (const int &NId, const int &index)
 Gets the value of a string node attr specified by node ID NId and the attr index. More...
 
TFlt GetFltAttrIndDatN (const TNodeI &NodeI, const int &index)
 Gets the value of a float node attr specified by node iterator NodeI and the attr index. More...
 
TFlt GetFltAttrIndDatN (const int &NId, const int &index)
 Gets the value of a float node attr specified by node ID NId and the attr index. More...
 
TInt GetIntAttrDatE (const TEdgeI &EdgeI, const TStr &attr)
 Gets the value of int attr from the edge attr value vector. More...
 
TInt GetIntAttrDatE (const int &EId, const TStr &attr)
 
TStr GetStrAttrDatE (const TEdgeI &EdgeI, const TStr &attr)
 Gets the value of str attr from the edge attr value vector. More...
 
TStr GetStrAttrDatE (const int &EId, const TStr &attr)
 
TFlt GetFltAttrDatE (const TEdgeI &EdgeI, const TStr &attr)
 Gets the value of flt attr from the edge attr value vector. More...
 
TFlt GetFltAttrDatE (const int &EId, const TStr &attr)
 
int GetIntAttrIndE (const TStr &attr)
 Gets the index of the edge attr value vector specified by attr (same as GetAttrIndE for compatibility reasons). More...
 
int GetAttrIndE (const TStr &attr)
 Gets the index of the edge attr value vector specified by attr. More...
 
TInt GetIntAttrIndDatE (const TEdgeI &EdgeI, const int &index)
 Gets the value of an int edge attr specified by edge iterator EdgeI and the attr index. More...
 
TInt GetIntAttrIndDatE (const int &EId, const int &index)
 Gets the value of an int edge attr specified by edge ID EId and the attr index. More...
 
TFlt GetFltAttrIndDatE (const TEdgeI &EdgeI, const int &index)
 Gets the value of a float edge attr specified by edge iterator EdgeI and the attr index. More...
 
TFlt GetFltAttrIndDatE (const int &EId, const int &index)
 Gets the value of an int edge attr specified by edge ID EId and the attr index. More...
 
TStr GetStrAttrIndDatE (const TEdgeI &EdgeI, const int &index)
 Gets the value of a string edge attr specified by edge iterator EdgeI and the attr index. More...
 
TStr GetStrAttrIndDatE (const int &EId, const int &index)
 Gets the value of an int edge attr specified by edge ID EId and the attr index. More...
 
int DelAttrDatN (const TNodeI &NodeI, const TStr &attr)
 Deletes the node attribute for NodeI. More...
 
int DelAttrDatN (const int &NId, const TStr &attr)
 
int DelAttrDatE (const TEdgeI &EdgeI, const TStr &attr)
 Deletes the edge attribute for NodeI. More...
 
int DelAttrDatE (const int &EId, const TStr &attr)
 
int AddIntAttrN (const TStr &attr, TInt defaultValue=TInt::Mn)
 Adds a new Int node attribute to the hashmap. More...
 
int AddStrAttrN (const TStr &attr, TStr defaultValue=TStr::GetNullStr())
 Adds a new Str node attribute to the hashmap. More...
 
int AddFltAttrN (const TStr &attr, TFlt defaultValue=TFlt::Mn)
 Adds a new Flt node attribute to the hashmap. More...
 
int AddIntAttrE (const TStr &attr, TInt defaultValue=TInt::Mn)
 Adds a new Int edge attribute to the hashmap. More...
 
int AddStrAttrE (const TStr &attr, TStr defaultValue=TStr::GetNullStr())
 Adds a new Str edge attribute to the hashmap. More...
 
int AddFltAttrE (const TStr &attr, TFlt defaultValue=TFlt::Mn)
 Adds a new Flt edge attribute to the hashmap. More...
 
int DelAttrN (const TStr &attr)
 Removes all the values for node attr. More...
 
int DelAttrE (const TStr &attr)
 Removes all the values for edge attr. More...
 
bool IsAttrDeletedN (const int &NId, const TStr &attr) const
 
bool IsIntAttrDeletedN (const int &NId, const TStr &attr) const
 
bool IsStrAttrDeletedN (const int &NId, const TStr &attr) const
 
bool IsFltAttrDeletedN (const int &NId, const TStr &attr) const
 
bool NodeAttrIsDeleted (const int &NId, const TStrIntPrH::TIter &NodeHI) const
 
bool NodeAttrIsIntDeleted (const int &NId, const TStrIntPrH::TIter &NodeHI) const
 
bool NodeAttrIsStrDeleted (const int &NId, const TStrIntPrH::TIter &NodeHI) const
 
bool NodeAttrIsFltDeleted (const int &NId, const TStrIntPrH::TIter &NodeHI) const
 
bool IsAttrDeletedE (const int &EId, const TStr &attr) const
 
bool IsIntAttrDeletedE (const int &EId, const TStr &attr) const
 
bool IsStrAttrDeletedE (const int &EId, const TStr &attr) const
 
bool IsFltAttrDeletedE (const int &EId, const TStr &attr) const
 
bool EdgeAttrIsDeleted (const int &EId, const TStrIntPrH::TIter &EdgeHI) const
 
bool EdgeAttrIsIntDeleted (const int &EId, const TStrIntPrH::TIter &EdgeHI) const
 
bool EdgeAttrIsStrDeleted (const int &EId, const TStrIntPrH::TIter &EdgeHI) const
 
bool EdgeAttrIsFltDeleted (const int &EId, const TStrIntPrH::TIter &EdgeHI) const
 
TStr GetNodeAttrValue (const int &NId, const TStrIntPrH::TIter &NodeHI) const
 
TStr GetEdgeAttrValue (const int &EId, const TStrIntPrH::TIter &EdgeHI) const
 
void GetAttrNNames (TStrV &IntAttrNames, TStrV &FltAttrNames, TStrV &StrAttrNames) const
 Fills each of the vectors with the names of node attributes of the given type. More...
 
void GetAttrENames (TStrV &IntAttrNames, TStrV &FltAttrNames, TStrV &StrAttrNames) const
 Fills each of the vectors with the names of edge attributes of the given type. More...
 

Static Public Member Functions

static PNEANet New ()
 Static cons returns pointer to graph. Ex: PNEANet Graph=TNEANet::New(). More...
 
static PNEANet New (const int &Nodes, const int &Edges)
 Static constructor that returns a pointer to the graph and reserves enough memory for Nodes nodes and Edges edges. More...
 
static PNEANet Load (TSIn &SIn)
 Static constructor that loads the graph from a stream SIn and returns a pointer to it. More...
 
static PNEANet GetSmallGraph ()
 Returns a small multigraph on 5 nodes and 6 edges. More...
 

Private Types

enum  { IntType, StrType, FltType }
 

Private Member Functions

TNodeGetNode (const int &NId)
 
const TNodeGetNode (const int &NId) const
 
TEdgeGetEdge (const int &EId)
 
const TEdgeGetEdge (const int &EId) const
 
TInt GetIntAttrDefaultN (const TStr &attribute) const
 Get Int node attribute val. If not a proper attr, return default. More...
 
TStr GetStrAttrDefaultN (const TStr &attribute) const
 Get Str node attribute val. If not a proper attr, return default. More...
 
TFlt GetFltAttrDefaultN (const TStr &attribute) const
 Get Flt node attribute val. If not a proper attr, return default. More...
 
TInt GetIntAttrDefaultE (const TStr &attribute) const
 Get Int edge attribute val. If not a proper attr, return default. More...
 
TStr GetStrAttrDefaultE (const TStr &attribute) const
 Get Str edge attribute val. If not a proper attr, return default. More...
 
TFlt GetFltAttrDefaultE (const TStr &attribute) const
 Get Flt edge attribute val. If not a proper attr, return default. More...
 

Private Attributes

TCRef CRef
 
TInt MxNId
 
TInt MxEId
 
THash< TInt, TNodeNodeH
 
THash< TInt, TEdgeEdgeH
 
TStrIntPrH KeyToIndexTypeN
 KeyToIndexType[N|E]: Key->(Type,Index). More...
 
TStrIntPrH KeyToIndexTypeE
 
THash< TStr, TIntIntDefaultsN
 
THash< TStr, TIntIntDefaultsE
 
THash< TStr, TStrStrDefaultsN
 
THash< TStr, TStrStrDefaultsE
 
THash< TStr, TFltFltDefaultsN
 
THash< TStr, TFltFltDefaultsE
 
TVec< TIntVVecOfIntVecsN
 
TVec< TIntVVecOfIntVecsE
 
TVec< TStrVVecOfStrVecsN
 
TVec< TStrVVecOfStrVecsE
 
TVec< TFltVVecOfFltVecsN
 
TVec< TFltVVecOfFltVecsE
 

Friends

class TPt< TNEANet >
 

Detailed Description

Directed multigraph with node edge attributes.

Node IDs can be arbitrary non-negative integers. Edges have IDs. There can be more than one directed edge from one source node to a destination node. Self loops (one per node) are allowed as well as multiple (parallel) edges. Nodes and edges can have attributes/data associated with them. The attributes can be added dynamically at runtime. The directed multigraph data structure is implemented using sorted adjacency lists. This means adding a node takes constant time, while adding an edge takes linear time (since adjacency list is kept sorted) in the node degree. Accessing arbitrary node takes constant time and accessing any edge takes logarithmic time in the node degree. The attributes are organized in a columnar store, where each attribute column is defined for all the nodes or edges in the network.

Definition at line 1587 of file network.h.

Member Typedef Documentation

Definition at line 1590 of file network.h.

Definition at line 1589 of file network.h.

Member Enumeration Documentation

anonymous enum
private
Enumerator
IntType 
StrType 
FltType 

Definition at line 1840 of file network.h.

Constructor & Destructor Documentation

TNEANet::TNEANet ( )
inline

Definition at line 1842 of file network.h.

1842  : CRef(), MxNId(0), MxEId(0), NodeH(), EdgeH(),
1846  VecOfFltVecsN(), VecOfFltVecsE() { }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1837
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:1836
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
THash< TStr, TInt > IntDefaultsE
Definition: network.h:1834
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:1836
TInt MxNId
Definition: network.h:1828
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
TCRef CRef
Definition: network.h:1827
THash< TStr, TStr > StrDefaultsN
Definition: network.h:1835
TInt MxEId
Definition: network.h:1828
THash< TStr, TStr > StrDefaultsE
Definition: network.h:1835
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1839
THash< TStr, TInt > IntDefaultsN
Definition: network.h:1834
THash< TInt, TNode > NodeH
Definition: network.h:1829
TNEANet::TNEANet ( const int &  Nodes,
const int &  Edges 
)
inlineexplicit

Constructor that reserves enough memory for a graph of nodes and edges.

Definition at line 1848 of file network.h.

1848  : CRef(),
1853  { Reserve(Nodes, Edges); }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1837
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:1836
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
THash< TStr, TInt > IntDefaultsE
Definition: network.h:1834
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:1836
TInt MxNId
Definition: network.h:1828
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
void Reserve(const int &Nodes, const int &Edges)
Reserves memory for a graph of Nodes nodes and Edges edges.
Definition: network.h:2106
TCRef CRef
Definition: network.h:1827
THash< TStr, TStr > StrDefaultsN
Definition: network.h:1835
TInt MxEId
Definition: network.h:1828
THash< TStr, TStr > StrDefaultsE
Definition: network.h:1835
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1839
THash< TStr, TInt > IntDefaultsN
Definition: network.h:1834
THash< TInt, TNode > NodeH
Definition: network.h:1829
TNEANet::TNEANet ( const TNEANet Graph)
inline

Definition at line 1854 of file network.h.

1854  : MxNId(Graph.MxNId), MxEId(Graph.MxEId),
1855  NodeH(Graph.NodeH), EdgeH(Graph.EdgeH), KeyToIndexTypeN(), KeyToIndexTypeE(),
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1837
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:1836
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
THash< TStr, TInt > IntDefaultsE
Definition: network.h:1834
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:1836
TInt MxNId
Definition: network.h:1828
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
THash< TStr, TStr > StrDefaultsN
Definition: network.h:1835
TInt MxEId
Definition: network.h:1828
THash< TStr, TStr > StrDefaultsE
Definition: network.h:1835
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1839
THash< TStr, TInt > IntDefaultsN
Definition: network.h:1834
THash< TInt, TNode > NodeH
Definition: network.h:1829
TNEANet::TNEANet ( TSIn SIn)
inline

Constructor for loading the graph from a (binary) stream SIn.

Definition at line 1860 of file network.h.

1860  : MxNId(SIn), MxEId(SIn), NodeH(SIn), EdgeH(SIn),
1862  StrDefaultsN(SIn), StrDefaultsE(SIn), FltDefaultsN(SIn), FltDefaultsE(SIn),
1864  VecOfFltVecsN(SIn), VecOfFltVecsE(SIn) { }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1837
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:1836
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
THash< TStr, TInt > IntDefaultsE
Definition: network.h:1834
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:1836
TInt MxNId
Definition: network.h:1828
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
THash< TStr, TStr > StrDefaultsN
Definition: network.h:1835
TInt MxEId
Definition: network.h:1828
THash< TStr, TStr > StrDefaultsE
Definition: network.h:1835
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1839
THash< TStr, TInt > IntDefaultsN
Definition: network.h:1834
THash< TInt, TNode > NodeH
Definition: network.h:1829

Member Function Documentation

int TNEANet::AddEdge ( const int &  SrcNId,
const int &  DstNId,
int  EId = -1 
)

Adds an edge with ID EId 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 419 of file network.cpp.

419  {
420  int i;
421 
422  if (EId == -1) { EId = MxEId; MxEId++; }
423  else { MxEId = TMath::Mx(EId+1, MxEId()); }
424  IAssertR(!IsEdge(EId), TStr::Fmt("EdgeId %d already exists", EId));
425  IAssertR(IsNode(SrcNId) && IsNode(DstNId), TStr::Fmt("%d or %d not a node.", SrcNId, DstNId).CStr());
426  EdgeH.AddDat(EId, TEdge(EId, SrcNId, DstNId));
427  GetNode(SrcNId).OutEIdV.AddSorted(EId);
428  GetNode(DstNId).InEIdV.AddSorted(EId);
429 
430  // update attribute columns
431  for (i = 0; i < VecOfIntVecsE.Len(); i++) {
432  TVec<TInt>& IntVec = VecOfIntVecsE[i];
433  IntVec.Ins(EdgeH.GetKeyId(EId), TInt::Mn);
434  }
435  TVec<TStr> DefIntVec = TVec<TStr>();
436  IntDefaultsE.GetKeyV(DefIntVec);
437  for (i = 0; i < DefIntVec.Len(); i++) {
438  TStr attr = DefIntVec[i];
439  TVec<TInt>& IntVec = VecOfIntVecsE[KeyToIndexTypeE.GetDat(DefIntVec[i]).Val2];
440  IntVec[EdgeH.GetKeyId(EId)] = GetIntAttrDefaultE(attr);
441  }
442 
443  for (i = 0; i < VecOfStrVecsE.Len(); i++) {
444  TVec<TStr>& StrVec = VecOfStrVecsE[i];
445  StrVec.Ins(EdgeH.GetKeyId(EId), TStr::GetNullStr());
446  }
447  TVec<TStr> DefStrVec = TVec<TStr>();
448  IntDefaultsE.GetKeyV(DefStrVec);
449  for (i = 0; i < DefStrVec.Len(); i++) {
450  TStr attr = DefStrVec[i];
451  TVec<TStr>& StrVec = VecOfStrVecsE[KeyToIndexTypeE.GetDat(DefStrVec[i]).Val2];
452  StrVec[EdgeH.GetKeyId(EId)] = GetStrAttrDefaultE(attr);
453  }
454 
455  for (i = 0; i < VecOfFltVecsE.Len(); i++) {
456  TVec<TFlt>& FltVec = VecOfFltVecsE[i];
457  FltVec.Ins(EdgeH.GetKeyId(EId), TFlt::Mn);
458  }
459  TVec<TStr> DefFltVec = TVec<TStr>();
460  FltDefaultsE.GetKeyV(DefFltVec);
461  for (i = 0; i < DefFltVec.Len(); i++) {
462  TStr attr = DefFltVec[i];
463  TVec<TFlt>& FltVec = VecOfFltVecsE[KeyToIndexTypeE.GetDat(DefFltVec[i]).Val2];
464  FltVec[NodeH.GetKeyId(EId)] = GetFltAttrDefaultE(attr);
465  }
466  return EId;
467 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:1836
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
THash< TStr, TInt > IntDefaultsE
Definition: network.h:1834
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32
TNode & GetNode(const int &NId)
Definition: network.h:1808
TInt GetIntAttrDefaultE(const TStr &attribute) const
Get Int edge attribute val. If not a proper attr, return default.
Definition: network.h:1820
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2068
TIntV OutEIdV
Definition: network.h:1595
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
TSizeTy AddSorted(const TVal &Val, const bool &Asc=true, const TSizeTy &_MxVals=-1)
Adds element Val to a sorted vector.
Definition: ds.h:1027
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
static const int Mn
Definition: dt.h:1046
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
TStr GetStrAttrDefaultE(const TStr &attribute) const
Get Str edge attribute val. If not a proper attr, return default.
Definition: network.h:1822
static TStr GetNullStr()
Definition: dt.cpp:1626
TInt MxEId
Definition: network.h:1828
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1086
TFlt GetFltAttrDefaultE(const TStr &attribute) const
Get Flt edge attribute val. If not a proper attr, return default.
Definition: network.h:1824
void GetKeyV(TVec< TKey > &KeyV) const
Definition: hash.h:438
Definition: dt.h:412
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TVal2 Val2
Definition: ds.h:35
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:1906
THash< TInt, TNode > NodeH
Definition: network.h:1829
TIntV InEIdV
Definition: network.h:1595
TDat & AddDat(const TKey &Key)
Definition: hash.h:196
static const double Mn
Definition: dt.h:1295
int TNEANet::AddEdge ( const TEdgeI EdgeI)
inline

Adds an edge between EdgeI.GetSrcNId() and EdgeI.GetDstNId() to the graph.

Definition at line 2058 of file network.h.

2058 { return AddEdge(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), EdgeI.GetId()); }
int AddEdge(const int &SrcNId, const int &DstNId, int EId=-1)
Adds an edge with ID EId between node IDs SrcNId and DstNId to the graph.
Definition: network.cpp:419
int TNEANet::AddFltAttrDatE ( const TEdgeI EdgeI,
const TFlt value,
const TStr attr 
)
inline

Attribute based add function for attr to Flt value.

Adds the key flt value pair to the corresponding edge attribute value vector.

Definition at line 2152 of file network.h.

2152 { return AddFltAttrDatE(EdgeI.GetId(), value, attr); }
int AddFltAttrDatE(const TEdgeI &EdgeI, const TFlt &value, const TStr &attr)
Attribute based add function for attr to Flt value.
Definition: network.h:2152
int TNEANet::AddFltAttrDatE ( const int &  EId,
const TFlt value,
const TStr attr 
)

Definition at line 774 of file network.cpp.

774  {
775  int i;
776  TInt CurrLen;
777 
778  if (!IsEdge(EId)) {
779  //AddEdge(EId);
780  return -1;
781  }
782  if (KeyToIndexTypeE.IsKey(attr)) {
784  NewVec[EdgeH.GetKeyId(EId)] = value;
785  } else {
786  CurrLen = VecOfFltVecsE.Len();
787  KeyToIndexTypeE.AddDat(attr, TIntPr(FltType, CurrLen));
788  TVec<TFlt> NewVec = TVec<TFlt>();
789  for (i = 0; i < MxEId; i++) {
790  NewVec.Ins(i, GetFltAttrDefaultE(attr));
791  }
792  NewVec[EdgeH.GetKeyId(EId)] = value;
793  VecOfFltVecsE.Add(NewVec);
794  }
795  return 0;
796 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2068
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
TInt MxEId
Definition: network.h:1828
Definition: dt.h:1042
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1086
TFlt GetFltAttrDefaultE(const TStr &attribute) const
Get Flt edge attribute val. If not a proper attr, return default.
Definition: network.h:1824
TVal2 Val2
Definition: ds.h:35
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TDat & AddDat(const TKey &Key)
Definition: hash.h:196
int TNEANet::AddFltAttrDatN ( const TNodeI NodeI,
const TFlt value,
const TStr attr 
)
inline

Attribute based add function for attr to Flt value.

Adds the key flt value pair to the corresponding node attribute value vector.

Definition at line 2136 of file network.h.

2136 { return AddFltAttrDatN(NodeI.GetId(), value, attr); }
int AddFltAttrDatN(const TNodeI &NodeI, const TFlt &value, const TStr &attr)
Attribute based add function for attr to Flt value.
Definition: network.h:2136
int TNEANet::AddFltAttrDatN ( const int &  NId,
const TFlt value,
const TStr attr 
)

Definition at line 704 of file network.cpp.

704  {
705  int i;
706  TInt CurrLen;
707 
708  if (!IsNode(NId)) {
709  // AddNode(NId);
710  return -1;
711  }
712  if (KeyToIndexTypeN.IsKey(attr)) {
714  NewVec[NodeH.GetKeyId(NId)] = value;
715  } else {
716  CurrLen = VecOfFltVecsN.Len();
717  KeyToIndexTypeN.AddDat(attr, TIntPr(FltType, CurrLen));
718  TVec<TFlt> NewVec = TVec<TFlt>();
719  for (i = 0; i < MxNId; i++) {
720  NewVec.Ins(i, GetFltAttrDefaultN(attr));
721  }
722  NewVec[NodeH.GetKeyId(NId)] = value;
723  VecOfFltVecsN.Add(NewVec);
724  }
725  return 0;
726 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
TInt MxNId
Definition: network.h:1828
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
Definition: dt.h:1042
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1086
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1839
TVal2 Val2
Definition: ds.h:35
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:1906
THash< TInt, TNode > NodeH
Definition: network.h:1829
TFlt GetFltAttrDefaultN(const TStr &attribute) const
Get Flt node attribute val. If not a proper attr, return default.
Definition: network.h:1818
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TDat & AddDat(const TKey &Key)
Definition: hash.h:196
int TNEANet::AddFltAttrE ( const TStr attr,
TFlt  defaultValue = TFlt::Mn 
)

Adds a new Flt edge attribute to the hashmap.

Definition at line 988 of file network.cpp.

988  {
989  int i;
990  TInt CurrLen;
991  TVec<TFlt> NewVec;
992  CurrLen = VecOfStrVecsE.Len();
993  KeyToIndexTypeE.AddDat(attr, TIntPr(FltType, CurrLen));
994  NewVec = TVec<TFlt>();
995  for (i = 0; i < MxEId; i++) {
996  NewVec.Ins(i, defaultValue);
997  }
998  VecOfFltVecsE.Add(NewVec);
999  if (!FltDefaultsE.IsKey(attr)) {
1000  FltDefaultsE.AddDat(attr, defaultValue);
1001  } else {
1002  return -1;
1003  }
1004  return 0;
1005 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:1836
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
TInt MxEId
Definition: network.h:1828
Definition: dt.h:1042
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1086
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TDat & AddDat(const TKey &Key)
Definition: hash.h:196
int TNEANet::AddFltAttrN ( const TStr attr,
TFlt  defaultValue = TFlt::Mn 
)

Adds a new Flt node attribute to the hashmap.

Definition at line 929 of file network.cpp.

929  {
930  // TODO(nkhadke): add error checking
931  int i;
932  TInt CurrLen;
933  TVec<TFlt> NewVec;
934  CurrLen = VecOfStrVecsN.Len();
935  KeyToIndexTypeN.AddDat(attr, TIntPr(FltType, CurrLen));
936  NewVec = TVec<TFlt>();
937  for (i = 0; i < MxNId; i++) {
938  NewVec.Ins(i, defaultValue);
939  }
940  VecOfFltVecsN.Add(NewVec);
941  if (!FltDefaultsN.IsKey(attr)) {
942  FltDefaultsN.AddDat(attr, defaultValue);
943  } else {
944  return -1;
945  }
946  return 0;
947 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:1836
TInt MxNId
Definition: network.h:1828
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
Definition: dt.h:1042
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1086
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1839
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TDat & AddDat(const TKey &Key)
Definition: hash.h:196
int TNEANet::AddIntAttrDatE ( const TEdgeI EdgeI,
const TInt value,
const TStr attr 
)
inline

Attribute based add function for attr to Int value.

Adds the key int value pair to the corresponding edge attribute value vector.

Definition at line 2142 of file network.h.

2142 { return AddIntAttrDatE(EdgeI.GetId(), value, attr); }
int AddIntAttrDatE(const TEdgeI &EdgeI, const TInt &value, const TStr &attr)
Attribute based add function for attr to Int value.
Definition: network.h:2142
int TNEANet::AddIntAttrDatE ( const int &  EId,
const TInt value,
const TStr attr 
)

Definition at line 728 of file network.cpp.

728  {
729  int i;
730  TInt CurrLen;
731  if (!IsEdge(EId)) {
732  //AddEdge(EId);
733  return -1;
734  }
735  if (KeyToIndexTypeE.IsKey(attr)) {
737  NewVec[EdgeH.GetKeyId(EId)] = value;
738  } else {
739  CurrLen = VecOfIntVecsE.Len();
740  KeyToIndexTypeE.AddDat(attr, TIntPr(IntType, CurrLen));
741  TVec<TInt> NewVec = TVec<TInt>();
742  for (i = 0; i < MxEId; i++) {
743  NewVec.Ins(i, GetIntAttrDefaultE(attr));
744  }
745  NewVec[EdgeH.GetKeyId(EId)] = value;
746  VecOfIntVecsE.Add(NewVec);
747  }
748  return 0;
749 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
TInt GetIntAttrDefaultE(const TStr &attribute) const
Get Int edge attribute val. If not a proper attr, return default.
Definition: network.h:1820
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2068
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
TInt MxEId
Definition: network.h:1828
Definition: dt.h:1042
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1086
TVal2 Val2
Definition: ds.h:35
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TDat & AddDat(const TKey &Key)
Definition: hash.h:196
int TNEANet::AddIntAttrDatN ( const TNodeI NodeI,
const TInt value,
const TStr attr 
)
inline

Attribute based add function for attr to Int value.

Adds the key int value pair to the corresponding node attribute value vector.

Definition at line 2126 of file network.h.

2126 { return AddIntAttrDatN(NodeI.GetId(), value, attr); }
int AddIntAttrDatN(const TNodeI &NodeI, const TInt &value, const TStr &attr)
Attribute based add function for attr to Int value.
Definition: network.h:2126
int TNEANet::AddIntAttrDatN ( const int &  NId,
const TInt value,
const TStr attr 
)

Definition at line 658 of file network.cpp.

658  {
659  int i;
660  TInt CurrLen;
661  if (!IsNode(NId)) {
662  // AddNode(NId);
663  return -1;
664  }
665  if (KeyToIndexTypeN.IsKey(attr)) {
667  NewVec[NodeH.GetKeyId(NId)] = value;
668  } else {
669  CurrLen = VecOfIntVecsN.Len();
670  KeyToIndexTypeN.AddDat(attr, TIntPr(IntType, CurrLen));
671  TVec<TInt> NewVec = TVec<TInt>();
672  for (i = 0; i < MxNId; i++) {
673  NewVec.Ins(i, GetIntAttrDefaultN(attr));
674  }
675  NewVec[NodeH.GetKeyId(NId)] = value;
676  VecOfIntVecsN.Add(NewVec);
677  }
678  return 0;
679 }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1837
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
TInt MxNId
Definition: network.h:1828
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
Definition: dt.h:1042
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1086
TVal2 Val2
Definition: ds.h:35
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:1906
THash< TInt, TNode > NodeH
Definition: network.h:1829
TInt GetIntAttrDefaultN(const TStr &attribute) const
Get Int node attribute val. If not a proper attr, return default.
Definition: network.h:1814
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TDat & AddDat(const TKey &Key)
Definition: hash.h:196
int TNEANet::AddIntAttrE ( const TStr attr,
TInt  defaultValue = TInt::Mn 
)

Adds a new Int edge attribute to the hashmap.

Definition at line 949 of file network.cpp.

949  {
950  // TODO(nkhadke): add error checking
951  int i;
952  TInt CurrLen;
953  TVec<TInt> NewVec;
954  CurrLen = VecOfIntVecsE.Len();
955  KeyToIndexTypeE.AddDat(attr, TIntPr(IntType, CurrLen));
956  NewVec = TVec<TInt>();
957  for (i = 0; i < MxEId; i++) {
958  NewVec.Ins(i, defaultValue);
959  }
960  VecOfIntVecsE.Add(NewVec);
961  if (!IntDefaultsE.IsKey(attr)) {
962  IntDefaultsE.AddDat(attr, defaultValue);
963  } else {
964  return -1;
965  }
966  return 0;
967 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
THash< TStr, TInt > IntDefaultsE
Definition: network.h:1834
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
TInt MxEId
Definition: network.h:1828
Definition: dt.h:1042
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1086
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TDat & AddDat(const TKey &Key)
Definition: hash.h:196
int TNEANet::AddIntAttrN ( const TStr attr,
TInt  defaultValue = TInt::Mn 
)

Adds a new Int node attribute to the hashmap.

Definition at line 891 of file network.cpp.

891  {
892  int i;
893  TInt CurrLen;
894  TVec<TInt> NewVec;
895  CurrLen = VecOfIntVecsN.Len();
896  KeyToIndexTypeN.AddDat(attr, TIntPr(IntType, CurrLen));
897  NewVec = TVec<TInt>();
898  for (i = 0; i < MxNId; i++) {
899  NewVec.Ins(i, defaultValue);
900  }
901  VecOfIntVecsN.Add(NewVec);
902  if (!IntDefaultsN.IsKey(attr)) {
903  IntDefaultsN.AddDat(attr, defaultValue);
904  } else {
905  return -1;
906  }
907  return 0;
908 }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1837
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
TInt MxNId
Definition: network.h:1828
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
Definition: dt.h:1042
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1086
THash< TStr, TInt > IntDefaultsN
Definition: network.h:1834
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TDat & AddDat(const TKey &Key)
Definition: hash.h:196
int TNEANet::AddNode ( int  NId = -1)

Adds a node of ID NId to the graph.

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 313 of file network.cpp.

313  {
314  int i;
315  if (NId == -1) {
316  NId = MxNId; MxNId++;
317  } else {
318  IAssertR(!IsNode(NId), TStr::Fmt("NodeId %d already exists", NId));
319  MxNId = TMath::Mx(NId+1, MxNId());
320  }
321  // update attribute columns
322  NodeH.AddDat(NId, TNode(NId));
323  for (i = 0; i < VecOfIntVecsN.Len(); i++) {
324  TVec<TInt>& IntVec = VecOfIntVecsN[i];
325  IntVec.Ins(NodeH.GetKeyId(NId), TInt::Mn);
326  }
327  TVec<TStr> DefIntVec = TVec<TStr>();
328  IntDefaultsN.GetKeyV(DefIntVec);
329  for (i = 0; i < DefIntVec.Len(); i++) {
330  TStr attr = DefIntVec[i];
331  TVec<TInt>& IntVec = VecOfIntVecsN[KeyToIndexTypeN.GetDat(DefIntVec[i]).Val2];
332  IntVec[NodeH.GetKeyId(NId)] = GetIntAttrDefaultN(attr);
333  }
334  for (i = 0; i < VecOfStrVecsN.Len(); i++) {
335  TVec<TStr>& StrVec = VecOfStrVecsN[i];
336  StrVec.Ins(NodeH.GetKeyId(NId), TStr::GetNullStr());
337  }
338  TVec<TStr> DefStrVec = TVec<TStr>();
339  IntDefaultsN.GetKeyV(DefStrVec);
340  for (i = 0; i < DefStrVec.Len(); i++) {
341  TStr attr = DefStrVec[i];
342  TVec<TStr>& StrVec = VecOfStrVecsN[KeyToIndexTypeN.GetDat(DefStrVec[i]).Val2];
343  StrVec[NodeH.GetKeyId(NId)] = GetStrAttrDefaultN(attr);
344  }
345  for (i = 0; i < VecOfFltVecsN.Len(); i++) {
346  TVec<TFlt>& FltVec = VecOfFltVecsN[i];
347  FltVec.Ins(NodeH.GetKeyId(NId), TFlt::Mn);
348  }
349  TVec<TStr> DefFltVec = TVec<TStr>();
350  FltDefaultsN.GetKeyV(DefFltVec);
351  for (i = 0; i < DefFltVec.Len(); i++) {
352  TStr attr = DefFltVec[i];
353  TVec<TFlt>& FltVec = VecOfFltVecsN[KeyToIndexTypeN.GetDat(DefFltVec[i]).Val2];
354  FltVec[NodeH.GetKeyId(NId)] = GetFltAttrDefaultN(attr);
355  }
356  return NId;
357 }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1837
#define IAssertR(Cond, Reason)
Definition: bd.h:265
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:1836
TInt MxNId
Definition: network.h:1828
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
static const int Mn
Definition: dt.h:1046
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
TStr GetStrAttrDefaultN(const TStr &attribute) const
Get Str node attribute val. If not a proper attr, return default.
Definition: network.h:1816
static TStr GetNullStr()
Definition: dt.cpp:1626
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1086
void GetKeyV(TVec< TKey > &KeyV) const
Definition: hash.h:438
Definition: dt.h:412
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1839
TVal2 Val2
Definition: ds.h:35
THash< TStr, TInt > IntDefaultsN
Definition: network.h:1834
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:1906
THash< TInt, TNode > NodeH
Definition: network.h:1829
TFlt GetFltAttrDefaultN(const TStr &attribute) const
Get Flt node attribute val. If not a proper attr, return default.
Definition: network.h:1818
TInt GetIntAttrDefaultN(const TStr &attribute) const
Get Int node attribute val. If not a proper attr, return default.
Definition: network.h:1814
TDat & AddDat(const TKey &Key)
Definition: hash.h:196
static const double Mn
Definition: dt.h:1295
int TNEANet::AddNode ( const TNodeI NodeI)
inline

Adds a node of ID NodeI.GetId() to the graph.

Definition at line 1898 of file network.h.

1898 { return AddNode(NodeI.GetId()); }
int AddNode(int NId=-1)
Adds a node of ID NId to the graph.
Definition: network.cpp:313
int TNEANet::AddStrAttrDatE ( const TEdgeI EdgeI,
const TStr value,
const TStr attr 
)
inline

Attribute based add function for attr to Str value.

Adds the key str value pair to the corresponding edge attribute value vector.

Definition at line 2147 of file network.h.

2147 { return AddStrAttrDatE(EdgeI.GetId(), value, attr); }
int AddStrAttrDatE(const TEdgeI &EdgeI, const TStr &value, const TStr &attr)
Attribute based add function for attr to Str value.
Definition: network.h:2147
int TNEANet::AddStrAttrDatE ( const int &  EId,
const TStr value,
const TStr attr 
)

Definition at line 751 of file network.cpp.

751  {
752  int i;
753  TInt CurrLen;
754  if (!IsEdge(EId)) {
755  //AddEdge(EId);
756  return -1;
757  }
758  if (KeyToIndexTypeE.IsKey(attr)) {
760  NewVec[EdgeH.GetKeyId(EId)] = value;
761  } else {
762  CurrLen = VecOfStrVecsE.Len();
763  KeyToIndexTypeE.AddDat(attr, TIntPr(StrType, CurrLen));
764  TVec<TStr> NewVec = TVec<TStr>();
765  for (i = 0; i < MxEId; i++) {
766  NewVec.Ins(i, GetStrAttrDefaultE(attr));
767  }
768  NewVec[EdgeH.GetKeyId(EId)] = value;
769  VecOfStrVecsE.Add(NewVec);
770  }
771  return 0;
772 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2068
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
TStr GetStrAttrDefaultE(const TStr &attribute) const
Get Str edge attribute val. If not a proper attr, return default.
Definition: network.h:1822
TInt MxEId
Definition: network.h:1828
Definition: dt.h:1042
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1086
TVal2 Val2
Definition: ds.h:35
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TDat & AddDat(const TKey &Key)
Definition: hash.h:196
int TNEANet::AddStrAttrDatN ( const TNodeI NodeI,
const TStr value,
const TStr attr 
)
inline

Attribute based add function for attr to Str value.

Adds the key str value pair to the corresponding node attribute value vector.

Definition at line 2131 of file network.h.

2131 { return AddStrAttrDatN(NodeI.GetId(), value, attr); }
int AddStrAttrDatN(const TNodeI &NodeI, const TStr &value, const TStr &attr)
Attribute based add function for attr to Str value.
Definition: network.h:2131
int TNEANet::AddStrAttrDatN ( const int &  NId,
const TStr value,
const TStr attr 
)

Definition at line 681 of file network.cpp.

681  {
682  int i;
683  TInt CurrLen;
684  if (!IsNode(NId)) {
685  // AddNode(NId);
686  return -1;
687  }
688  if (KeyToIndexTypeN.IsKey(attr)) {
690  NewVec[NodeH.GetKeyId(NId)] = value;
691  } else {
692  CurrLen = VecOfStrVecsN.Len();
693  KeyToIndexTypeN.AddDat(attr, TIntPr(StrType, CurrLen));
694  TVec<TStr> NewVec = TVec<TStr>();
695  for (i = 0; i < MxNId; i++) {
696  NewVec.Ins(i, GetStrAttrDefaultN(attr));
697  }
698  NewVec[NodeH.GetKeyId(NId)] = value;
699  VecOfStrVecsN.Add(NewVec);
700  }
701  return 0;
702 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
TInt MxNId
Definition: network.h:1828
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
TStr GetStrAttrDefaultN(const TStr &attribute) const
Get Str node attribute val. If not a proper attr, return default.
Definition: network.h:1816
Definition: dt.h:1042
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1086
TVal2 Val2
Definition: ds.h:35
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:1906
THash< TInt, TNode > NodeH
Definition: network.h:1829
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TDat & AddDat(const TKey &Key)
Definition: hash.h:196
int TNEANet::AddStrAttrE ( const TStr attr,
TStr  defaultValue = TStr::GetNullStr() 
)

Adds a new Str edge attribute to the hashmap.

Definition at line 969 of file network.cpp.

969  {
970  int i;
971  TInt CurrLen;
972  TVec<TStr> NewVec;
973  CurrLen = VecOfStrVecsE.Len();
974  KeyToIndexTypeE.AddDat(attr, TIntPr(StrType, CurrLen));
975  NewVec = TVec<TStr>();
976  for (i = 0; i < MxEId; i++) {
977  NewVec.Ins(i, defaultValue);
978  }
979  VecOfStrVecsE.Add(NewVec);
980  if (!StrDefaultsE.IsKey(attr)) {
981  StrDefaultsE.AddDat(attr, defaultValue);
982  } else {
983  return -1;
984  }
985  return 0;
986 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
TInt MxEId
Definition: network.h:1828
Definition: dt.h:1042
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1086
THash< TStr, TStr > StrDefaultsE
Definition: network.h:1835
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TDat & AddDat(const TKey &Key)
Definition: hash.h:196
int TNEANet::AddStrAttrN ( const TStr attr,
TStr  defaultValue = TStr::GetNullStr() 
)

Adds a new Str node attribute to the hashmap.

Definition at line 910 of file network.cpp.

910  {
911  int i;
912  TInt CurrLen;
913  TVec<TStr> NewVec;
914  CurrLen = VecOfStrVecsN.Len();
915  KeyToIndexTypeN.AddDat(attr, TIntPr(StrType, CurrLen));
916  NewVec = TVec<TStr>();
917  for (i = 0; i < MxNId; i++) {
918  NewVec.Ins(i, defaultValue);
919  }
920  VecOfStrVecsN.Add(NewVec);
921  if (!StrDefaultsN.IsKey(attr)) {
922  StrDefaultsN.AddDat(attr, defaultValue);
923  } else {
924  return -1;
925  }
926  return 0;
927 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
TInt MxNId
Definition: network.h:1828
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
THash< TStr, TStr > StrDefaultsN
Definition: network.h:1835
Definition: dt.h:1042
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1086
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TDat & AddDat(const TKey &Key)
Definition: hash.h:196
void TNEANet::AttrNameEI ( const TInt EId,
TStrV Names 
) const
inline

Returns a vector of attr names for edge EId.

Definition at line 1976 of file network.h.

1976  {
1977  AttrNameEI(EId, KeyToIndexTypeE.BegI(), Names);}
void AttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of attr names for edge EId.
Definition: network.h:1976
TIter BegI() const
Definition: hash.h:171
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
void TNEANet::AttrNameEI ( const TInt EId,
TStrIntPrH::TIter  EdgeHI,
TStrV Names 
) const

Definition at line 172 of file network.cpp.

172  {
173  Names = TVec<TStr>();
174  while (!EdgeHI.IsEnd()) {
175  if (!EdgeAttrIsDeleted(EId, EdgeHI)) {
176  Names.Add(EdgeHI.GetKey());
177  }
178  EdgeHI++;
179  }
180 }
bool EdgeAttrIsDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Definition: network.cpp:274
const TKey & GetKey() const
Definition: hash.h:71
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
Definition: hash.h:69
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
void TNEANet::AttrNameNI ( const TInt NId,
TStrV Names 
) const
inline

Returns a vector of attr names for node NId.

Definition at line 1943 of file network.h.

1943  {
1944  AttrNameNI(NId, KeyToIndexTypeN.BegI(), Names);}
TIter BegI() const
Definition: hash.h:171
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
void AttrNameNI(const TInt &NId, TStrV &Names) const
Returns a vector of attr names for node NId.
Definition: network.h:1943
void TNEANet::AttrNameNI ( const TInt NId,
TStrIntPrH::TIter  NodeHI,
TStrV Names 
) const

Definition at line 25 of file network.cpp.

25  {
26  Names = TVec<TStr>();
27  while (!NodeHI.IsEnd()) {
28  if (!NodeAttrIsDeleted(NId, NodeHI)) {
29  Names.Add(NodeHI.GetKey());
30  }
31  NodeHI++;
32  }
33 }
bool NodeAttrIsDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Definition: network.cpp:127
const TKey & GetKey() const
Definition: hash.h:71
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
Definition: hash.h:69
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
void TNEANet::AttrValueEI ( const TInt EId,
TStrV Values 
) const
inline

Returns a vector of attr values for edge EId.

Definition at line 1980 of file network.h.

1980  {
1981  AttrValueEI(EId, KeyToIndexTypeE.BegI(), Values);}
TIter BegI() const
Definition: hash.h:171
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
void AttrValueEI(const TInt &EId, TStrV &Values) const
Returns a vector of attr values for edge EId.
Definition: network.h:1980
void TNEANet::AttrValueEI ( const TInt EId,
TStrIntPrH::TIter  EdgeHI,
TStrV Values 
) const

Definition at line 182 of file network.cpp.

182  {
183  Values = TVec<TStr>();
184  while (!EdgeHI.IsEnd()) {
185  if (!EdgeAttrIsDeleted(EId, EdgeHI)) {
186  Values.Add(GetEdgeAttrValue(EId, EdgeHI));
187  }
188  EdgeHI++;
189  }
190 }
TStr GetEdgeAttrValue(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Definition: network.cpp:299
bool EdgeAttrIsDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Definition: network.cpp:274
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
Definition: hash.h:69
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
void TNEANet::AttrValueNI ( const TInt NId,
TStrV Values 
) const
inline

Returns a vector of attr values for node NId.

Definition at line 1947 of file network.h.

1947  {
1948  AttrValueNI(NId, KeyToIndexTypeN.BegI(), Values);}
TIter BegI() const
Definition: hash.h:171
void AttrValueNI(const TInt &NId, TStrV &Values) const
Returns a vector of attr values for node NId.
Definition: network.h:1947
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
void TNEANet::AttrValueNI ( const TInt NId,
TStrIntPrH::TIter  NodeHI,
TStrV Values 
) const

Definition at line 35 of file network.cpp.

35  {
36  Values = TVec<TStr>();
37  while (!NodeHI.IsEnd()) {
38  if (!NodeAttrIsDeleted(NId, NodeHI)) {
39  Values.Add(GetNodeAttrValue(NId, NodeHI));
40  }
41  NodeHI++;
42  }
43 }
bool NodeAttrIsDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Definition: network.cpp:127
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
Definition: hash.h:69
TStr GetNodeAttrValue(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Definition: network.cpp:158
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
TAFltI TNEANet::BegEAFltI ( const TStr attr) const
inline

Returns an iterator referring to the first edge's flt attribute.

Definition at line 2032 of file network.h.

2032  {
2033  return TAFltI(VecOfFltVecsE[KeyToIndexTypeE.GetDat(attr).Val2].BegI(), attr, true, this);
2034  }
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
TVal2 Val2
Definition: ds.h:35
TAIntI TNEANet::BegEAIntI ( const TStr attr) const
inline

Returns an iterator referring to the first edge's int attribute.

Definition at line 2009 of file network.h.

2009  {
2010  return TAIntI(VecOfIntVecsE[KeyToIndexTypeE.GetDat(attr).Val2].BegI(), attr, true, this);
2011  }
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
TVal2 Val2
Definition: ds.h:35
TAStrI TNEANet::BegEAStrI ( const TStr attr) const
inline

Returns an iterator referring to the first edge's str attribute.

Definition at line 2021 of file network.h.

2021  {
2022  return TAStrI(VecOfStrVecsE[KeyToIndexTypeE.GetDat(attr).Val2].BegI(), attr, true, this); }
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVal2 Val2
Definition: ds.h:35
TEdgeI TNEANet::BegEI ( ) const
inline

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

Definition at line 2076 of file network.h.

2076 { return TEdgeI(EdgeH.BegI(), this); }
TIter BegI() const
Definition: hash.h:171
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
TAFltI TNEANet::BegNAFltI ( const TStr attr) const
inline

Returns an iterator referring to the first node's flt attribute.

Definition at line 1933 of file network.h.

1933  {
1934  return TAFltI(VecOfFltVecsN[KeyToIndexTypeN.GetDat(attr).Val2].BegI(), attr, false, this); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1839
TVal2 Val2
Definition: ds.h:35
TAIntI TNEANet::BegNAIntI ( const TStr attr) const
inline

Returns an iterator referring to the first node's int attribute.

Definition at line 1914 of file network.h.

1914  {
1915  return TAIntI(VecOfIntVecsN[KeyToIndexTypeN.GetDat(attr).Val2].BegI(), attr, false, this); }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1837
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
TVal2 Val2
Definition: ds.h:35
TAStrI TNEANet::BegNAStrI ( const TStr attr) const
inline

Returns an iterator referring to the first node's str attribute.

Definition at line 1923 of file network.h.

1923  {
1924 
1925  return TAStrI(VecOfStrVecsN[KeyToIndexTypeN.GetDat(attr).Val2].BegI(), attr, false, this); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
TVal2 Val2
Definition: ds.h:35
TNodeI TNEANet::BegNI ( ) const
inline

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

Definition at line 1908 of file network.h.

1908 { return TNodeI(NodeH.BegI(), this); }
TIter BegI() const
Definition: hash.h:171
THash< TInt, TNode > NodeH
Definition: network.h:1829
void TNEANet::Clr ( )
inline

Deletes all nodes and edges from the graph.

Definition at line 2100 of file network.h.

2100  { MxNId=0; MxEId=0; NodeH.Clr(); EdgeH.Clr(),
2103  VecOfIntVecsN.Clr(), VecOfIntVecsE.Clr(), VecOfStrVecsN.Clr(), VecOfStrVecsE.Clr(),
2104  VecOfFltVecsN.Clr(), VecOfFltVecsE.Clr();}
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1837
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:1836
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
THash< TStr, TInt > IntDefaultsE
Definition: network.h:1834
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:1836
TInt MxNId
Definition: network.h:1828
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
THash< TStr, TStr > StrDefaultsN
Definition: network.h:1835
TInt MxEId
Definition: network.h:1828
THash< TStr, TStr > StrDefaultsE
Definition: network.h:1835
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1839
void Clr(const bool &DoDel=true, const int &NoDelLim=-1, const bool &ResetDat=true)
Definition: hash.h:315
THash< TStr, TInt > IntDefaultsN
Definition: network.h:1834
THash< TInt, TNode > NodeH
Definition: network.h:1829
void TNEANet::Defrag ( const bool &  OnlyNodeLinks = false)

Defragments the graph.

After performing many node and edge insertions and deletions to a graph, the graph data structure will be fragmented in memory. This function compacts down the graph data structure and frees unneeded memory.

Definition at line 539 of file network.cpp.

539  {
540  for (int kid = NodeH.FFirstKeyId(); NodeH.FNextKeyId(kid); ) {
541  TNode& Node = NodeH[kid];
542  Node.InEIdV.Pack(); Node.OutEIdV.Pack();
543  }
544  if (! OnlyNodeLinks && ! NodeH.IsKeyIdEqKeyN()) { NodeH.Defrag(); }
545  if (! OnlyNodeLinks && ! EdgeH.IsKeyIdEqKeyN()) { EdgeH.Defrag(); }
546 }
bool IsKeyIdEqKeyN() const
Definition: hash.h:191
void Defrag()
Definition: hash.h:509
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
bool FNextKeyId(int &KeyId) const
Definition: hash.h:432
int FFirstKeyId() const
Definition: hash.h:232
THash< TInt, TNode > NodeH
Definition: network.h:1829
void Pack()
Definition: hash.h:243
int TNEANet::DelAttrDatE ( const TEdgeI EdgeI,
const TStr attr 
)
inline

Deletes the edge attribute for NodeI.

Definition at line 2220 of file network.h.

2220 { return DelAttrDatE(EdgeI.GetId(), attr); }
int DelAttrDatE(const TEdgeI &EdgeI, const TStr &attr)
Deletes the edge attribute for NodeI.
Definition: network.h:2220
int TNEANet::DelAttrDatE ( const int &  EId,
const TStr attr 
)

Definition at line 876 of file network.cpp.

876  {
877  // TODO(nkhadke): add error checking
878  TInt vecType = KeyToIndexTypeE(attr).Val1;
879  if (vecType == IntType) {
881  } else if (vecType == StrType) {
883  } else if (vecType == FltType) {
885  } else {
886  return -1;
887  }
888  return 0;
889 }
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
TInt GetIntAttrDefaultE(const TStr &attribute) const
Get Int edge attribute val. If not a proper attr, return default.
Definition: network.h:1820
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
TStr GetStrAttrDefaultE(const TStr &attribute) const
Get Str edge attribute val. If not a proper attr, return default.
Definition: network.h:1822
Definition: dt.h:1042
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TFlt GetFltAttrDefaultE(const TStr &attribute) const
Get Flt edge attribute val. If not a proper attr, return default.
Definition: network.h:1824
TVal2 Val2
Definition: ds.h:35
int TNEANet::DelAttrDatN ( const TNodeI NodeI,
const TStr attr 
)
inline

Deletes the node attribute for NodeI.

Definition at line 2217 of file network.h.

2217 { return DelAttrDatN(NodeI.GetId(), attr); }
int DelAttrDatN(const TNodeI &NodeI, const TStr &attr)
Deletes the node attribute for NodeI.
Definition: network.h:2217
int TNEANet::DelAttrDatN ( const int &  NId,
const TStr attr 
)

Definition at line 862 of file network.cpp.

862  {
863  TInt vecType = KeyToIndexTypeN(attr).Val1;
864  if (vecType == IntType) {
866  } else if (vecType == StrType) {
868  } else if (vecType == FltType) {
870  } else {
871  return -1;
872  }
873  return 0;
874 }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1837
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
TStr GetStrAttrDefaultN(const TStr &attribute) const
Get Str node attribute val. If not a proper attr, return default.
Definition: network.h:1816
Definition: dt.h:1042
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1839
TVal2 Val2
Definition: ds.h:35
THash< TInt, TNode > NodeH
Definition: network.h:1829
TFlt GetFltAttrDefaultN(const TStr &attribute) const
Get Flt node attribute val. If not a proper attr, return default.
Definition: network.h:1818
TInt GetIntAttrDefaultN(const TStr &attribute) const
Get Int node attribute val. If not a proper attr, return default.
Definition: network.h:1814
int TNEANet::DelAttrE ( const TStr attr)

Removes all the values for edge attr.

Definition at line 1031 of file network.cpp.

1031  {
1032  TInt vecType = KeyToIndexTypeE(attr).Val1;
1033  if (vecType == IntType) {
1035  if (IntDefaultsE.IsKey(attr)) {
1036  IntDefaultsE.DelKey(attr);
1037  }
1038  } else if (vecType == StrType) {
1040  if (StrDefaultsE.IsKey(attr)) {
1041  StrDefaultsE.DelKey(attr);
1042  }
1043  } else if (vecType == FltType) {
1045  if (FltDefaultsE.IsKey(attr)) {
1046  FltDefaultsE.DelKey(attr);
1047  }
1048  } else {
1049  return -1;
1050  }
1051  KeyToIndexTypeE.DelKey(attr);
1052  return 0;
1053 }
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:1836
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
THash< TStr, TInt > IntDefaultsE
Definition: network.h:1834
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
void DelKey(const TKey &Key)
Definition: hash.h:358
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
Definition: dt.h:1042
THash< TStr, TStr > StrDefaultsE
Definition: network.h:1835
TVal2 Val2
Definition: ds.h:35
bool IsKey(const TKey &Key) const
Definition: hash.h:216
int TNEANet::DelAttrN ( const TStr attr)

Removes all the values for node attr.

Definition at line 1007 of file network.cpp.

1007  {
1008  TInt vecType = KeyToIndexTypeN(attr).Val1;
1009  if (vecType == IntType) {
1011  if (IntDefaultsN.IsKey(attr)) {
1012  IntDefaultsN.DelKey(attr);
1013  }
1014  } else if (vecType == StrType) {
1016  if (StrDefaultsN.IsKey(attr)) {
1017  StrDefaultsN.DelKey(attr);
1018  }
1019  } else if (vecType == FltType) {
1021  if (FltDefaultsN.IsKey(attr)) {
1022  FltDefaultsN.DelKey(attr);
1023  }
1024  } else {
1025  return -1;
1026  }
1027  KeyToIndexTypeN.DelKey(attr);
1028  return 0;
1029 }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1837
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:1836
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
void DelKey(const TKey &Key)
Definition: hash.h:358
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
THash< TStr, TStr > StrDefaultsN
Definition: network.h:1835
Definition: dt.h:1042
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1839
TVal2 Val2
Definition: ds.h:35
THash< TStr, TInt > IntDefaultsN
Definition: network.h:1834
bool IsKey(const TKey &Key) const
Definition: hash.h:216
void TNEANet::DelEdge ( const int &  EId)

Deletes an edge with edge ID EId from the graph.

Definition at line 469 of file network.cpp.

469  {
470  int i;
471 
472  IAssert(IsEdge(EId));
473  const int SrcNId = GetEdge(EId).GetSrcNId();
474  const int DstNId = GetEdge(EId).GetDstNId();
475  GetNode(SrcNId).OutEIdV.DelIfIn(EId);
476  GetNode(DstNId).InEIdV.DelIfIn(EId);
477  EdgeH.DelKey(EId);
478 
479  for (i = 0; i < VecOfIntVecsE.Len(); i++) {
480  TVec<TInt>& IntVec = VecOfIntVecsE[i];
481  IntVec.Ins(EdgeH.GetKeyId(EId), TInt::Mn);
482  }
483  for (i = 0; i < VecOfStrVecsE.Len(); i++) {
484  TVec<TStr>& StrVec = VecOfStrVecsE[i];
485  StrVec.Ins(EdgeH.GetKeyId(EId), TStr::GetNullStr());
486  }
487  for (i = 0; i < VecOfFltVecsE.Len(); i++) {
488  TVec<TFlt>& FltVec = VecOfFltVecsE[i];
489  FltVec.Ins(EdgeH.GetKeyId(EId), TFlt::Mn);
490  }
491 }
#define IAssert(Cond)
Definition: bd.h:262
bool DelIfIn(const TVal &Val)
Removes the first occurrence of element Val.
Definition: ds.h:1115
int GetSrcNId() const
Definition: network.h:1623
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
TNode & GetNode(const int &NId)
Definition: network.h:1808
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2068
TIntV OutEIdV
Definition: network.h:1595
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
void DelKey(const TKey &Key)
Definition: hash.h:358
static const int Mn
Definition: dt.h:1046
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
int GetDstNId() const
Definition: network.h:1624
static TStr GetNullStr()
Definition: dt.cpp:1626
TEdge & GetEdge(const int &EId)
Definition: network.h:1810
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1086
TIntV InEIdV
Definition: network.h:1595
static const double Mn
Definition: dt.h:1295
void TNEANet::DelEdge ( const int &  SrcNId,
const int &  DstNId,
const bool &  IsDir = true 
)

Deletes all edges between node IDs SrcNId and DstNId from the graph.

If the edge (SrcNId, DstNId) does not exist in the graph function still completes. But the function aborts if SrcNId or DstNId are not nodes in the graph.

Definition at line 494 of file network.cpp.

494  {
495  int EId = 0;
496  bool Edge = IsEdge(SrcNId, DstNId, EId, IsDir);
497  IAssert(Edge); // there is at least one edge
498  while (Edge) {
499  DelEdge(EId);
500  Edge = IsEdge(SrcNId, DstNId, EId, IsDir);
501  }
502 }
#define IAssert(Cond)
Definition: bd.h:262
void DelEdge(const int &EId)
Deletes an edge with edge ID EId from the graph.
Definition: network.cpp:469
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2068
void TNEANet::DelNode ( const int &  NId)

Deletes node of ID NId from the graph.

If the node of ID NId does not exist the function aborts.

Definition at line 359 of file network.cpp.

359  {
360  int i;
361 
362  const TNode& Node = GetNode(NId);
363  for (int out = 0; out < Node.GetOutDeg(); out++) {
364  const int EId = Node.GetOutEId(out);
365  const TEdge& Edge = GetEdge(EId);
366  IAssert(Edge.GetSrcNId() == NId);
367  GetNode(Edge.GetDstNId()).InEIdV.DelIfIn(EId);
368  // Delete from Edge Attributes
369  for (i = 0; i < VecOfIntVecsE.Len(); i++) {
370  TVec<TInt>& IntVec = VecOfIntVecsE[i];
371  IntVec[EdgeH.GetKeyId(EId)] = TInt::Mn;
372  }
373  for (i = 0; i < VecOfStrVecsE.Len(); i++) {
374  TVec<TStr>& StrVec = VecOfStrVecsE[i];
375  StrVec[EdgeH.GetKeyId(EId)] = TStr::GetNullStr();
376  }
377  for (i = 0; i < VecOfFltVecsE.Len(); i++) {
378  TVec<TFlt>& FltVec = VecOfFltVecsE[i];
379  FltVec[EdgeH.GetKeyId(EId)] = TFlt::Mn;
380  }
381  EdgeH.DelKey(EId);
382  }
383  for (int in = 0; in < Node.GetInDeg(); in++) {
384  const int EId = Node.GetInEId(in);
385  const TEdge& Edge = GetEdge(EId);
386  IAssert(Edge.GetDstNId() == NId);
387  GetNode(Edge.GetSrcNId()).OutEIdV.DelIfIn(EId);
388  // Delete from Edge Attributes
389  for (i = 0; i < VecOfIntVecsE.Len(); i++) {
390  TVec<TInt>& IntVec = VecOfIntVecsE[i];
391  IntVec[EdgeH.GetKeyId(EId)] = TInt::Mn;
392  }
393  for (i = 0; i < VecOfStrVecsE.Len(); i++) {
394  TVec<TStr>& StrVec = VecOfStrVecsE[i];
395  StrVec[EdgeH.GetKeyId(EId)] = TStr::GetNullStr();
396  }
397  for (i = 0; i < VecOfFltVecsE.Len(); i++) {
398  TVec<TFlt>& FltVec = VecOfFltVecsE[i];
399  FltVec[EdgeH.GetKeyId(EId)] = TFlt::Mn;
400  }
401  EdgeH.DelKey(EId);
402  }
403 
404  for (i = 0; i < VecOfIntVecsN.Len(); i++) {
405  TVec<TInt>& IntVec = VecOfIntVecsN[i];
406  IntVec[NodeH.GetKeyId(NId)] = TInt::Mn;
407  }
408  for (i = 0; i < VecOfStrVecsN.Len(); i++) {
409  TVec<TStr>& StrVec = VecOfStrVecsN[i];
410  StrVec[NodeH.GetKeyId(NId)] = TStr::GetNullStr();
411  }
412  for (i = 0; i < VecOfFltVecsN.Len(); i++) {
413  TVec<TFlt>& FltVec = VecOfFltVecsN[i];
414  FltVec[NodeH.GetKeyId(NId)] = TFlt::Mn;
415  }
416  NodeH.DelKey(NId);
417 }
#define IAssert(Cond)
Definition: bd.h:262
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1837
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
TNode & GetNode(const int &NId)
Definition: network.h:1808
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
void DelKey(const TKey &Key)
Definition: hash.h:358
static const int Mn
Definition: dt.h:1046
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
static TStr GetNullStr()
Definition: dt.cpp:1626
TEdge & GetEdge(const int &EId)
Definition: network.h:1810
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1839
THash< TInt, TNode > NodeH
Definition: network.h:1829
static const double Mn
Definition: dt.h:1295
void TNEANet::DelNode ( const TNode NodeI)
inline

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

Definition at line 1904 of file network.h.

1904 { DelNode(NodeI.GetId()); }
void DelNode(const int &NId)
Deletes node of ID NId from the graph.
Definition: network.cpp:359
void TNEANet::Dump ( FILE *  OutF = stdout) const

Print the graph in a human readable form to an output stream OutF.

Definition at line 601 of file network.cpp.

601  {
602  const int NodePlaces = (int) ceil(log10((double) GetNodes()));
603  const int EdgePlaces = (int) ceil(log10((double) GetEdges()));
604  fprintf(OutF, "-------------------------------------------------\nDirected Node-Edge Network: nodes: %d, edges: %d\n", GetNodes(), GetEdges());
605  for (TNodeI NodeI = BegNI(); NodeI < EndNI(); NodeI++) {
606  fprintf(OutF, " %*d]\n", NodePlaces, NodeI.GetId());
607  // load node attributes
608  TIntV IntAttrN;
609  IntAttrValueNI(NodeI.GetId(), IntAttrN);
610  fprintf(OutF, " nai[%d]", IntAttrN.Len());
611  for (int i = 0; i < IntAttrN.Len(); i++) {
612  fprintf(OutF, " %*i", NodePlaces, IntAttrN[i]()); }
613  TStrV StrAttrN;
614  StrAttrValueNI(NodeI.GetId(), StrAttrN);
615  fprintf(OutF, " nas[%d]", StrAttrN.Len());
616  for (int i = 0; i < StrAttrN.Len(); i++) {
617  fprintf(OutF, " %*s", NodePlaces, StrAttrN[i]()); }
618  TFltV FltAttrN;
619  FltAttrValueNI(NodeI.GetId(), FltAttrN);
620  fprintf(OutF, " naf[%d]", FltAttrN.Len());
621  for (int i = 0; i < FltAttrN.Len(); i++) {
622  fprintf(OutF, " %*f", NodePlaces, FltAttrN[i]()); }
623 
624  fprintf(OutF, " in[%d]", NodeI.GetInDeg());
625  for (int edge = 0; edge < NodeI.GetInDeg(); edge++) {
626  fprintf(OutF, " %*d", EdgePlaces, NodeI.GetInEId(edge)); }
627  fprintf(OutF, "\n");
628  fprintf(OutF, " out[%d]", NodeI.GetOutDeg());
629  for (int edge = 0; edge < NodeI.GetOutDeg(); edge++) {
630  fprintf(OutF, " %*d", EdgePlaces, NodeI.GetOutEId(edge)); }
631  fprintf(OutF, "\n");
632  }
633  for (TEdgeI EdgeI = BegEI(); EdgeI < EndEI(); EdgeI++) {
634  fprintf(OutF, " %*d] %*d -> %*d\n", EdgePlaces, EdgeI.GetId(), NodePlaces, EdgeI.GetSrcNId(), NodePlaces, EdgeI.GetDstNId());
635 
636  // load edge attributes
637  TIntV IntAttrE;
638  IntAttrValueEI(EdgeI.GetId(), IntAttrE);
639  fprintf(OutF, " eai[%d]", IntAttrE.Len());
640  for (int i = 0; i < IntAttrE.Len(); i++) {
641  fprintf(OutF, " %*i", EdgePlaces, IntAttrE[i]()); }
642  TStrV StrAttrE;
643  StrAttrValueEI(EdgeI.GetId(), StrAttrE);
644  fprintf(OutF, " eas[%d]", StrAttrE.Len());
645  for (int i = 0; i < StrAttrE.Len(); i++) {
646  fprintf(OutF, " %*s", EdgePlaces, StrAttrE[i]()); }
647  TFltV FltAttrE;
648  FltAttrValueEI(EdgeI.GetId(), FltAttrE);
649  fprintf(OutF, " eaf[%d]", FltAttrE.Len());
650  for (int i = 0; i < FltAttrE.Len(); i++) {
651  fprintf(OutF, " %*f", EdgePlaces, FltAttrE[i]()); }
652  }
653  fprintf(OutF, "\n");
654 }
int GetNodes() const
Returns the number of nodes in the graph.
Definition: network.h:1890
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
void StrAttrValueNI(const TInt &NId, TStrV &Values) const
Returns a vector of attr values for node NId.
Definition: network.h:1963
void IntAttrValueEI(const TInt &EId, TIntV &Values) const
Returns a vector of attr values for edge EId.
Definition: network.h:1988
void StrAttrValueEI(const TInt &EId, TStrV &Values) const
Returns a vector of attr values for node NId.
Definition: network.h:1996
void FltAttrValueEI(const TInt &EId, TFltV &Values) const
Returns a vector of attr values for node NId.
Definition: network.h:2004
TEdgeI BegEI() const
Returns an iterator referring to the first edge in the graph.
Definition: network.h:2076
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the graph.
Definition: network.h:2078
void FltAttrValueNI(const TInt &NId, TFltV &Values) const
Returns a vector of attr values for node NId.
Definition: network.h:1971
void IntAttrValueNI(const TInt &NId, TIntV &Values) const
Returns a vector of attr values for node NId.
Definition: network.h:1955
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the graph.
Definition: network.h:1910
int GetEdges() const
Returns the number of edges in the graph.
Definition: network.h:2049
TNodeI BegNI() const
Returns an iterator referring to the first node in the graph.
Definition: network.h:1908
bool TNEANet::EdgeAttrIsDeleted ( const int &  EId,
const TStrIntPrH::TIter EdgeHI 
) const

Definition at line 274 of file network.cpp.

274  {
275  bool IntDel = EdgeAttrIsIntDeleted(EId, EdgeHI);
276  bool StrDel = EdgeAttrIsStrDeleted(EId, EdgeHI);
277  bool FltDel = EdgeAttrIsFltDeleted(EId, EdgeHI);
278  return IntDel || StrDel || FltDel;
279 }
bool EdgeAttrIsFltDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Definition: network.cpp:293
bool EdgeAttrIsIntDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Definition: network.cpp:281
bool EdgeAttrIsStrDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Definition: network.cpp:287
bool TNEANet::EdgeAttrIsFltDeleted ( const int &  EId,
const TStrIntPrH::TIter EdgeHI 
) const

Definition at line 293 of file network.cpp.

293  {
294  return (EdgeHI.GetDat().Val1 == FltType &&
295  GetFltAttrDefaultE(EdgeHI.GetKey()) == this->VecOfFltVecsE.GetVal(
296  this->KeyToIndexTypeE.GetDat(EdgeHI.GetKey()).Val2).GetVal(EdgeH.GetKeyId(EId)));
297 }
const TKey & GetKey() const
Definition: hash.h:71
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
const TDat & GetDat() const
Definition: hash.h:72
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TFlt GetFltAttrDefaultE(const TStr &attribute) const
Get Flt edge attribute val. If not a proper attr, return default.
Definition: network.h:1824
bool TNEANet::EdgeAttrIsIntDeleted ( const int &  EId,
const TStrIntPrH::TIter EdgeHI 
) const

Definition at line 281 of file network.cpp.

281  {
282  return (EdgeHI.GetDat().Val1 == IntType &&
283  GetIntAttrDefaultE(EdgeHI.GetKey()) == this->VecOfIntVecsE.GetVal(
284  this->KeyToIndexTypeE.GetDat(EdgeHI.GetKey()).Val2).GetVal(EdgeH.GetKeyId(EId)));
285 }
TInt GetIntAttrDefaultE(const TStr &attribute) const
Get Int edge attribute val. If not a proper attr, return default.
Definition: network.h:1820
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
const TKey & GetKey() const
Definition: hash.h:71
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
const TDat & GetDat() const
Definition: hash.h:72
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
bool TNEANet::EdgeAttrIsStrDeleted ( const int &  EId,
const TStrIntPrH::TIter EdgeHI 
) const

Definition at line 287 of file network.cpp.

287  {
288  return (EdgeHI.GetDat().Val1 == StrType &&
289  GetStrAttrDefaultE(EdgeHI.GetKey()) == this->VecOfStrVecsE.GetVal(
290  this->KeyToIndexTypeE.GetDat(EdgeHI.GetKey()).Val2).GetVal(EdgeH.GetKeyId(EId)));
291 }
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
const TKey & GetKey() const
Definition: hash.h:71
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
const TDat & GetDat() const
Definition: hash.h:72
TStr GetStrAttrDefaultE(const TStr &attribute) const
Get Str edge attribute val. If not a proper attr, return default.
Definition: network.h:1822
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
bool TNEANet::Empty ( ) const
inline

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

Definition at line 2098 of file network.h.

2098 { return GetNodes()==0; }
int GetNodes() const
Returns the number of nodes in the graph.
Definition: network.h:1890
TAFltI TNEANet::EndEAFltI ( const TStr attr) const
inline

Returns an iterator referring to the past-the-end edge's attribute.

Definition at line 2036 of file network.h.

2036  {
2037  return TAFltI(VecOfFltVecsE[KeyToIndexTypeE.GetDat(attr).Val2].EndI(), attr, true, this);
2038  }
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
TVal2 Val2
Definition: ds.h:35
TAIntI TNEANet::EndEAIntI ( const TStr attr) const
inline

Returns an iterator referring to the past-the-end edge's attribute.

Definition at line 2013 of file network.h.

2013  {
2014  return TAIntI(VecOfIntVecsE[KeyToIndexTypeE.GetDat(attr).Val2].EndI(), attr, true, this);
2015  }
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
TVal2 Val2
Definition: ds.h:35
TAStrI TNEANet::EndEAStrI ( const TStr attr) const
inline

Returns an iterator referring to the past-the-end edge's attribute.

Definition at line 2024 of file network.h.

2024  {
2025  return TAStrI(VecOfStrVecsE[KeyToIndexTypeE.GetDat(attr).Val2].EndI(), attr, true, this);
2026  }
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVal2 Val2
Definition: ds.h:35
TEdgeI TNEANet::EndEI ( ) const
inline

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

Definition at line 2078 of file network.h.

2078 { return TEdgeI(EdgeH.EndI(), this); }
TIter EndI() const
Definition: hash.h:176
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
TAFltI TNEANet::EndNAFltI ( const TStr attr) const
inline

Returns an iterator referring to the past-the-end node's attribute.

Definition at line 1936 of file network.h.

1936  {
1937  return TAFltI(VecOfFltVecsN[KeyToIndexTypeN.GetDat(attr).Val2].EndI(), attr, false, this); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1839
TVal2 Val2
Definition: ds.h:35
TAIntI TNEANet::EndNAIntI ( const TStr attr) const
inline

Returns an iterator referring to the past-the-end node's attribute.

Definition at line 1917 of file network.h.

1917  {
1918  return TAIntI(VecOfIntVecsN[KeyToIndexTypeN.GetDat(attr).Val2].EndI(), attr, false, this); }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1837
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
TVal2 Val2
Definition: ds.h:35
TAStrI TNEANet::EndNAStrI ( const TStr attr) const
inline

Returns an iterator referring to the past-the-end node's attribute.

Definition at line 1927 of file network.h.

1927  {
1928  return TAStrI(VecOfStrVecsN[KeyToIndexTypeN.GetDat(attr).Val2].EndI(), attr, false, this); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
TVal2 Val2
Definition: ds.h:35
TNodeI TNEANet::EndNI ( ) const
inline

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

Definition at line 1910 of file network.h.

1910 { return TNodeI(NodeH.EndI(), this); }
TIter EndI() const
Definition: hash.h:176
THash< TInt, TNode > NodeH
Definition: network.h:1829
void TNEANet::FltAttrNameEI ( const TInt EId,
TStrV Names 
) const
inline

Returns a vector of int attr names for node NId.

Definition at line 2000 of file network.h.

2000  {
2001  FltAttrNameEI(EId, KeyToIndexTypeE.BegI(), Names);}
TIter BegI() const
Definition: hash.h:171
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
void FltAttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of int attr names for node NId.
Definition: network.h:2000
void TNEANet::FltAttrNameEI ( const TInt EId,
TStrIntPrH::TIter  EdgeHI,
TStrV Names 
) const

Definition at line 234 of file network.cpp.

234  {
235  Names = TVec<TStr>();
236  while (!EdgeHI.IsEnd()) {
237  if (EdgeHI.GetDat().Val1 == FltType && !EdgeAttrIsFltDeleted(EId, EdgeHI)) {
238  Names.Add(EdgeHI.GetKey());
239  }
240  EdgeHI++;
241  }
242 }
bool EdgeAttrIsFltDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Definition: network.cpp:293
const TKey & GetKey() const
Definition: hash.h:71
const TDat & GetDat() const
Definition: hash.h:72
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
Definition: hash.h:69
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
void TNEANet::FltAttrNameNI ( const TInt NId,
TStrV Names 
) const
inline

Returns a vector of int attr names for node NId.

Definition at line 1967 of file network.h.

1967  {
1968  FltAttrNameNI(NId, KeyToIndexTypeN.BegI(), Names);}
void FltAttrNameNI(const TInt &NId, TStrV &Names) const
Returns a vector of int attr names for node NId.
Definition: network.h:1967
TIter BegI() const
Definition: hash.h:171
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
void TNEANet::FltAttrNameNI ( const TInt NId,
TStrIntPrH::TIter  NodeHI,
TStrV Names 
) const

Definition at line 87 of file network.cpp.

87  {
88  Names = TVec<TStr>();
89  while (!NodeHI.IsEnd()) {
90  if (NodeHI.GetDat().Val1 == FltType && !NodeAttrIsFltDeleted(NId, NodeHI)) {
91  Names.Add(NodeHI.GetKey());
92  }
93  NodeHI++;
94  }
95 }
const TKey & GetKey() const
Definition: hash.h:71
bool NodeAttrIsFltDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Definition: network.cpp:150
const TDat & GetDat() const
Definition: hash.h:72
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
Definition: hash.h:69
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
void TNEANet::FltAttrValueEI ( const TInt EId,
TFltV Values 
) const
inline

Returns a vector of attr values for node NId.

Definition at line 2004 of file network.h.

2004  {
2005  FltAttrValueEI(EId, KeyToIndexTypeE.BegI(), Values);}
TIter BegI() const
Definition: hash.h:171
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
void FltAttrValueEI(const TInt &EId, TFltV &Values) const
Returns a vector of attr values for node NId.
Definition: network.h:2004
void TNEANet::FltAttrValueEI ( const TInt EId,
TStrIntPrH::TIter  EdgeHI,
TFltV Values 
) const

Definition at line 244 of file network.cpp.

244  {
245  Values = TVec<TFlt>();
246  while (!EdgeHI.IsEnd()) {
247  if (EdgeHI.GetDat().Val1 == FltType && !EdgeAttrIsFltDeleted(EId, EdgeHI)) {
248  TFlt val = (this->VecOfFltVecsE.GetVal(EdgeHI.GetDat().Val2).GetVal(EId));
249  Values.Add(val);
250  }
251  EdgeHI++;
252  }
253 }
bool EdgeAttrIsFltDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Definition: network.cpp:293
Definition: dt.h:1291
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
const TDat & GetDat() const
Definition: hash.h:72
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
Definition: hash.h:69
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
void TNEANet::FltAttrValueNI ( const TInt NId,
TFltV Values 
) const
inline

Returns a vector of attr values for node NId.

Definition at line 1971 of file network.h.

1971  {
1972  FltAttrValueNI(NId, KeyToIndexTypeN.BegI(), Values);}
TIter BegI() const
Definition: hash.h:171
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
void FltAttrValueNI(const TInt &NId, TFltV &Values) const
Returns a vector of attr values for node NId.
Definition: network.h:1971
void TNEANet::FltAttrValueNI ( const TInt NId,
TStrIntPrH::TIter  NodeHI,
TFltV Values 
) const

Definition at line 97 of file network.cpp.

97  {
98  Values = TVec<TFlt>();
99  while (!NodeHI.IsEnd()) {
100  if (NodeHI.GetDat().Val1 == FltType && !NodeAttrIsFltDeleted(NId, NodeHI)) {
101  TFlt val = (this->VecOfFltVecsN.GetVal(NodeHI.GetDat().Val2).GetVal(NodeH.GetKeyId(NId)));
102  Values.Add(val);
103  }
104  NodeHI++;
105  }
106 }
Definition: dt.h:1291
bool NodeAttrIsFltDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Definition: network.cpp:150
const TDat & GetDat() const
Definition: hash.h:72
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
Definition: hash.h:69
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1839
THash< TInt, TNode > NodeH
Definition: network.h:1829
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
void TNEANet::GetAttrENames ( TStrV IntAttrNames,
TStrV FltAttrNames,
TStrV StrAttrNames 
) const

Fills each of the vectors with the names of edge attributes of the given type.

Definition at line 1079 of file network.cpp.

1079  {
1080  for (TStrIntPrH::TIter it = KeyToIndexTypeE.BegI(); it < KeyToIndexTypeE.EndI(); it++) {
1081  if (it.GetDat().GetVal1() == IntType) {
1082  IntAttrNames.Add(it.GetKey());
1083  }
1084  if (it.GetDat().GetVal1() == FltType) {
1085  FltAttrNames.Add(it.GetKey());
1086  }
1087  if (it.GetDat().GetVal1() == StrType) {
1088  StrAttrNames.Add(it.GetKey());
1089  }
1090  }
1091 }
TIter BegI() const
Definition: hash.h:171
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
TIter EndI() const
Definition: hash.h:176
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
int TNEANet::GetAttrIndE ( const TStr attr)

Gets the index of the edge attr value vector specified by attr.

Definition at line 858 of file network.cpp.

858  {
859  return KeyToIndexTypeE.GetDat(attr).Val2.Val;
860 }
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVal2 Val2
Definition: ds.h:35
int TNEANet::GetAttrIndN ( const TStr attr)

Gets the index of the node attr value vector specified by attr.

Definition at line 826 of file network.cpp.

826  {
827  return KeyToIndexTypeN.GetDat(attr).Val2.Val;
828 }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
TVal2 Val2
Definition: ds.h:35
void TNEANet::GetAttrNNames ( TStrV IntAttrNames,
TStrV FltAttrNames,
TStrV StrAttrNames 
) const

Fills each of the vectors with the names of node attributes of the given type.

Definition at line 1065 of file network.cpp.

1065  {
1066  for (TStrIntPrH::TIter it = KeyToIndexTypeN.BegI(); it < KeyToIndexTypeN.EndI(); it++) {
1067  if (it.GetDat().GetVal1() == IntType) {
1068  IntAttrNames.Add(it.GetKey());
1069  }
1070  if (it.GetDat().GetVal1() == FltType) {
1071  FltAttrNames.Add(it.GetKey());
1072  }
1073  if (it.GetDat().GetVal1() == StrType) {
1074  StrAttrNames.Add(it.GetKey());
1075  }
1076  }
1077 }
TIter BegI() const
Definition: hash.h:171
TIter EndI() const
Definition: hash.h:176
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
TAFltI TNEANet::GetEAFltI ( const TStr attr,
const int &  EId 
) const
inline

Returns an iterator referring to the edge of ID EId in the graph.

Definition at line 2040 of file network.h.

2040  {
2041  return TAFltI(VecOfFltVecsE[KeyToIndexTypeE.GetDat(attr).Val2].GetI(EdgeH.GetKeyId(EId)), attr, true, this);
2042  }
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TVal2 Val2
Definition: ds.h:35
TAIntI TNEANet::GetEAIntI ( const TStr attr,
const int &  EId 
) const
inline

Returns an iterator referring to the edge of ID EId in the graph.

Definition at line 2017 of file network.h.

2017  {
2018  return TAIntI(VecOfIntVecsE[KeyToIndexTypeE.GetDat(attr).Val2].GetI(EdgeH.GetKeyId(EId)), attr, true, this);
2019  }
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TVal2 Val2
Definition: ds.h:35
TAStrI TNEANet::GetEAStrI ( const TStr attr,
const int &  EId 
) const
inline

Returns an iterator referring to the edge of ID EId in the graph.

Definition at line 2028 of file network.h.

2028  {
2029  return TAStrI(VecOfStrVecsE[KeyToIndexTypeE.GetDat(attr).Val2].GetI(EdgeH.GetKeyId(EId)), attr, true, this);
2030  }
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TVal2 Val2
Definition: ds.h:35
TEdge& TNEANet::GetEdge ( const int &  EId)
inlineprivate

Definition at line 1810 of file network.h.

1810 { return EdgeH.GetDat(EId); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
const TEdge& TNEANet::GetEdge ( const int &  EId) const
inlineprivate

Definition at line 1811 of file network.h.

1811 { return EdgeH.GetDat(EId); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
TStr TNEANet::GetEdgeAttrValue ( const int &  EId,
const TStrIntPrH::TIter EdgeHI 
) const

Definition at line 299 of file network.cpp.

299  {
300  if (EdgeHI.GetDat().Val1 == IntType) {
301  return (this->VecOfIntVecsE.GetVal(
302  this->KeyToIndexTypeE.GetDat(EdgeHI.GetKey()).Val2).GetVal(EdgeH.GetKeyId(EId))).GetStr();
303  } else if(EdgeHI.GetDat().Val1 == StrType) {
304  return this->VecOfStrVecsE.GetVal(
305  this->KeyToIndexTypeE.GetDat(EdgeHI.GetKey()).Val2).GetVal(EdgeH.GetKeyId(EId));
306  } else if (EdgeHI.GetDat().Val1 == FltType) {
307  return (this->VecOfFltVecsE.GetVal(
308  this->KeyToIndexTypeE.GetDat(EdgeHI.GetKey()).Val2).GetVal(EdgeH.GetKeyId(EId))).GetStr();
309  }
310  return TStr::GetNullStr();
311 }
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
const TKey & GetKey() const
Definition: hash.h:71
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
const TDat & GetDat() const
Definition: hash.h:72
static TStr GetNullStr()
Definition: dt.cpp:1626
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
int TNEANet::GetEdges ( ) const
inline

Returns the number of edges in the graph.

Definition at line 2049 of file network.h.

2049 { return EdgeH.Len(); }
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
int Len() const
Definition: hash.h:186
TEdgeI TNEANet::GetEI ( const int &  EId) const
inline

Returns an iterator referring to edge with edge ID EId.

Definition at line 2080 of file network.h.

2080 { return TEdgeI(EdgeH.GetI(EId), this); }
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
TIter GetI(const TKey &Key) const
Definition: hash.h:178
TEdgeI TNEANet::GetEI ( const int &  SrcNId,
const int &  DstNId 
) const
inline

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

Definition at line 2082 of file network.h.

2082 { return GetEI(GetEId(SrcNId, DstNId)); }
TEdgeI GetEI(const int &EId) const
Returns an iterator referring to edge with edge ID EId.
Definition: network.h:2080
int GetEId(const int &SrcNId, const int &DstNId) const
Returns an edge ID between node IDs SrcNId and DstNId, if such an edge exists. Otherwise, return -1.
Definition: network.h:2074
int TNEANet::GetEId ( const int &  SrcNId,
const int &  DstNId 
) const
inline

Returns an edge ID between node IDs SrcNId and DstNId, if such an edge exists. Otherwise, return -1.

Definition at line 2074 of file network.h.

2074 { int EId; return IsEdge(SrcNId, DstNId, EId)?EId:-1; }
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2068
void TNEANet::GetEIdV ( TIntV EIdV) const

Gets a vector IDs of all edges in the graph.

Definition at line 532 of file network.cpp.

532  {
533  EIdV.Gen(GetEdges(), 0);
534  for (int E=EdgeH.FFirstKeyId(); EdgeH.FNextKeyId(E); ) {
535  EIdV.Add(EdgeH.GetKey(E));
536  }
537 }
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
bool FNextKeyId(int &KeyId) const
Definition: hash.h:432
int FFirstKeyId() const
Definition: hash.h:232
int GetEdges() const
Returns the number of edges in the graph.
Definition: network.h:2049
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:486
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:210
TFlt TNEANet::GetFltAttrDatE ( const TEdgeI EdgeI,
const TStr attr 
)
inline

Gets the value of flt attr from the edge attr value vector.

Definition at line 2193 of file network.h.

2193 { return GetFltAttrDatE(EdgeI.GetId(), attr); }
TFlt GetFltAttrDatE(const TEdgeI &EdgeI, const TStr &attr)
Gets the value of flt attr from the edge attr value vector.
Definition: network.h:2193
TFlt TNEANet::GetFltAttrDatE ( const int &  EId,
const TStr attr 
)

Definition at line 838 of file network.cpp.

838  {
840 }
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TVal2 Val2
Definition: ds.h:35
TFlt TNEANet::GetFltAttrDatN ( const TNodeI NodeI,
const TStr attr 
)
inline

Gets the value of flt attr from the node attr value vector.

Definition at line 2163 of file network.h.

2163 { return GetFltAttrDatN(NodeI.GetId(), attr); }
TFlt GetFltAttrDatN(const TNodeI &NodeI, const TStr &attr)
Gets the value of flt attr from the node attr value vector.
Definition: network.h:2163
TFlt TNEANet::GetFltAttrDatN ( const int &  NId,
const TStr attr 
)

Definition at line 806 of file network.cpp.

806  {
808 }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1839
TVal2 Val2
Definition: ds.h:35
THash< TInt, TNode > NodeH
Definition: network.h:1829
TFlt TNEANet::GetFltAttrDefaultE ( const TStr attribute) const
inlineprivate

Get Flt edge attribute val. If not a proper attr, return default.

Definition at line 1824 of file network.h.

1824 { return FltDefaultsE.IsKey(attribute) ? FltDefaultsE.GetDat(attribute) : (TFlt) TFlt::Mn; }
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:1836
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
Definition: dt.h:1291
bool IsKey(const TKey &Key) const
Definition: hash.h:216
static const double Mn
Definition: dt.h:1295
TFlt TNEANet::GetFltAttrDefaultN ( const TStr attribute) const
inlineprivate

Get Flt node attribute val. If not a proper attr, return default.

Definition at line 1818 of file network.h.

1818 { return FltDefaultsN.IsKey(attribute) ? FltDefaultsN.GetDat(attribute) : (TFlt) TFlt::Mn; }
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:1836
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
Definition: dt.h:1291
bool IsKey(const TKey &Key) const
Definition: hash.h:216
static const double Mn
Definition: dt.h:1295
TFlt TNEANet::GetFltAttrIndDatE ( const TEdgeI EdgeI,
const int &  index 
)
inline

Gets the value of a float edge attr specified by edge iterator EdgeI and the attr index.

Definition at line 2207 of file network.h.

2207 { return GetFltAttrIndDatE(EdgeI.GetId(), index); }
TFlt GetFltAttrIndDatE(const TEdgeI &EdgeI, const int &index)
Gets the value of a float edge attr specified by edge iterator EdgeI and the attr index...
Definition: network.h:2207
TFlt TNEANet::GetFltAttrIndDatE ( const int &  EId,
const int &  index 
)

Gets the value of an int edge attr specified by edge ID EId and the attr index.

Definition at line 850 of file network.cpp.

850  {
851  return VecOfFltVecsE[index][EdgeH.GetKeyId(EId)];
852 }
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TFlt TNEANet::GetFltAttrIndDatN ( const TNodeI NodeI,
const int &  index 
)
inline

Gets the value of a float node attr specified by node iterator NodeI and the attr index.

Definition at line 2182 of file network.h.

2182 { return GetFltAttrIndDatN(NodeI.GetId(), index); }
TFlt GetFltAttrIndDatN(const TNodeI &NodeI, const int &index)
Gets the value of a float node attr specified by node iterator NodeI and the attr index...
Definition: network.h:2182
TFlt TNEANet::GetFltAttrIndDatN ( const int &  NId,
const int &  index 
)

Gets the value of a float node attr specified by node ID NId and the attr index.

Definition at line 818 of file network.cpp.

818  {
819  return VecOfFltVecsN[index][NodeH.GetKeyId(NId)];
820 }
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1839
THash< TInt, TNode > NodeH
Definition: network.h:1829
TInt TNEANet::GetIntAttrDatE ( const TEdgeI EdgeI,
const TStr attr 
)
inline

Gets the value of int attr from the edge attr value vector.

Definition at line 2187 of file network.h.

2187 { return GetIntAttrDatE(EdgeI.GetId(), attr); }
TInt GetIntAttrDatE(const TEdgeI &EdgeI, const TStr &attr)
Gets the value of int attr from the edge attr value vector.
Definition: network.h:2187
TInt TNEANet::GetIntAttrDatE ( const int &  EId,
const TStr attr 
)

Definition at line 830 of file network.cpp.

830  {
832 }
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TVal2 Val2
Definition: ds.h:35
TInt TNEANet::GetIntAttrDatN ( const TNodeI NodeI,
const TStr attr 
)
inline

Gets the value of int attr from the node attr value vector.

Definition at line 2156 of file network.h.

2156 { return GetIntAttrDatN(NodeI.GetId(), attr); }
TInt GetIntAttrDatN(const TNodeI &NodeI, const TStr &attr)
Gets the value of int attr from the node attr value vector.
Definition: network.h:2156
TInt TNEANet::GetIntAttrDatN ( const int &  NId,
const TStr attr 
)

Definition at line 798 of file network.cpp.

798  {
800 }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1837
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TVal2 Val2
Definition: ds.h:35
THash< TInt, TNode > NodeH
Definition: network.h:1829
TInt TNEANet::GetIntAttrDefaultE ( const TStr attribute) const
inlineprivate

Get Int edge attribute val. If not a proper attr, return default.

Definition at line 1820 of file network.h.

1820 { return IntDefaultsE.IsKey(attribute) ? IntDefaultsE.GetDat(attribute) : (TInt) TInt::Mn; }
THash< TStr, TInt > IntDefaultsE
Definition: network.h:1834
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
static const int Mn
Definition: dt.h:1046
Definition: dt.h:1042
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TInt TNEANet::GetIntAttrDefaultN ( const TStr attribute) const
inlineprivate

Get Int node attribute val. If not a proper attr, return default.

Definition at line 1814 of file network.h.

1814 { return IntDefaultsN.IsKey(attribute) ? IntDefaultsN.GetDat(attribute) : (TInt) TInt::Mn; }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
static const int Mn
Definition: dt.h:1046
Definition: dt.h:1042
THash< TStr, TInt > IntDefaultsN
Definition: network.h:1834
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TInt TNEANet::GetIntAttrIndDatE ( const TEdgeI EdgeI,
const int &  index 
)
inline

Gets the value of an int edge attr specified by edge iterator EdgeI and the attr index.

Definition at line 2202 of file network.h.

2202 { return GetIntAttrIndDatE(EdgeI.GetId(), index); }
TInt GetIntAttrIndDatE(const TEdgeI &EdgeI, const int &index)
Gets the value of an int edge attr specified by edge iterator EdgeI and the attr index.
Definition: network.h:2202
TInt TNEANet::GetIntAttrIndDatE ( const int &  EId,
const int &  index 
)

Gets the value of an int edge attr specified by edge ID EId and the attr index.

Definition at line 842 of file network.cpp.

842  {
843  return VecOfIntVecsE[index][EdgeH.GetKeyId(EId)];
844 }
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TInt TNEANet::GetIntAttrIndDatN ( const TNodeI NodeI,
const int &  index 
)
inline

Gets the value of an int node attr specified by node iterator NodeI and the attr index.

Definition at line 2172 of file network.h.

2172 { return GetIntAttrIndDatN(NodeI.GetId(), index); }
TInt GetIntAttrIndDatN(const TNodeI &NodeI, const int &index)
Gets the value of an int node attr specified by node iterator NodeI and the attr index.
Definition: network.h:2172
TInt TNEANet::GetIntAttrIndDatN ( const int &  NId,
const int &  index 
)

Gets the value of an int node attr specified by node ID NId and the attr index.

Definition at line 810 of file network.cpp.

810  {
811  return VecOfIntVecsN[index][NodeH.GetKeyId(NId)];
812 }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1837
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
THash< TInt, TNode > NodeH
Definition: network.h:1829
int TNEANet::GetIntAttrIndE ( const TStr attr)

Gets the index of the edge attr value vector specified by attr (same as GetAttrIndE for compatibility reasons).

Definition at line 854 of file network.cpp.

854  {
855  return KeyToIndexTypeE.GetDat(attr).Val2.Val;
856 }
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVal2 Val2
Definition: ds.h:35
int TNEANet::GetIntAttrIndN ( const TStr attr)

Gets the index of the node attr value vector specified by attr (same as GetAttrIndN for compatibility reasons).

Definition at line 822 of file network.cpp.

822  {
823  return KeyToIndexTypeN.GetDat(attr).Val2.Val;
824 }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
TVal2 Val2
Definition: ds.h:35
int TNEANet::GetMxEId ( ) const
inline

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

Definition at line 2046 of file network.h.

2046 { return MxEId; }
TInt MxEId
Definition: network.h:1828
int TNEANet::GetMxNId ( ) const
inline

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

Definition at line 2044 of file network.h.

2044 { return MxNId; }
TInt MxNId
Definition: network.h:1828
TAFltI TNEANet::GetNAFltI ( const TStr attr,
const int &  NId 
) const
inline

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

Definition at line 1939 of file network.h.

1939  {
1940  return TAFltI(VecOfFltVecsN[KeyToIndexTypeN.GetDat(attr).Val2].GetI(NodeH.GetKeyId(NId)), attr, false, this); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1839
TVal2 Val2
Definition: ds.h:35
THash< TInt, TNode > NodeH
Definition: network.h:1829
TAIntI TNEANet::GetNAIntI ( const TStr attr,
const int &  NId 
) const
inline

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

Definition at line 1920 of file network.h.

1920  {
1921  return TAIntI(VecOfIntVecsN[KeyToIndexTypeN.GetDat(attr).Val2].GetI(NodeH.GetKeyId(NId)), attr, false, this); }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1837
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TVal2 Val2
Definition: ds.h:35
THash< TInt, TNode > NodeH
Definition: network.h:1829
TAStrI TNEANet::GetNAStrI ( const TStr attr,
const int &  NId 
) const
inline

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

Definition at line 1930 of file network.h.

1930  {
1931  return TAStrI(VecOfStrVecsN[KeyToIndexTypeN.GetDat(attr).Val2].GetI(NodeH.GetKeyId(NId)), attr, false, this); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TVal2 Val2
Definition: ds.h:35
THash< TInt, TNode > NodeH
Definition: network.h:1829
TNodeI TNEANet::GetNI ( const int &  NId) const
inline

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

Definition at line 1912 of file network.h.

1912 { return TNodeI(NodeH.GetI(NId), this); }
THash< TInt, TNode > NodeH
Definition: network.h:1829
TIter GetI(const TKey &Key) const
Definition: hash.h:178
void TNEANet::GetNIdV ( TIntV NIdV) const

Gets a vector IDs of all nodes in the graph.

Definition at line 525 of file network.cpp.

525  {
526  NIdV.Gen(GetNodes(), 0);
527  for (int N=NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
528  NIdV.Add(NodeH.GetKey(N));
529  }
530 }
int GetNodes() const
Returns the number of nodes in the graph.
Definition: network.h:1890
bool FNextKeyId(int &KeyId) const
Definition: hash.h:432
int FFirstKeyId() const
Definition: hash.h:232
THash< TInt, TNode > NodeH
Definition: network.h:1829
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:486
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:210
TNode& TNEANet::GetNode ( const int &  NId)
inlineprivate

Definition at line 1808 of file network.h.

1808 { return NodeH.GetDat(NId); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
THash< TInt, TNode > NodeH
Definition: network.h:1829
const TNode& TNEANet::GetNode ( const int &  NId) const
inlineprivate

Definition at line 1809 of file network.h.

1809 { return NodeH.GetDat(NId); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
THash< TInt, TNode > NodeH
Definition: network.h:1829
TStr TNEANet::GetNodeAttrValue ( const int &  NId,
const TStrIntPrH::TIter NodeHI 
) const

Definition at line 158 of file network.cpp.

158  {
159  if (NodeHI.GetDat().Val1 == IntType) {
160  return (this->VecOfIntVecsN.GetVal(
161  this->KeyToIndexTypeN.GetDat(NodeHI.GetKey()).Val2).GetVal(NodeH.GetKeyId(NId))).GetStr();
162  } else if(NodeHI.GetDat().Val1 == StrType) {
163  return this->VecOfStrVecsN.GetVal(
164  this->KeyToIndexTypeN.GetDat(NodeHI.GetKey()).Val2).GetVal(NodeH.GetKeyId(NId));
165  } else if (NodeHI.GetDat().Val1 == FltType) {
166  return (this->VecOfFltVecsN.GetVal(
167  this->KeyToIndexTypeN.GetDat(NodeHI.GetKey()).Val2).GetVal(NodeH.GetKeyId(NId))).GetStr();
168  }
169  return TStr::GetNullStr();
170 }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1837
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
const TKey & GetKey() const
Definition: hash.h:71
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
const TDat & GetDat() const
Definition: hash.h:72
static TStr GetNullStr()
Definition: dt.cpp:1626
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1839
THash< TInt, TNode > NodeH
Definition: network.h:1829
int TNEANet::GetNodes ( ) const
inline

Returns the number of nodes in the graph.

Definition at line 1890 of file network.h.

1890 { return NodeH.Len(); }
THash< TInt, TNode > NodeH
Definition: network.h:1829
int Len() const
Definition: hash.h:186
TEdgeI TNEANet::GetRndEI ( TRnd Rnd = TInt::Rnd)
inline

Returns an interator referring to a random edge in the graph.

Definition at line 2091 of file network.h.

2091 { return GetEI(GetRndEId(Rnd)); }
TEdgeI GetEI(const int &EId) const
Returns an iterator referring to edge with edge ID EId.
Definition: network.h:2080
int GetRndEId(TRnd &Rnd=TInt::Rnd)
Returns an ID of a random edge in the graph.
Definition: network.h:2089
int TNEANet::GetRndEId ( TRnd Rnd = TInt::Rnd)
inline

Returns an ID of a random edge in the graph.

Definition at line 2089 of file network.h.

2089 { return EdgeH.GetKey(EdgeH.GetRndKeyId(Rnd, 0.8)); }
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
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:398
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:210
TNodeI TNEANet::GetRndNI ( TRnd Rnd = TInt::Rnd)
inline

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

Definition at line 2087 of file network.h.

2087 { return GetNI(GetRndNId(Rnd)); }
int GetRndNId(TRnd &Rnd=TInt::Rnd)
Returns an ID of a random node in the graph.
Definition: network.h:2085
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the graph.
Definition: network.h:1912
int TNEANet::GetRndNId ( TRnd Rnd = TInt::Rnd)
inline

Returns an ID of a random node in the graph.

Definition at line 2085 of file network.h.

2085 { return NodeH.GetKey(NodeH.GetRndKeyId(Rnd, 0.8)); }
THash< TInt, TNode > NodeH
Definition: network.h:1829
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:398
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:210
PNEANet TNEANet::GetSmallGraph ( )
static

Returns a small multigraph on 5 nodes and 6 edges.

/// Edges:  0 -> 1, 0 -> 2, 0 -> 3, 0 -> 4, 1 -> 2, 1 -> 2
/// 

Definition at line 1056 of file network.cpp.

1056  {
1057  PNEANet Net = TNEANet::New();
1058  for (int i = 0; i < 5; i++) { Net->AddNode(i); }
1059  Net->AddEdge(0,1); Net->AddEdge(0,2);
1060  Net->AddEdge(0,3); Net->AddEdge(0,4);
1061  Net->AddEdge(1,2); Net->AddEdge(1,2);
1062  return Net;
1063 }
Definition: bd.h:196
static PNEANet New()
Static cons returns pointer to graph. Ex: PNEANet Graph=TNEANet::New().
Definition: network.h:1876
TStr TNEANet::GetStrAttrDatE ( const TEdgeI EdgeI,
const TStr attr 
)
inline

Gets the value of str attr from the edge attr value vector.

Definition at line 2190 of file network.h.

2190 { return GetStrAttrDatE(EdgeI.GetId(), attr); }
TStr GetStrAttrDatE(const TEdgeI &EdgeI, const TStr &attr)
Gets the value of str attr from the edge attr value vector.
Definition: network.h:2190
TStr TNEANet::GetStrAttrDatE ( const int &  EId,
const TStr attr 
)

Definition at line 834 of file network.cpp.

834  {
836 }
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TVal2 Val2
Definition: ds.h:35
TStr TNEANet::GetStrAttrDatN ( const TNodeI NodeI,
const TStr attr 
)
inline

Gets the value of str attr from the node attr value vector.

Definition at line 2160 of file network.h.

2160 { return GetStrAttrDatN(NodeI.GetId(), attr); }
TStr GetStrAttrDatN(const TNodeI &NodeI, const TStr &attr)
Gets the value of str attr from the node attr value vector.
Definition: network.h:2160
TStr TNEANet::GetStrAttrDatN ( const int &  NId,
const TStr attr 
)

Definition at line 802 of file network.cpp.

802  {
804 }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TVal2 Val2
Definition: ds.h:35
THash< TInt, TNode > NodeH
Definition: network.h:1829
TStr TNEANet::GetStrAttrDefaultE ( const TStr attribute) const
inlineprivate

Get Str edge attribute val. If not a proper attr, return default.

Definition at line 1822 of file network.h.

1822 { return StrDefaultsE.IsKey(attribute) ? StrDefaultsE.GetDat(attribute) : (TStr) TStr::GetNullStr(); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
static TStr GetNullStr()
Definition: dt.cpp:1626
THash< TStr, TStr > StrDefaultsE
Definition: network.h:1835
Definition: dt.h:412
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TStr TNEANet::GetStrAttrDefaultN ( const TStr attribute) const
inlineprivate

Get Str node attribute val. If not a proper attr, return default.

Definition at line 1816 of file network.h.

1816 { return StrDefaultsN.IsKey(attribute) ? StrDefaultsN.GetDat(attribute) : (TStr) TStr::GetNullStr(); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
THash< TStr, TStr > StrDefaultsN
Definition: network.h:1835
static TStr GetNullStr()
Definition: dt.cpp:1626
Definition: dt.h:412
bool IsKey(const TKey &Key) const
Definition: hash.h:216
TStr TNEANet::GetStrAttrIndDatE ( const TEdgeI EdgeI,
const int &  index 
)
inline

Gets the value of a string edge attr specified by edge iterator EdgeI and the attr index.

Definition at line 2212 of file network.h.

2212 { return GetStrAttrIndDatE(EdgeI.GetId(), index); }
TStr GetStrAttrIndDatE(const TEdgeI &EdgeI, const int &index)
Gets the value of a string edge attr specified by edge iterator EdgeI and the attr index...
Definition: network.h:2212
TStr TNEANet::GetStrAttrIndDatE ( const int &  EId,
const int &  index 
)

Gets the value of an int edge attr specified by edge ID EId and the attr index.

Definition at line 846 of file network.cpp.

846  {
847  return VecOfStrVecsE[index][EdgeH.GetKeyId(EId)];
848 }
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TStr TNEANet::GetStrAttrIndDatN ( const TNodeI NodeI,
const int &  index 
)
inline

Gets the value of a string node attr specified by node iterator NodeI and the attr index.

Definition at line 2177 of file network.h.

2177 { return GetStrAttrIndDatN(NodeI.GetId(), index); }
TStr GetStrAttrIndDatN(const TNodeI &NodeI, const int &index)
Gets the value of a string node attr specified by node iterator NodeI and the attr index...
Definition: network.h:2177
TStr TNEANet::GetStrAttrIndDatN ( const int &  NId,
const int &  index 
)

Gets the value of a string node attr specified by node ID NId and the attr index.

Definition at line 814 of file network.cpp.

814  {
815  return VecOfStrVecsN[index][NodeH.GetKeyId(NId)];
816 }
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
THash< TInt, TNode > NodeH
Definition: network.h:1829
bool TNEANet::HasFlag ( const TGraphFlag Flag) const

Allows for run-time checking the type of the graph (see the TGraphFlag for flags).

Definition at line 3 of file network.cpp.

3  {
4  return HasGraphFlag(TNEANet::TNet, Flag);
5 }
#define HasGraphFlag(TGraph, Flag)
For quick testing of the properties of the graph/network object (see TGraphFlag). ...
Definition: gbase.h:38
Directed multigraph with node edge attributes.
Definition: network.h:1587
void TNEANet::IntAttrNameEI ( const TInt EId,
TStrV Names 
) const
inline

Returns a vector of int attr names for edge EId.

Definition at line 1984 of file network.h.

1984  {
1985  IntAttrNameEI(EId, KeyToIndexTypeE.BegI(), Names);}
TIter BegI() const
Definition: hash.h:171
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
void IntAttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of int attr names for edge EId.
Definition: network.h:1984
void TNEANet::IntAttrNameEI ( const TInt EId,
TStrIntPrH::TIter  EdgeHI,
TStrV Names 
) const

Definition at line 192 of file network.cpp.

192  {
193  Names = TVec<TStr>();
194  while (!EdgeHI.IsEnd()) {
195  if (EdgeHI.GetDat().Val1 == IntType && !EdgeAttrIsIntDeleted(EId, EdgeHI)) {
196  Names.Add(EdgeHI.GetKey());
197  }
198  EdgeHI++;
199  }
200 }
bool EdgeAttrIsIntDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Definition: network.cpp:281
const TKey & GetKey() const
Definition: hash.h:71
const TDat & GetDat() const
Definition: hash.h:72
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
Definition: hash.h:69
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
void TNEANet::IntAttrNameNI ( const TInt NId,
TStrV Names 
) const
inline

Returns a vector of int attr names for node NId.

Definition at line 1951 of file network.h.

1951  {
1952  IntAttrNameNI(NId, KeyToIndexTypeN.BegI(), Names);}
TIter BegI() const
Definition: hash.h:171
void IntAttrNameNI(const TInt &NId, TStrV &Names) const
Returns a vector of int attr names for node NId.
Definition: network.h:1951
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
void TNEANet::IntAttrNameNI ( const TInt NId,
TStrIntPrH::TIter  NodeHI,
TStrV Names 
) const

Definition at line 45 of file network.cpp.

45  {
46  Names = TVec<TStr>();
47  while (!NodeHI.IsEnd()) {
48  if (NodeHI.GetDat().Val1 == IntType && !NodeAttrIsIntDeleted(NId, NodeHI)) {
49  Names.Add(NodeHI.GetKey());
50  }
51  NodeHI++;
52  }
53 }
const TKey & GetKey() const
Definition: hash.h:71
const TDat & GetDat() const
Definition: hash.h:72
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
Definition: hash.h:69
bool NodeAttrIsIntDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Definition: network.cpp:134
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
void TNEANet::IntAttrValueEI ( const TInt EId,
TIntV Values 
) const
inline

Returns a vector of attr values for edge EId.

Definition at line 1988 of file network.h.

1988  {
1989  IntAttrValueEI(EId, KeyToIndexTypeE.BegI(), Values);}
TIter BegI() const
Definition: hash.h:171
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
void IntAttrValueEI(const TInt &EId, TIntV &Values) const
Returns a vector of attr values for edge EId.
Definition: network.h:1988
void TNEANet::IntAttrValueEI ( const TInt EId,
TStrIntPrH::TIter  EdgeHI,
TIntV Values 
) const

Definition at line 202 of file network.cpp.

202  {
203  Values = TVec<TInt>();
204  while (!EdgeHI.IsEnd()) {
205  if (EdgeHI.GetDat().Val1 == IntType && !EdgeAttrIsIntDeleted(EId, EdgeHI)) {
206  TInt val = (this->VecOfIntVecsE.GetVal(EdgeHI.GetDat().Val2).GetVal(EId));
207  Values.Add(val);
208  }
209  EdgeHI++;
210  }
211 }
bool EdgeAttrIsIntDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Definition: network.cpp:281
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
const TDat & GetDat() const
Definition: hash.h:72
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
Definition: hash.h:69
Definition: dt.h:1042
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
void TNEANet::IntAttrValueNI ( const TInt NId,
TIntV Values 
) const
inline

Returns a vector of attr values for node NId.

Definition at line 1955 of file network.h.

1955  {
1956  IntAttrValueNI(NId, KeyToIndexTypeN.BegI(), Values);}
TIter BegI() const
Definition: hash.h:171
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
void IntAttrValueNI(const TInt &NId, TIntV &Values) const
Returns a vector of attr values for node NId.
Definition: network.h:1955
void TNEANet::IntAttrValueNI ( const TInt NId,
TStrIntPrH::TIter  NodeHI,
TIntV Values 
) const

Definition at line 55 of file network.cpp.

55  {
56  Values = TVec<TInt>();
57  while (!NodeHI.IsEnd()) {
58  if (NodeHI.GetDat().Val1 == IntType && !NodeAttrIsIntDeleted(NId, NodeHI)) {
59  TInt val = this->VecOfIntVecsN.GetVal(NodeHI.GetDat().Val2).GetVal(NodeH.GetKeyId(NId));
60  Values.Add(val);
61  }
62  NodeHI++;
63  }
64 }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1837
const TDat & GetDat() const
Definition: hash.h:72
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
Definition: hash.h:69
Definition: dt.h:1042
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
bool NodeAttrIsIntDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Definition: network.cpp:134
THash< TInt, TNode > NodeH
Definition: network.h:1829
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
bool TNEANet::IsAttrDeletedE ( const int &  EId,
const TStr attr 
) const

Definition at line 255 of file network.cpp.

255  {
256  bool IntDel = IsIntAttrDeletedE(EId, attr);
257  bool StrDel = IsStrAttrDeletedE(EId, attr);
258  bool FltDel = IsFltAttrDeletedE(EId, attr);
259  return IntDel || StrDel || FltDel;
260 }
bool IsFltAttrDeletedE(const int &EId, const TStr &attr) const
Definition: network.cpp:270
bool IsIntAttrDeletedE(const int &EId, const TStr &attr) const
Definition: network.cpp:262
bool IsStrAttrDeletedE(const int &EId, const TStr &attr) const
Definition: network.cpp:266
bool TNEANet::IsAttrDeletedN ( const int &  NId,
const TStr attr 
) const

Definition at line 108 of file network.cpp.

108  {
109  bool IntDel = IsIntAttrDeletedN(NId, attr);
110  bool StrDel = IsStrAttrDeletedN(NId, attr);
111  bool FltDel = IsFltAttrDeletedN(NId, attr);
112  return IntDel || StrDel || FltDel;
113 }
bool IsStrAttrDeletedN(const int &NId, const TStr &attr) const
Definition: network.cpp:119
bool IsFltAttrDeletedN(const int &NId, const TStr &attr) const
Definition: network.cpp:123
bool IsIntAttrDeletedN(const int &NId, const TStr &attr) const
Definition: network.cpp:115
bool TNEANet::IsEdge ( const int &  EId) const
inline

Tests whether an edge with edge ID EId exists in the graph.

Definition at line 2068 of file network.h.

2068 { return EdgeH.IsKey(EId); }
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
bool IsKey(const TKey &Key) const
Definition: hash.h:216
bool TNEANet::IsEdge ( const int &  SrcNId,
const int &  DstNId,
const bool &  IsDir = true 
) const
inline

Tests whether an edge between node IDs SrcNId and DstNId exists in the graph.

Definition at line 2070 of file network.h.

2070 { int EId; return IsEdge(SrcNId, DstNId, EId, IsDir); }
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2068
bool TNEANet::IsEdge ( const int &  SrcNId,
const int &  DstNId,
int &  EId,
const bool &  IsDir = true 
) const

Tests whether an edge between node IDs SrcNId and DstNId exists in the graph. if an edge exists, return its edge ID in EId.

Definition at line 504 of file network.cpp.

504  {
505  const TNode& SrcNode = GetNode(SrcNId);
506  for (int edge = 0; edge < SrcNode.GetOutDeg(); edge++) {
507  const TEdge& Edge = GetEdge(SrcNode.GetOutEId(edge));
508  if (DstNId == Edge.GetDstNId()) {
509  EId = Edge.GetId();
510  return true;
511  }
512  }
513  if (! IsDir) {
514  for (int edge = 0; edge < SrcNode.GetInDeg(); edge++) {
515  const TEdge& Edge = GetEdge(SrcNode.GetInEId(edge));
516  if (DstNId == Edge.GetSrcNId()) {
517  EId = Edge.GetId();
518  return true;
519  }
520  }
521  }
522  return false;
523 }
int GetId() const
Definition: network.h:1622
TNode & GetNode(const int &NId)
Definition: network.h:1808
TEdge & GetEdge(const int &EId)
Definition: network.h:1810
bool TNEANet::IsFltAttrDeletedE ( const int &  EId,
const TStr attr 
) const

Definition at line 270 of file network.cpp.

270  {
271  return EdgeAttrIsFltDeleted(EId, KeyToIndexTypeE.GetI(attr));
272 }
bool EdgeAttrIsFltDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Definition: network.cpp:293
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
TIter GetI(const TKey &Key) const
Definition: hash.h:178
bool TNEANet::IsFltAttrDeletedN ( const int &  NId,
const TStr attr 
) const

Definition at line 123 of file network.cpp.

123  {
124  return NodeAttrIsFltDeleted(NId, KeyToIndexTypeN.GetI(attr));
125 }
bool NodeAttrIsFltDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Definition: network.cpp:150
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
TIter GetI(const TKey &Key) const
Definition: hash.h:178
bool TNEANet::IsIntAttrDeletedE ( const int &  EId,
const TStr attr 
) const

Definition at line 262 of file network.cpp.

262  {
263  return EdgeAttrIsIntDeleted(EId, KeyToIndexTypeE.GetI(attr));
264 }
bool EdgeAttrIsIntDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Definition: network.cpp:281
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
TIter GetI(const TKey &Key) const
Definition: hash.h:178
bool TNEANet::IsIntAttrDeletedN ( const int &  NId,
const TStr attr 
) const

Definition at line 115 of file network.cpp.

115  {
116  return NodeAttrIsIntDeleted(NId, KeyToIndexTypeN.GetI(attr));
117 }
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
bool NodeAttrIsIntDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Definition: network.cpp:134
TIter GetI(const TKey &Key) const
Definition: hash.h:178
bool TNEANet::IsNode ( const int &  NId) const
inline

Tests whether ID NId is a node.

Definition at line 1906 of file network.h.

1906 { return NodeH.IsKey(NId); }
THash< TInt, TNode > NodeH
Definition: network.h:1829
bool IsKey(const TKey &Key) const
Definition: hash.h:216
bool TNEANet::IsOk ( const bool &  ThrowExcept = true) const

Checks the graph data structure for internal consistency.

For each node in the graph check that its neighbors are also nodes in the graph.

Definition at line 548 of file network.cpp.

548  {
549  bool RetVal = true;
550  for (int N = NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
551  const TNode& Node = NodeH[N];
552  if (! Node.OutEIdV.IsSorted()) {
553  const TStr Msg = TStr::Fmt("Out-edge list of node %d is not sorted.", Node.GetId());
554  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
555  }
556  if (! Node.InEIdV.IsSorted()) {
557  const TStr Msg = TStr::Fmt("In-edge list of node %d is not sorted.", Node.GetId());
558  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
559  }
560  // check out-edge ids
561  int prevEId = -1;
562  for (int e = 0; e < Node.GetOutDeg(); e++) {
563  if (! IsEdge(Node.GetOutEId(e))) {
564  const TStr Msg = TStr::Fmt("Out-edge id %d of node %d does not exist.", Node.GetOutEId(e), Node.GetId());
565  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
566  }
567  if (e > 0 && prevEId == Node.GetOutEId(e)) {
568  const TStr Msg = TStr::Fmt("Node %d has duplidate out-edge id %d.", Node.GetId(), Node.GetOutEId(e));
569  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
570  }
571  prevEId = Node.GetOutEId(e);
572  }
573  // check in-edge ids
574  prevEId = -1;
575  for (int e = 0; e < Node.GetInDeg(); e++) {
576  if (! IsEdge(Node.GetInEId(e))) {
577  const TStr Msg = TStr::Fmt("Out-edge id %d of node %d does not exist.", Node.GetInEId(e), Node.GetId());
578  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
579  }
580  if (e > 0 && prevEId == Node.GetInEId(e)) {
581  const TStr Msg = TStr::Fmt("Node %d has duplidate out-edge id %d.", Node.GetId(), Node.GetInEId(e));
582  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
583  }
584  prevEId = Node.GetInEId(e);
585  }
586  }
587  for (int E = EdgeH.FFirstKeyId(); EdgeH.FNextKeyId(E); ) {
588  const TEdge& Edge = EdgeH[E];
589  if (! IsNode(Edge.GetSrcNId())) {
590  const TStr Msg = TStr::Fmt("Edge %d source node %d does not exist.", Edge.GetId(), Edge.GetSrcNId());
591  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
592  }
593  if (! IsNode(Edge.GetDstNId())) {
594  const TStr Msg = TStr::Fmt("Edge %d destination node %d does not exist.", Edge.GetId(), Edge.GetDstNId());
595  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
596  }
597  }
598  return RetVal;
599 }
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2068
void ErrNotify(const char *NotifyCStr)
Definition: bd.h:74
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
bool FNextKeyId(int &KeyId) const
Definition: hash.h:432
int FFirstKeyId() const
Definition: hash.h:232
Definition: dt.h:412
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
#define EAssertR(Cond, MsgStr)
Definition: bd.h:283
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:1906
THash< TInt, TNode > NodeH
Definition: network.h:1829
char * CStr()
Definition: dt.h:476
bool TNEANet::IsStrAttrDeletedE ( const int &  EId,
const TStr attr 
) const

Definition at line 266 of file network.cpp.

266  {
267  return EdgeAttrIsStrDeleted(EId, KeyToIndexTypeE.GetI(attr));
268 }
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
bool EdgeAttrIsStrDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Definition: network.cpp:287
TIter GetI(const TKey &Key) const
Definition: hash.h:178
bool TNEANet::IsStrAttrDeletedN ( const int &  NId,
const TStr attr 
) const

Definition at line 119 of file network.cpp.

119  {
120  return NodeAttrIsStrDeleted(NId, KeyToIndexTypeN.GetI(attr));
121 }
bool NodeAttrIsStrDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Definition: network.cpp:142
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
TIter GetI(const TKey &Key) const
Definition: hash.h:178
static PNEANet TNEANet::Load ( TSIn SIn)
inlinestatic

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

Definition at line 1882 of file network.h.

1882 { return PNEANet(new TNEANet(SIn)); }
TNEANet()
Definition: network.h:1842
TPt< TNEANet > PNEANet
Pointer to a directed attribute multigraph (TNEANet)
Definition: network.h:1566
static PNEANet TNEANet::New ( )
inlinestatic

Static cons returns pointer to graph. Ex: PNEANet Graph=TNEANet::New().

Definition at line 1876 of file network.h.

1876 { return PNEANet(new TNEANet()); }
TNEANet()
Definition: network.h:1842
TPt< TNEANet > PNEANet
Pointer to a directed attribute multigraph (TNEANet)
Definition: network.h:1566
static PNEANet TNEANet::New ( const int &  Nodes,
const int &  Edges 
)
inlinestatic

Static constructor that returns a pointer to the graph and reserves enough memory for Nodes nodes and Edges edges.

Call: PNEANet Graph = TNEANet::New(Nodes, Edges).

Definition at line 1880 of file network.h.

1880 { return PNEANet(new TNEANet(Nodes, Edges)); }
TNEANet()
Definition: network.h:1842
TPt< TNEANet > PNEANet
Pointer to a directed attribute multigraph (TNEANet)
Definition: network.h:1566
bool TNEANet::NodeAttrIsDeleted ( const int &  NId,
const TStrIntPrH::TIter NodeHI 
) const

Definition at line 127 of file network.cpp.

127  {
128  bool IntDel = NodeAttrIsIntDeleted(NId, NodeHI);
129  bool StrDel = NodeAttrIsStrDeleted(NId, NodeHI);
130  bool FltDel = NodeAttrIsFltDeleted(NId, NodeHI);
131  return IntDel || StrDel || FltDel;
132 }
bool NodeAttrIsStrDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Definition: network.cpp:142
bool NodeAttrIsFltDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Definition: network.cpp:150
bool NodeAttrIsIntDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Definition: network.cpp:134
bool TNEANet::NodeAttrIsFltDeleted ( const int &  NId,
const TStrIntPrH::TIter NodeHI 
) const

Definition at line 150 of file network.cpp.

150  {
151  if (NodeHI.GetDat().Val1 != FltType) {
152  return false;
153  }
154  return (GetFltAttrDefaultN(NodeHI.GetKey()) == this->VecOfFltVecsN.GetVal(
155  this->KeyToIndexTypeN.GetDat(NodeHI.GetKey()).Val2).GetVal(NodeH.GetKeyId(NId)));
156 }
const TKey & GetKey() const
Definition: hash.h:71
const TDat & GetDat() const
Definition: hash.h:72
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1839
THash< TInt, TNode > NodeH
Definition: network.h:1829
TFlt GetFltAttrDefaultN(const TStr &attribute) const
Get Flt node attribute val. If not a proper attr, return default.
Definition: network.h:1818
bool TNEANet::NodeAttrIsIntDeleted ( const int &  NId,
const TStrIntPrH::TIter NodeHI 
) const

Definition at line 134 of file network.cpp.

134  {
135  if (NodeHI.GetDat().Val1 != IntType) {
136  return false;
137  }
138  return (GetIntAttrDefaultN(NodeHI.GetKey()) == this->VecOfIntVecsN.GetVal(
139  this->KeyToIndexTypeN.GetDat(NodeHI.GetKey()).Val2).GetVal(NodeH.GetKeyId(NId)));
140 }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1837
const TKey & GetKey() const
Definition: hash.h:71
const TDat & GetDat() const
Definition: hash.h:72
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
THash< TInt, TNode > NodeH
Definition: network.h:1829
TInt GetIntAttrDefaultN(const TStr &attribute) const
Get Int node attribute val. If not a proper attr, return default.
Definition: network.h:1814
bool TNEANet::NodeAttrIsStrDeleted ( const int &  NId,
const TStrIntPrH::TIter NodeHI 
) const

Definition at line 142 of file network.cpp.

142  {
143  if (NodeHI.GetDat().Val1 != StrType) {
144  return false;
145  }
146  return (GetStrAttrDefaultN(NodeHI.GetKey()) == this->VecOfStrVecsN.GetVal(
147  this->KeyToIndexTypeN.GetDat(NodeHI.GetKey()).Val2).GetVal(NodeH.GetKeyId(NId)));
148 }
const TKey & GetKey() const
Definition: hash.h:71
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
const TDat & GetDat() const
Definition: hash.h:72
TStr GetStrAttrDefaultN(const TStr &attribute) const
Get Str node attribute val. If not a proper attr, return default.
Definition: network.h:1816
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
THash< TInt, TNode > NodeH
Definition: network.h:1829
TNEANet& TNEANet::operator= ( const TNEANet Graph)
inline

Definition at line 1885 of file network.h.

1885  { if (this!=&Graph) {
1886  MxNId=Graph.MxNId; MxEId=Graph.MxEId; NodeH=Graph.NodeH; EdgeH=Graph.EdgeH; }
1887  return *this; }
TInt MxNId
Definition: network.h:1828
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
TInt MxEId
Definition: network.h:1828
THash< TInt, TNode > NodeH
Definition: network.h:1829
void TNEANet::Reserve ( const int &  Nodes,
const int &  Edges 
)
inline

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

Definition at line 2106 of file network.h.

2106  {
2107  if (Nodes>0) { NodeH.Gen(Nodes/2); } if (Edges>0) { EdgeH.Gen(Edges/2); } }
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
void Gen(const int &ExpectVals)
Definition: hash.h:180
THash< TInt, TNode > NodeH
Definition: network.h:1829
void TNEANet::Save ( TSOut SOut) const
inline

Saves the graph to a (binary) stream SOut.

Definition at line 1866 of file network.h.

1866  {
1867  MxNId.Save(SOut); MxEId.Save(SOut); NodeH.Save(SOut); EdgeH.Save(SOut);
1869  IntDefaultsN.Save(SOut); IntDefaultsE.Save(SOut);
1870  StrDefaultsN.Save(SOut); StrDefaultsE.Save(SOut);
1871  FltDefaultsN.Save(SOut); FltDefaultsE.Save(SOut);
1872  VecOfIntVecsN.Save(SOut); VecOfIntVecsE.Save(SOut);
1873  VecOfStrVecsN.Save(SOut); VecOfStrVecsE.Save(SOut);
1874  VecOfFltVecsN.Save(SOut); VecOfFltVecsE.Save(SOut); }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1837
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:1836
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
THash< TStr, TInt > IntDefaultsE
Definition: network.h:1834
void Save(TSOut &SOut) const
Definition: dt.h:1058
void Save(TSOut &SOut) const
Definition: hash.h:141
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:1836
TInt MxNId
Definition: network.h:1828
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1837
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
THash< TInt, TEdge > EdgeH
Definition: network.h:1830
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1839
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
THash< TStr, TStr > StrDefaultsN
Definition: network.h:1835
TInt MxEId
Definition: network.h:1828
THash< TStr, TStr > StrDefaultsE
Definition: network.h:1835
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1839
THash< TStr, TInt > IntDefaultsN
Definition: network.h:1834
THash< TInt, TNode > NodeH
Definition: network.h:1829
void TNEANet::StrAttrNameEI ( const TInt EId,
TStrV Names 
) const
inline

Returns a vector of str attr names for node NId.

Definition at line 1992 of file network.h.

1992  {
1993  StrAttrNameEI(EId, KeyToIndexTypeE.BegI(), Names);}
TIter BegI() const
Definition: hash.h:171
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
void StrAttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of str attr names for node NId.
Definition: network.h:1992
void TNEANet::StrAttrNameEI ( const TInt EId,
TStrIntPrH::TIter  EdgeHI,
TStrV Names 
) const

Definition at line 213 of file network.cpp.

213  {
214  Names = TVec<TStr>();
215  while (!EdgeHI.IsEnd()) {
216  if (EdgeHI.GetDat().Val1 == StrType && !EdgeAttrIsStrDeleted(EId, EdgeHI)) {
217  Names.Add(EdgeHI.GetKey());
218  }
219  EdgeHI++;
220  }
221 }
const TKey & GetKey() const
Definition: hash.h:71
const TDat & GetDat() const
Definition: hash.h:72
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
Definition: hash.h:69
bool EdgeAttrIsStrDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Definition: network.cpp:287
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
void TNEANet::StrAttrNameNI ( const TInt NId,
TStrV Names 
) const
inline

Returns a vector of str attr names for node NId.

Definition at line 1959 of file network.h.

1959  {
1960  StrAttrNameNI(NId, KeyToIndexTypeN.BegI(), Names);}
void StrAttrNameNI(const TInt &NId, TStrV &Names) const
Returns a vector of str attr names for node NId.
Definition: network.h:1959
TIter BegI() const
Definition: hash.h:171
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
void TNEANet::StrAttrNameNI ( const TInt NId,
TStrIntPrH::TIter  NodeHI,
TStrV Names 
) const

Definition at line 66 of file network.cpp.

66  {
67  Names = TVec<TStr>();
68  while (!NodeHI.IsEnd()) {
69  if (NodeHI.GetDat().Val1 == StrType && !NodeAttrIsStrDeleted(NId, NodeHI)) {
70  Names.Add(NodeHI.GetKey());
71  }
72  NodeHI++;
73  }
74 }
bool NodeAttrIsStrDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Definition: network.cpp:142
const TKey & GetKey() const
Definition: hash.h:71
const TDat & GetDat() const
Definition: hash.h:72
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
Definition: hash.h:69
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
void TNEANet::StrAttrValueEI ( const TInt EId,
TStrV Values 
) const
inline

Returns a vector of attr values for node NId.

Definition at line 1996 of file network.h.

1996  {
1997  StrAttrValueEI(EId, KeyToIndexTypeE.BegI(), Values);}
TIter BegI() const
Definition: hash.h:171
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1832
void StrAttrValueEI(const TInt &EId, TStrV &Values) const
Returns a vector of attr values for node NId.
Definition: network.h:1996
void TNEANet::StrAttrValueEI ( const TInt EId,
TStrIntPrH::TIter  EdgeHI,
TStrV Values 
) const

Definition at line 223 of file network.cpp.

223  {
224  Values = TVec<TStr>();
225  while (!EdgeHI.IsEnd()) {
226  if (EdgeHI.GetDat().Val1 == StrType && !EdgeAttrIsStrDeleted(EId, EdgeHI)) {
227  TStr val = this->VecOfStrVecsE.GetVal(EdgeHI.GetDat().Val2).GetVal(EId);
228  Values.Add(val);
229  }
230  EdgeHI++;
231  }
232 }
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1838
const TDat & GetDat() const
Definition: hash.h:72
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
Definition: hash.h:69
bool EdgeAttrIsStrDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Definition: network.cpp:287
Definition: dt.h:412
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
void TNEANet::StrAttrValueNI ( const TInt NId,
TStrV Values 
) const
inline

Returns a vector of attr values for node NId.

Definition at line 1963 of file network.h.

1963  {
1964  StrAttrValueNI(NId, KeyToIndexTypeN.BegI(), Values);}
TIter BegI() const
Definition: hash.h:171
void StrAttrValueNI(const TInt &NId, TStrV &Values) const
Returns a vector of attr values for node NId.
Definition: network.h:1963
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1832
void TNEANet::StrAttrValueNI ( const TInt NId,
TStrIntPrH::TIter  NodeHI,
TStrV Values 
) const

Definition at line 76 of file network.cpp.

76  {
77  Values = TVec<TStr>();
78  while (!NodeHI.IsEnd()) {
79  if (NodeHI.GetDat().Val1 == StrType && !NodeAttrIsStrDeleted(NId, NodeHI)) {
80  TStr val = this->VecOfStrVecsN.GetVal(NodeHI.GetDat().Val2).GetVal(NodeH.GetKeyId(NId));
81  Values.Add(val);
82  }
83  NodeHI++;
84  }
85 }
bool NodeAttrIsStrDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Definition: network.cpp:142
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1838
const TDat & GetDat() const
Definition: hash.h:72
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
Definition: hash.h:69
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
Definition: dt.h:412
THash< TInt, TNode > NodeH
Definition: network.h:1829
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559

Friends And Related Function Documentation

friend class TPt< TNEANet >
friend

Definition at line 2294 of file network.h.

Member Data Documentation

TCRef TNEANet::CRef
private

Definition at line 1827 of file network.h.

THash<TInt, TEdge> TNEANet::EdgeH
private

Definition at line 1830 of file network.h.

THash<TStr, TFlt> TNEANet::FltDefaultsE
private

Definition at line 1836 of file network.h.

THash<TStr, TFlt> TNEANet::FltDefaultsN
private

Definition at line 1836 of file network.h.

THash<TStr, TInt> TNEANet::IntDefaultsE
private

Definition at line 1834 of file network.h.

THash<TStr, TInt> TNEANet::IntDefaultsN
private

Definition at line 1834 of file network.h.

TStrIntPrH TNEANet::KeyToIndexTypeE
private

Definition at line 1832 of file network.h.

TStrIntPrH TNEANet::KeyToIndexTypeN
private

KeyToIndexType[N|E]: Key->(Type,Index).

Definition at line 1832 of file network.h.

TInt TNEANet::MxEId
private

Definition at line 1828 of file network.h.

TInt TNEANet::MxNId
private

Definition at line 1828 of file network.h.

THash<TInt, TNode> TNEANet::NodeH
private

Definition at line 1829 of file network.h.

THash<TStr, TStr> TNEANet::StrDefaultsE
private

Definition at line 1835 of file network.h.

THash<TStr, TStr> TNEANet::StrDefaultsN
private

Definition at line 1835 of file network.h.

TVec<TFltV> TNEANet::VecOfFltVecsE
private

Definition at line 1839 of file network.h.

TVec<TFltV> TNEANet::VecOfFltVecsN
private

Definition at line 1839 of file network.h.

TVec<TIntV> TNEANet::VecOfIntVecsE
private

Definition at line 1837 of file network.h.

TVec<TIntV> TNEANet::VecOfIntVecsN
private

Definition at line 1837 of file network.h.

TVec<TStrV> TNEANet::VecOfStrVecsE
private

Definition at line 1838 of file network.h.

TVec<TStrV> TNEANet::VecOfStrVecsN
private

Definition at line 1838 of file network.h.


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