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 Network (directed graph, TNGraph with data on nodes only). 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 TNodeNet< TNodeData > | TNet |
typedef TPt< TNet > | PNet |
Public Member Functions | |
TNodeNet () | |
TNodeNet (const int &Nodes, const int &Edges) | |
Constructor that reserves enough memory for a network of Nodes nodes and Edges edges. More... | |
TNodeNet (const TNodeNet &NodeNet) | |
TNodeNet (TSIn &SIn) | |
Constructor that loads the network from a (binary) stream SIn. More... | |
virtual | ~TNodeNet () |
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... | |
TNodeNet & | operator= (const TNodeNet &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... | |
virtual 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 TEdgeI &EdgeI) |
Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() 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... | |
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 <TNodeNet<TNodeData> > Net = TNodeNet<TNodeData>::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) |
Protected Attributes | |
TCRef | CRef |
TInt | MxNId |
THash< TInt, TNode > | NodeH |
Friends | |
class | TPt< TNodeNet< TNodeData > > |
Node Network (directed graph, TNGraph with data on nodes only).
|
inlineexplicit |
Constructor that reserves enough memory for a network of Nodes nodes and Edges edges.
Definition at line 143 of file network.h.
|
inline |
int TNodeNet< TNodeData >::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 was successfully added return -1. Normally the function should return an ID of the edge added but since edges in TNodeNet have no IDs we return -1. Function aborts if SrcNId or DstNId are not nodes in the network.
Definition at line 334 of file network.h.
Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() to the network.
Definition at line 212 of file network.h.
int TNodeNet< TNodeData >::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 276 of file network.h.
int TNodeNet< TNodeData >::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 288 of file network.h.
Adds a node NodeI and its node data to the network.
Definition at line 174 of file network.h.
Returns an iterator referring to the first edge in the network.
Definition at line 222 of file network.h.
|
inline |
Deletes all nodes and edges from the network.
Definition at line 240 of file network.h.
void TNodeNet< TNodeData >::Defrag | ( | const bool & | OnlyNodeLinks = false | ) |
void TNodeNet< TNodeData >::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.
|
virtual |
Deletes node of ID NodeI.GetId() from the network.
Definition at line 180 of file network.h.
|
inline |
Tests whether the network is empty (has zero nodes).
Definition at line 238 of file network.h.
Returns an iterator referring to the past-the-end edge in the network.
Definition at line 224 of file network.h.
int TNodeNet< TNodeData >::GetEdges | ( | ) | const |
Not supported/implemented!
TNodeNet< TNodeData >::TEdgeI TNodeNet< TNodeData >::GetEI | ( | const int & | SrcNId, |
const int & | DstNId | ||
) | const |
Returns an iterator referring to edge (SrcNId, DstNId) in the network.
Definition at line 368 of file network.h.
|
inline |
|
inline |
|
inline |
Gets a vector IDs of all nodes in the network.
Definition at line 361 of file network.h.
|
inline |
|
inline |
Returns an interator referring to a random node in the network.
Definition at line 233 of file network.h.
Returns an ID of a random node in the network.
Definition at line 231 of file network.h.
bool TNodeNet< TNodeData >::HasFlag | ( | const TGraphFlag & | Flag | ) | const |
Allows for run-time checking the type of the network (see the TGraphFlag for flags).
Definition at line 271 of file network.h.
bool TNodeNet< TNodeData >::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 354 of file network.h.
|
inline |
bool TNodeNet< TNodeData >::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 386 of file network.h.
Static constructor that returns a pointer to the network. Call: TPt <TNodeNet<TNodeData> > Net = TNodeNet<TNodeData>::New().
Definition at line 151 of file network.h.
|
inline |
|
inline |
|
inlinevirtual |
void TNodeNet< TNodeData >::SetNDat | ( | const int & | NId, |
const TNodeData & | NodeDat | ||
) |
Sets node data for the node of ID NId in the network.
Definition at line 320 of file network.h.
|
inline |
|
inline |