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
TNodeEdgeNet< TNodeData, TEdgeData > Class Template Reference

List of all members.

Classes

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

Public Types

typedef TNodeData TNodeDat
typedef TEdgeData TEdgeDat
typedef TNodeEdgeNet
< TNodeData, TEdgeData > 
TNet
typedef TPt< TNetPNet

Public Member Functions

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

Static Public Member Functions

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

Protected Attributes

TCRef CRef
TInt MxNId
TInt MxEId
THash< TInt, TNodeNodeH
THash< TInt, TEdgeEdgeH

Friends

class TPt< TNodeEdgeNet< TNodeData, TEdgeData > >

Detailed Description

template<class TNodeData, class TEdgeData>
class TNodeEdgeNet< TNodeData, TEdgeData >

Node Edge Network (directed multigraph, TNEGraph with data on nodes and edges).


Member Typedef Documentation

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

Reimplemented in TTimeNENet.

template<class TNodeData, class TEdgeData>
typedef TEdgeData TNodeEdgeNet< TNodeData, TEdgeData >::TEdgeDat
template<class TNodeData, class TEdgeData>
typedef TNodeEdgeNet<TNodeData, TEdgeData> TNodeEdgeNet< TNodeData, TEdgeData >::TNet

Reimplemented in TTimeNENet.

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

Constructor & Destructor Documentation

