SNAP Library 3.0, User Reference
2016-07-20 17:56:49
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
Node Edge Network (directed graph, TNGraph with data on nodes and edges). More...
#include <network.h>
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< TNet > | PNet |
typedef TVec< TPair< TInt, TEdgeData > > | TNIdDatPrV |
Public Member Functions | |
TNodeEDatNet () | |
TNodeEDatNet (const int &Nodes, const int &Edges) | |
Constructor that reserves enough memory for a network of Nodes nodes and Edges edges. More... | |
TNodeEDatNet (const TNodeEDatNet &NodeNet) | |
TNodeEDatNet (TSIn &SIn) | |
Constructor that loads the network from a (binary) stream SIn. More... | |
virtual | ~TNodeEDatNet () |
virtual void | Save (TSOut &SOut) const |
Saves the network to a (binary) stream SOut. More... | |
bool | HasFlag (const TGraphFlag &Flag) const |
Allows for run-time checking the type of the network (see the TGraphFlag for flags). More... | |
TNodeEDatNet & | operator= (const TNodeEDatNet &NodeNet) |
int | GetNodes () const |
Returns the number of nodes in the network. More... | |
int | AddNode (int NId=-1) |
Adds a node of ID NId to the network. More... | |
int | AddNode (int NId, const TNodeData &NodeDat) |
Adds a node of ID NId and node data NodeDat to the network. More... | |
int | AddNode (const TNodeI &NodeI) |
Adds a node NodeI and its node data to the network. More... | |
void | DelNode (const int &NId) |
Deletes node of ID NId from the network. More... | |
void | DelNode (const TNode &NodeI) |
Deletes node of ID NodeI.GetId() from the network. More... | |
bool | IsNode (const int &NId) const |
Tests whether ID NId is a node. More... | |
TNodeI | BegNI () const |
Returns an iterator referring to the first node in the network. More... | |
TNodeI | EndNI () const |
Returns an iterator referring to the past-the-end node in the network. More... | |
TNodeI | GetNI (const int &NId) const |
Returns an iterator referring to the node of ID NId in the network. More... | |
const TNode & | GetNode (const int &NId) const |
Returns node element for the node of ID NId in the network. More... | |
void | SetNDat (const int &NId, const TNodeData &NodeDat) |
Sets node data for the node of ID NId in the network. More... | |
TNodeData & | GetNDat (const int &NId) |
Returns node data for the node of ID NId in the network. More... | |
const TNodeData & | GetNDat (const int &NId) const |
Returns node data for the node of ID NId in the network. More... | |
int | GetMxNId () const |
Returns an ID that is larger than any node ID in the network. More... | |
int | GetEdges () const |
Returns the number of edges in the network. More... | |
int | AddEdge (const int &SrcNId, const int &DstNId) |
Adds an edge from node IDs SrcNId to node DstNId to the network. More... | |
int | AddEdge (const int &SrcNId, const int &DstNId, const TEdgeData &EdgeDat) |
Adds an edge and edge data from node IDs SrcNId to node DstNId. More... | |
int | AddEdge (const TEdgeI &EdgeI) |
Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() and its edge data to the network. More... | |
void | DelEdge (const int &SrcNId, const int &DstNId, const bool &IsDir=true) |
Deletes an edge from node IDs SrcNId to DstNId from the network. More... | |
bool | IsEdge (const int &SrcNId, const int &DstNId, const bool &IsDir=true) const |
Tests whether an edge from node IDs SrcNId to DstNId exists in the network. More... | |
TEdgeI | BegEI () const |
Returns an iterator referring to the first edge in the network. More... | |
TEdgeI | EndEI () const |
Returns an iterator referring to the past-the-end edge in the network. More... | |
TEdgeI | GetEI (const int &EId) const |
Not supported/implemented! More... | |
TEdgeI | GetEI (const int &SrcNId, const int &DstNId) const |
Returns an iterator referring to edge (SrcNId, DstNId) in the network. More... | |
void | SetEDat (const int &SrcNId, const int &DstNId, const TEdgeData &EdgeDat) |
Sets edge data for the edge between nodes SrcNId and DstNId in the network. More... | |
bool | GetEDat (const int &SrcNId, const int &DstNId, TEdgeData &EdgeDat) const |
Returns edge data in Data for the edge from node IDs SrcNId to DstNId. More... | |
TEdgeData & | GetEDat (const int &SrcNId, const int &DstNId) |
Returns edge data for the edge from node IDs SrcNId to DstNId. More... | |
const TEdgeData & | GetEDat (const int &SrcNId, const int &DstNId) const |
Returns edge data for the edge from node IDs SrcNId to DstNId. More... | |
void | SetAllEDat (const TEdgeData &EdgeDat) |
Sets edge data for all the edges in the network to EDat. More... | |
int | GetRndNId (TRnd &Rnd=TInt::Rnd) |
Returns an ID of a random node in the network. More... | |
TNodeI | GetRndNI (TRnd &Rnd=TInt::Rnd) |
Returns an interator referring to a random node in the network. More... | |
void | GetNIdV (TIntV &NIdV) const |
Gets a vector IDs of all nodes in the network. More... | |
bool | Empty () const |
Tests whether the network is empty (has zero nodes). More... | |
void | Clr (const bool &DoDel=true, const bool &ResetDat=true) |
Deletes all nodes and edges from the network. More... | |
void | Reserve (const int &Nodes, const int &Edges) |
Reserves memory for a network of Nodes nodes and Edges edges. More... | |
void | SortNIdById (const bool &Asc=true) |
Sorts nodes by node IDs. More... | |
void | SortNIdByDat (const bool &Asc=true) |
Sorts nodes by node data. More... | |
void | Defrag (const bool &OnlyNodeLinks=false) |
Defragments the network. More... | |
bool | IsOk (const bool &ThrowExcept=true) const |
Checks the network data structure for internal consistency. More... | |
Static Public Member Functions | |
static PNet | New () |
Static constructor that returns a pointer to the network. Call: TPt <TNodeEDatNet<TNodeData, TEdgeData> > Net = TNodeEDatNet<TNodeData, TEdgeData>::New(). More... | |
static PNet | Load (TSIn &SIn) |
Static constructor that loads the network from a stream SIn and returns a pointer to it. More... | |
Protected Member Functions | |
TNode & | GetNode (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, TNode > | NodeH |
Friends | |
class | TPt< TNodeEDatNet< TNodeData, TEdgeData > > |
Node Edge Network (directed graph, TNGraph with data on nodes and edges).
typedef TPt<TNet> TNodeEDatNet< TNodeData, TEdgeData >::PNet |
typedef TEdgeData TNodeEDatNet< TNodeData, TEdgeData >::TEdgeDat |
typedef TNodeEDatNet<TNodeData, TEdgeData> TNodeEDatNet< TNodeData, TEdgeData >::TNet |
typedef TVec<TPair<TInt, TEdgeData> > TNodeEDatNet< TNodeData, TEdgeData >::TNIdDatPrV |
typedef TNodeData TNodeEDatNet< TNodeData, TEdgeData >::TNodeDat |
|
inline |
|
inlineexplicit |
Constructor that reserves enough memory for a network of Nodes nodes and Edges edges.
Definition at line 588 of file network.h.
|
inline |
|
inline |
|
inlinevirtual |
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.
Definition at line 813 of file network.h.
int TNodeEDatNet< TNodeData, TEdgeData >::AddEdge | ( | const int & | SrcNId, |
const int & | DstNId, | ||
const TEdgeData & | EdgeDat | ||
) |
Adds an edge and edge data from node IDs SrcNId to node DstNId.
If the edge already exists, set edges data and returns -2. If the edge does not exist and was successfully added returns -1. Normally the function should return an ID of the edge added but since edges in TNodeEDatNet have no IDs it returns -1. Function aborts if SrcNId or DstNId are not nodes in the network.
Definition at line 818 of file network.h.
|
inline |
Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() and its edge data to the network.
Definition at line 665 of file network.h.
int TNodeEDatNet< TNodeData, TEdgeData >::AddNode | ( | int | NId = -1 | ) |
Adds a node of ID NId to the network.
Returns the ID of the node being added. If NId is -1, node ID is automatically assigned. Aborts, if a node with ID NId already exists.
Definition at line 755 of file network.h.
int TNodeEDatNet< TNodeData, TEdgeData >::AddNode | ( | int | NId, |
const TNodeData & | NodeDat | ||
) |
Adds a node of ID NId and node data NodeDat to the network.
Returns the ID of the node being added. If NId is -1, node ID is automatically assigned. Aborts, if a node with ID NId already exists.
Definition at line 767 of file network.h.
|
inline |
Adds a node NodeI and its node data to the network.
Definition at line 619 of file network.h.
|
inline |
Returns an iterator referring to the first edge in the network.
Definition at line 675 of file network.h.
|
inline |
|
inline |
Deletes all nodes and edges from the network.
Definition at line 705 of file network.h.
void TNodeEDatNet< TNodeData, TEdgeData >::Defrag | ( | const bool & | OnlyNodeLinks = false | ) |
void TNodeEDatNet< TNodeData, TEdgeData >::DelEdge | ( | const int & | SrcNId, |
const int & | DstNId, | ||
const bool & | IsDir = true |
||
) |
Deletes an edge from node IDs SrcNId to DstNId from the network.
If the edge (SrcNId, DstNId) does not exist in the network function still completes. But the function aborts if SrcNId or DstNId are not nodes in the network.
Definition at line 831 of file network.h.
void TNodeEDatNet< TNodeData, TEdgeData >::DelNode | ( | const int & | NId | ) |
Deletes node of ID NId from the network.
If the node of ID NId does not exist the function aborts.
Definition at line 785 of file network.h.
|
inline |
Deletes node of ID NodeI.GetId() from the network.
Definition at line 625 of file network.h.
|
inline |
Tests whether the network is empty (has zero nodes).
Definition at line 703 of file network.h.
|
inline |
Returns an iterator referring to the past-the-end edge in the network.
Definition at line 677 of file network.h.
|
inline |
bool TNodeEDatNet< TNodeData, TEdgeData >::GetEDat | ( | const int & | SrcNId, |
const int & | DstNId, | ||
TEdgeData & | EdgeDat | ||
) | const |
Returns edge data in Data for the edge from node IDs SrcNId to DstNId.
Returns true, if the edge was found. Otherwise, returns false.
Definition at line 860 of file network.h.
TEdgeData & TNodeEDatNet< TNodeData, TEdgeData >::GetEDat | ( | const int & | SrcNId, |
const int & | DstNId | ||
) |
Returns edge data for the edge from node IDs SrcNId to DstNId.
Definition at line 868 of file network.h.
const TEdgeData & TNodeEDatNet< TNodeData, TEdgeData >::GetEDat | ( | const int & | SrcNId, |
const int & | DstNId | ||
) | const |
Returns edge data for the edge from node IDs SrcNId to DstNId.
Definition at line 875 of file network.h.
int TNodeEDatNet< TNodeData, TEdgeData >::GetEdges | ( | ) | const |
TEdgeI TNodeEDatNet< TNodeData, TEdgeData >::GetEI | ( | const int & | EId | ) | const |
Not supported/implemented!
TNodeEDatNet< TNodeData, TEdgeData >::TEdgeI TNodeEDatNet< TNodeData, TEdgeData >::GetEI | ( | const int & | SrcNId, |
const int & | DstNId | ||
) | const |
Returns an iterator referring to edge (SrcNId, DstNId) in the network.
Definition at line 889 of file network.h.
|
inline |
|
inline |
|
inline |
|
inline |
|
staticprotected |
void TNodeEDatNet< TNodeData, TEdgeData >::GetNIdV | ( | TIntV & | NIdV | ) | const |
Gets a vector IDs of all nodes in the network.
Definition at line 905 of file network.h.
|
inlineprotected |
|
inline |
|
inline |
|
inline |
Returns an interator referring to a random node in the network.
Definition at line 698 of file network.h.
|
inline |
Returns an ID of a random node in the network.
Definition at line 696 of file network.h.
bool TNodeEDatNet< TNodeData, TEdgeData >::HasFlag | ( | const TGraphFlag & | Flag | ) | const |
Allows for run-time checking the type of the network (see the TGraphFlag for flags).
Definition at line 737 of file network.h.
bool TNodeEDatNet< TNodeData, TEdgeData >::IsEdge | ( | const int & | SrcNId, |
const int & | DstNId, | ||
const bool & | IsDir = true |
||
) | const |
Tests whether an edge from node IDs SrcNId to DstNId exists in the network.
Definition at line 846 of file network.h.
|
inline |
bool TNodeEDatNet< TNodeData, TEdgeData >::IsOk | ( | const bool & | ThrowExcept = true | ) | const |
Checks the network data structure for internal consistency.
For each node in the network check that its neighbors are also nodes in the network.
Definition at line 923 of file network.h.
|
inlinestatic |
|
inlinestatic |
Static constructor that returns a pointer to the network. Call: TPt <TNodeEDatNet<TNodeData, TEdgeData> > Net = TNodeEDatNet<TNodeData, TEdgeData>::New().
Definition at line 596 of file network.h.
|
inline |
|
inline |
|
inlinevirtual |
void TNodeEDatNet< TNodeData, TEdgeData >::SetAllEDat | ( | const TEdgeData & | EdgeDat | ) |
Sets edge data for all the edges in the network to EDat.
Definition at line 882 of file network.h.
void TNodeEDatNet< TNodeData, TEdgeData >::SetEDat | ( | const int & | SrcNId, |
const int & | DstNId, | ||
const TEdgeData & | EdgeDat | ||
) |
Sets edge data for the edge between nodes SrcNId and DstNId in the network.
Definition at line 853 of file network.h.
void TNodeEDatNet< TNodeData, TEdgeData >::SetNDat | ( | const int & | NId, |
const TNodeData & | NodeDat | ||
) |
Sets node data for the node of ID NId in the network.
Definition at line 779 of file network.h.
|
inline |
|
inline |
|
friend |
|
protected |
|
protected |
|
protected |