SNAP Library, User Reference  2012-10-02 12:56:23
SNAP, a general purpose network analysis and graph mining library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TNodeEDatNet< TNodeData, TEdgeData > Class Template Reference

List of all members.

Classes

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

Public Types

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

Public Member Functions

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

Static Public Member Functions

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

Protected Member Functions

TNodeGetNode (const int &NId)

Static Protected Member Functions

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

Protected Attributes

TCRef CRef
TInt MxNId
THash< TInt, TNodeNodeH

Friends

class TPt< TNodeEDatNet< TNodeData, TEdgeData > >

Detailed Description

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

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


Member Typedef Documentation

template<class TNodeData , class TEdgeData >
typedef TPt<TNet> TNodeEDatNet< TNodeData, TEdgeData >::PNet
template<class TNodeData , class TEdgeData >
typedef TEdgeData TNodeEDatNet< TNodeData, TEdgeData >::TEdgeDat
template<class TNodeData , class TEdgeData >
typedef TNodeEDatNet<TNodeData, TEdgeData> TNodeEDatNet< TNodeData, TEdgeData >::TNet
template<class TNodeData , class TEdgeData >
typedef TVec<TPair<TInt, TEdgeData> > TNodeEDatNet< TNodeData, TEdgeData >::TNIdDatPrV
template<class TNodeData , class TEdgeData >
typedef TNodeData TNodeEDatNet< TNodeData, TEdgeData >::TNodeDat

Constructor & Destructor Documentation

template<class TNodeData , class TEdgeData >
TNodeEDatNet< TNodeData, TEdgeData >::TNodeEDatNet ( ) [inline]
template<class TNodeData , class TEdgeData >
TNodeEDatNet< TNodeData, TEdgeData >::TNodeEDatNet ( const int &  Nodes,
const int &  Edges 
) [inline, explicit]

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

template<class TNodeData , class TEdgeData >
TNodeEDatNet< TNodeData, TEdgeData >::TNodeEDatNet ( const TNodeEDatNet< TNodeData, TEdgeData > &  NodeNet) [inline]
template<class TNodeData , class TEdgeData >
TNodeEDatNet< TNodeData, TEdgeData >::TNodeEDatNet ( TSIn SIn) [inline]

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

template<class TNodeData , class TEdgeData >
virtual TNodeEDatNet< TNodeData, TEdgeData >::~TNodeEDatNet ( ) [inline, virtual]

Member Function Documentation

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

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

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

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

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

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

template<class TNodeData , class TEdgeData >
int TNodeEDatNet< TNodeData, TEdgeData >::AddEdge ( const TEdgeI EdgeI) [inline]

Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() and its edge data to the network.

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

Adds a node of ID NId to the network.

Returns the ID of the node being added. If NId is -1, node ID is automatically assigned. Aborts, if a node with ID NId already exists.

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

Adds a node of ID NId and node data NodeDat to the network.

Returns the ID of the node being added. If NId is -1, node ID is automatically assigned. Aborts, if a node with ID NId already exists.

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

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

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

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

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

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

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

Deletes all nodes and edges from the network.

template<class TNodeData , class TEdgeData >
void TNodeEDatNet< TNodeData, TEdgeData >::Defrag ( const bool &  OnlyNodeLinks = false)

Defragments the network.

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

template<class TNodeData , class TEdgeData >
void TNodeEDatNet< TNodeData, TEdgeData >::DelEdge ( const int &  SrcNId,
const int &  DstNId,
const bool &  IsDir = true 
)

Deletes an edge from node IDs SrcNId to DstNId from the network.

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

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

Deletes node of ID NId from the network.

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

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

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

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

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

template<class TNodeData , class TEdgeData >
TEdgeI TNodeEDatNet< TNodeData, TEdgeData >::EndEI ( ) const [inline]

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

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

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

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

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

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

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

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

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

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

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

Returns the number of edges in the network.

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

Not supported/implemented!

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

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

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

Returns the maximum id of a any node in the network.

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

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

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

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

template<class TNodeData , class TEdgeData >
TNodeI TNodeEDatNet< TNodeData, TEdgeData >::GetNI ( const int &  NId) const [inline]

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

template<class TNodeData , class TEdgeData >
int TNodeEDatNet< TNodeData, TEdgeData >::GetNIdPos ( const TVec< TPair< TInt, TEdgeData > > &  NIdV,
const int &  NId 
) [static, protected]
template<class TNodeData , class TEdgeData >
void TNodeEDatNet< TNodeData, TEdgeData >::GetNIdV ( TIntV NIdV) const

Gets a vector IDs of all nodes in the network.

template<class TNodeData , class TEdgeData >
TNode& TNodeEDatNet< TNodeData, TEdgeData >::GetNode ( const int &  NId) [inline, protected]
template<class TNodeData , class TEdgeData >
const TNode& TNodeEDatNet< TNodeData, TEdgeData >::GetNode ( const int &  NId) const [inline]

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

template<class TNodeData , class TEdgeData >
int TNodeEDatNet< TNodeData, TEdgeData >::GetNodes ( ) const [inline]

Returns the number of nodes in the network.

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

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

template<class TNodeData , class TEdgeData >
int TNodeEDatNet< TNodeData, TEdgeData >::GetRndNId ( TRnd Rnd = TInt::Rnd) [inline]

Returns an ID of a random node in the network.

template<class TNodeData , class TEdgeData >
bool TNodeEDatNet< TNodeData, TEdgeData >::HasFlag ( const TGraphFlag Flag) const

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

template<class TNodeData , class TEdgeData >
bool TNodeEDatNet< TNodeData, TEdgeData >::IsEdge ( const int &  SrcNId,
const int &  DstNId,
const bool &  IsDir = true 
) const

Tests whether an edge from node IDs SrcNId to DstNId exists in the network.

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

Tests whether ID NId is a node.

template<class TNodeData , class TEdgeData >
bool TNodeEDatNet< TNodeData, TEdgeData >::IsOk ( const bool &  ThrowExcept = true) const

Checks the network data structure for internal consistency.

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

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

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

template<class TNodeData , class TEdgeData >
static PNet TNodeEDatNet< TNodeData, TEdgeData >::New ( ) [inline, static]

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

template<class TNodeData , class TEdgeData >
TNodeEDatNet& TNodeEDatNet< TNodeData, TEdgeData >::operator= ( const TNodeEDatNet< TNodeData, TEdgeData > &  NodeNet) [inline]
template<class TNodeData , class TEdgeData >
void TNodeEDatNet< TNodeData, TEdgeData >::Reserve ( const int &  Nodes,
const int &  Edges 
) [inline]

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

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

Saves the network to a (binary) stream SOut.

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

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

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

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

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

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

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

Sorts nodes by node data.

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

Sorts nodes by node IDs.


Friends And Related Function Documentation

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

Member Data Documentation

template<class TNodeData , class TEdgeData >
TCRef TNodeEDatNet< TNodeData, TEdgeData >::CRef [protected]
template<class TNodeData , class TEdgeData >
TInt TNodeEDatNet< TNodeData, TEdgeData >::MxNId [protected]
template<class TNodeData , class TEdgeData >
THash<TInt, TNode> TNodeEDatNet< TNodeData, TEdgeData >::NodeH [protected]

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