template<class TNodeData, class TEdgeData>
TNodeEdgeNet< TNodeData, TEdgeData >::TNodeEdgeNet ( ) [inline]
template<class TNodeData, class TEdgeData>
TNodeEdgeNet< TNodeData, TEdgeData >::TNodeEdgeNet ( 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>
TNodeEdgeNet< TNodeData, TEdgeData >::TNodeEdgeNet ( const TNodeEdgeNet< TNodeData, TEdgeData > &  Net) [inline]
template<class TNodeData, class TEdgeData>
TNodeEdgeNet< TNodeData, TEdgeData >::TNodeEdgeNet ( TSIn SIn) [inline]

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

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

Member Function Documentation

template<class TNodeData , class TEdgeData >
int TNodeEdgeNet< TNodeData, TEdgeData >::AddEdge ( const int &  SrcNId,
const int &  DstNId,
int  EId = -1 
)

Adds an edge between node IDs SrcNId and DstNId to the graph.

Returns the ID of the edge being added. If EId is -1, edge ID is automatically assigned. Aborts, if an edge with ID EId already exists. Aborts, if SrcNId or DstNId are not nodes in the graph.

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

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

Returns the ID of the edge being added. If EId is -1, edge ID is automatically assigned. Aborts, if an edge with ID EId already exists. Aborts, if SrcNId or DstNId are not nodes in the graph.

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

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

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

Adds a node of ID NId to the network.

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

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

Adds node data to node with ID NId.

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

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

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

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

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

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

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

template<class TNodeData, class TEdgeData>
void TNodeEdgeNet< TNodeData, TEdgeData >::Clr ( ) [inline]

Deletes all nodes and edges from the network.

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

Defragments the network.

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

template<class TNodeData , class TEdgeData >
void TNodeEdgeNet< TNodeData, TEdgeData >::DelEdge ( const int &  EId)

Deletes an edge with ID EId from the network.

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

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

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

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

Deletes node of ID NId from the network.

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

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

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

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

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

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

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

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

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

template<class TNodeData, class TEdgeData>
TEdgeData& TNodeEdgeNet< TNodeData, TEdgeData >::GetEDat ( const int &  EId) [inline]

Returns edge data for the edge with ID EId.

template<class TNodeData, class TEdgeData>
const TEdgeData& TNodeEdgeNet< TNodeData, TEdgeData >::GetEDat ( const int &  EId) const [inline]

Returns edge data for the edge with ID EId.

template<class TNodeData, class TEdgeData>
int TNodeEdgeNet< TNodeData, TEdgeData >::GetEdges ( ) const [inline]

Returns the number of edges in the network.

template<class TNodeData, class TEdgeData>
TEdgeI TNodeEdgeNet< TNodeData, TEdgeData >::GetEI ( const int &  EId) const [inline]
template<class TNodeData, class TEdgeData>
TEdgeI TNodeEdgeNet< TNodeData, TEdgeData >::GetEI ( const int &  SrcNId,
const int &  DstNId 
) const [inline]
template<class TNodeData, class TEdgeData>
int TNodeEdgeNet< TNodeData, TEdgeData >::GetEId ( const int &  SrcNId,
const int &  DstNId 
) const [inline]
template<class TNodeData , class TEdgeData >
void TNodeEdgeNet< TNodeData, TEdgeData >::GetEIdV ( TIntV EIdV) const

Returns a vector of all edge IDs in the network.

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

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

template<class TNodeData, class TEdgeData>
TNodeData& TNodeEdgeNet< 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& TNodeEdgeNet< 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 TNodeEdgeNet< 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 >
void TNodeEdgeNet< TNodeData, TEdgeData >::GetNIdV ( TIntV NIdV) const

Returns a vector of all node IDs in the network.

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

Returns the number of nodes in the network.

template<class TNodeData, class TEdgeData>
TEdgeI TNodeEdgeNet< TNodeData, TEdgeData >::GetRndEI ( TRnd Rnd = TInt::Rnd) [inline]

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

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

Returns an ID of a random edge in the network.

template<class TNodeData, class TEdgeData>
TNodeI TNodeEdgeNet< 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 TNodeEdgeNet< TNodeData, TEdgeData >::GetRndNId ( TRnd Rnd = TInt::Rnd) [inline]

Returns an ID of a random node in the network.

template<class TNodeData , class TEdgeData >
int TNodeEdgeNet< TNodeData, TEdgeData >::GetUniqEdges ( const bool &  IsDir = true) const

Returns the number of edges in the network with a unique pair of nodes.

template<class TNodeData , class TEdgeData >
bool TNodeEdgeNet< 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 TNodeEdgeNet< TNodeData, TEdgeData >::IsEdge ( const int &  EId) const [inline]

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

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

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

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

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

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

Tests whether ID NId is a node.

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

Checks the network data structure for internal consistency.

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

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

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

Reimplemented in TTimeNENet.

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

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

Reimplemented in TTimeNENet.

template<class TNodeData, class TEdgeData>
TNodeEdgeNet& TNodeEdgeNet< TNodeData, TEdgeData >::operator= ( const TNodeEdgeNet< TNodeData, TEdgeData > &  Net) [inline]
template<class TNodeData, class TEdgeData>
void TNodeEdgeNet< 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 TNodeEdgeNet< TNodeData, TEdgeData >::Save ( TSOut SOut) const [inline, virtual]

Saves the network to a (binary) stream SOut.

Reimplemented in TTimeNENet.

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

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

template<class TNodeData , class TEdgeData>
void TNodeEdgeNet< TNodeData, TEdgeData >::SetEDat ( const int &  EId,
const TEdgeData &  EdgeDat 
)

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

template<class TNodeData, class TEdgeData >
void TNodeEdgeNet< 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 TNodeEdgeNet< TNodeData, TEdgeData >::SortEIdByDat ( const bool &  Asc = true) [inline]

Sorts edges by edge data.

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

Sorts edges by edge IDs.

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

Sorts nodes by node data.

template<class TNodeData, class TEdgeData>
void TNodeEdgeNet< 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< TNodeEdgeNet< TNodeData, TEdgeData > > [friend]

Member Data Documentation

template<class TNodeData, class TEdgeData>
TCRef TNodeEdgeNet< TNodeData, TEdgeData >::CRef [protected]
template<class TNodeData, class TEdgeData>
THash<TInt, TEdge> TNodeEdgeNet< TNodeData, TEdgeData >::EdgeH [protected]
template<class TNodeData, class TEdgeData>
TInt TNodeEdgeNet< TNodeData, TEdgeData >::MxEId [protected]
template<class TNodeData, class TEdgeData>
TInt TNodeEdgeNet< TNodeData, TEdgeData >::MxNId [protected]
template<class TNodeData, class TEdgeData>
THash<TInt, TNode> TNodeEdgeNet< TNodeData, TEdgeData >::NodeH [protected]

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