SNAP Library 6.0, User Reference
2020-12-09 16:24:20
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 | TNodeFunctor |
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 | AddNodeUnchecked (int NId=-1) |
Adds a node of ID NId to the network, noop if the node already exists. 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 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... | |
static PNet | LoadShM (TShMIn &ShMIn) |
Static constructor that loads the network from shared memory. More... | |
Protected Member Functions | |
TNode & | GetNode (const int &NId) |
Protected Attributes | |
TCRef | CRef |
TInt | MxNId |
THash< TInt, TNode > | NodeH |
Private Member Functions | |
void | LoadNetworkShM (TShMIn &ShMIn) |
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 162 of file network.h.
|
inline |
int TNodeNet< TNodeData >::AddEdge | ( | const int & | SrcNId, |
const int & | DstNId | ||
) |
Adds an edge from node 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 381 of file network.h.
Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() to the network.
Definition at line 247 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 311 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 335 of file network.h.
Adds a node NodeI and its node data to the network.
Definition at line 209 of file network.h.
int TNodeNet< TNodeData >::AddNodeUnchecked | ( | int | NId = -1 | ) |
Adds a node of ID NId to the network, noop if the node already exists.
Returns -1, if the node NId already exists. Otherwise, it returns the ID of the node being added. If NId is -1, node ID is automatically assigned.
Definition at line 323 of file network.h.
Returns an iterator referring to the first edge in the network.
Definition at line 257 of file network.h.
|
inline |
Deletes all nodes and edges from the network.
Definition at line 275 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 215 of file network.h.
|
inline |
Tests whether the network is empty (has zero nodes).
Definition at line 273 of file network.h.
Returns an iterator referring to the past-the-end edge in the network.
Definition at line 259 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 415 of file network.h.
|
inline |
|
inline |
|
inline |
Gets a vector IDs of all nodes in the network.
Definition at line 408 of file network.h.
|
inline |
|
inline |
Returns an interator referring to a random node in the network.
Definition at line 268 of file network.h.
Returns an ID of a random node in the network.
Definition at line 266 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 306 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 401 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 433 of file network.h.
|
inlineprivate |
Definition at line 153 of file network.h.
Static constructor that returns a pointer to the network. Call: TPt <TNodeNet<TNodeData> > Net = TNodeNet<TNodeData>::New().
Definition at line 170 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 367 of file network.h.
|
inline |
|
inline |