SNAP Library, User Reference
2012-10-02 12:56:23
SNAP, a general purpose network analysis and graph mining library
|
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. | |
TNodeNet (const TNodeNet &NodeNet) | |
TNodeNet (TSIn &SIn) | |
Constructor that loads the network from a (binary) stream SIn. | |
virtual | ~TNodeNet () |
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). | |
TNodeNet & | operator= (const TNodeNet &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 TNode & | GetNode (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 TEdgeI &EdgeI) |
Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() 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. | |
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 <TNodeNet<TNodeData> > Net = TNodeNet<TNodeData>::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 | |
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).
Reimplemented in TTimeNet.
TNodeNet< TNodeData >::TNodeNet | ( | const int & | Nodes, |
const int & | Edges | ||
) | [inline, explicit] |
Constructor that reserves enough memory for a network of Nodes nodes and Edges edges.
TNodeNet< TNodeData >::TNodeNet | ( | const TNodeNet< TNodeData > & | NodeNet | ) | [inline] |
Constructor that loads the network from a (binary) stream SIn.
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.
Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() to the network.
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.
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.
Adds a node NodeId and its node data to the network.
Returns an iterator referring to the first edge in the network.
Returns an iterator referring to the first node in the network.
void TNodeNet< TNodeData >::Clr | ( | const bool & | DoDel = true , |
const bool & | ResetDat = true |
||
) | [inline] |
Deletes all nodes and edges from the network.
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.
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.
Deletes node of ID NId from the network.
If the node of ID NId does not exist the function aborts.
Deletes node of ID NodeI.GetId() from the network.
Tests whether the network is empty (has zero nodes).
Returns an iterator referring to the past-the-end edge in the network.
Returns an iterator referring to the past-the-end node in the network.
Returns the number of edges in the network.
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.
Returns the maximum id of a any node in the network.
Returns node data for the node of ID NId in the network.
const TNodeData& TNodeNet< TNodeData >::GetNDat | ( | const int & | NId | ) | const [inline] |
Returns node data for the node of ID NId in the network.
Returns an iterator referring to the node of ID NId in the network.
Gets a vector IDs of all nodes in the network.
TNode& TNodeNet< TNodeData >::GetNode | ( | const int & | NId | ) | [inline, protected] |
const TNode& TNodeNet< TNodeData >::GetNode | ( | const int & | NId | ) | const [inline] |
Returns node element for the node of ID NId in the network.
Returns the number of nodes in the network.
Returns an interator referring to a random node in the network.
Returns an ID of a random node in the network.
bool TNodeNet< TNodeData >::HasFlag | ( | const TGraphFlag & | Flag | ) | const |
Allows for run-time checking the type of the network (see the TGraphFlag for flags).
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.
Tests whether ID NId is a node.
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.
Static constructor that loads the network from a stream SIn and returns a pointer to it.
Reimplemented in TTimeNet.
Static constructor that returns a pointer to the network. Call: TPt <TNodeNet<TNodeData> > Net = TNodeNet<TNodeData>::New().
Reimplemented in TTimeNet.
TNodeNet& TNodeNet< TNodeData >::operator= | ( | const TNodeNet< TNodeData > & | NodeNet | ) | [inline] |
void TNodeNet< TNodeData >::Reserve | ( | const int & | Nodes, |
const int & | Edges | ||
) | [inline] |
Reserves memory for a network of Nodes nodes and Edges edges.
virtual void TNodeNet< TNodeData >::Save | ( | TSOut & | SOut | ) | const [inline, virtual] |
Saves the network to a (binary) stream SOut.
Reimplemented in TTimeNet.
void TNodeNet< TNodeData >::SetNDat | ( | const int & | NId, |
const TNodeData & | NodeDat | ||
) |
Sets node data for the node of ID NId in the network.
void TNodeNet< TNodeData >::SortNIdByDat | ( | const bool & | Asc = true | ) | [inline] |
Sorts nodes by node data.
void TNodeNet< TNodeData >::SortNIdById | ( | const bool & | Asc = true | ) | [inline] |
Sorts nodes by node IDs.