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 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. | |
TNodeEDatNet (const TNodeEDatNet &NodeNet) | |
TNodeEDatNet (TSIn &SIn) | |
Constructor that loads the network from a (binary) stream SIn. | |
virtual | ~TNodeEDatNet () |
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). | |
TNodeEDatNet & | operator= (const TNodeEDatNet &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 int &SrcNId, const int &DstNId, 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 &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. | |
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. | |
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. | |
TEdgeData & | GetEDat (const int &SrcNId, const int &DstNId) |
Returns edge data for the edge from node IDs SrcNId to DstNId. | |
const TEdgeData & | GetEDat (const int &SrcNId, const int &DstNId) const |
Returns edge data for the edge from node IDs SrcNId to DstNId. | |
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. | |
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 <TNodeEDatNet<TNodeData, TEdgeData> > Net = TNodeEDatNet<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 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 |
TNodeEDatNet< TNodeData, TEdgeData >::TNodeEDatNet | ( | ) | [inline] |
TNodeEDatNet< TNodeData, TEdgeData >::TNodeEDatNet | ( | const int & | Nodes, |
const int & | Edges | ||
) | [inline, explicit] |
Constructor that reserves enough memory for a network of Nodes nodes and Edges edges.
TNodeEDatNet< TNodeData, TEdgeData >::TNodeEDatNet | ( | const TNodeEDatNet< TNodeData, TEdgeData > & | NodeNet | ) | [inline] |
TNodeEDatNet< TNodeData, TEdgeData >::TNodeEDatNet | ( | TSIn & | SIn | ) | [inline] |
Constructor that loads the network from a (binary) stream SIn.
virtual TNodeEDatNet< TNodeData, TEdgeData >::~TNodeEDatNet | ( | ) | [inline, virtual] |
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.
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.
int TNodeEDatNet< TNodeData, TEdgeData >::AddEdge | ( | const TEdgeI & | EdgeI | ) | [inline] |
Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() and its edge data to the network.
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.
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.
int TNodeEDatNet< TNodeData, TEdgeData >::AddNode | ( | const TNodeI & | NodeId | ) | [inline] |
Adds a node NodeId and its node data to the network.
TEdgeI TNodeEDatNet< TNodeData, TEdgeData >::BegEI | ( | ) | const [inline] |
Returns an iterator referring to the first edge in the network.
TNodeI TNodeEDatNet< TNodeData, TEdgeData >::BegNI | ( | ) | const [inline] |
Returns an iterator referring to the first node in the network.
void TNodeEDatNet< TNodeData, TEdgeData >::Clr | ( | const bool & | DoDel = true , |
const bool & | ResetDat = true |
||
) | [inline] |
Deletes all nodes and edges from the network.
void TNodeEDatNet< 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.
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.
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.
void TNodeEDatNet< TNodeData, TEdgeData >::DelNode | ( | const TNode & | NodeI | ) | [inline] |
Deletes node of ID NodeI.GetId() from the network.
bool TNodeEDatNet< TNodeData, TEdgeData >::Empty | ( | ) | const [inline] |
Tests whether the network is empty (has zero nodes).
TEdgeI TNodeEDatNet< TNodeData, TEdgeData >::EndEI | ( | ) | const [inline] |
Returns an iterator referring to the past-the-end edge in the network.
TNodeI TNodeEDatNet< TNodeData, TEdgeData >::EndNI | ( | ) | const [inline] |
Returns an iterator referring to the past-the-end node in the network.
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.
TEdgeData & TNodeEDatNet< TNodeData, TEdgeData >::GetEDat | ( | const int & | SrcNId, |
const int & | DstNId | ||
) |
Returns edge data for the edge from node IDs SrcNId to DstNId.
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.
int TNodeEDatNet< TNodeData, TEdgeData >::GetEdges | ( | ) | const |
Returns the number of edges in the network.
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.
int TNodeEDatNet< TNodeData, TEdgeData >::GetMxNId | ( | ) | const [inline] |
Returns the maximum id of a any node in the network.
TNodeData& TNodeEDatNet< TNodeData, TEdgeData >::GetNDat | ( | const int & | NId | ) | [inline] |
Returns node data for the node of ID NId in the network.
const TNodeData& TNodeEDatNet< TNodeData, TEdgeData >::GetNDat | ( | const int & | NId | ) | const [inline] |
Returns node data for the node of ID NId in the network.
TNodeI TNodeEDatNet< TNodeData, TEdgeData >::GetNI | ( | const int & | NId | ) | const [inline] |
Returns an iterator referring to the node of ID NId in the network.
int TNodeEDatNet< TNodeData, TEdgeData >::GetNIdPos | ( | const TVec< TPair< TInt, TEdgeData > > & | NIdV, |
const int & | NId | ||
) | [static, protected] |
void TNodeEDatNet< TNodeData, TEdgeData >::GetNIdV | ( | TIntV & | NIdV | ) | const |
Gets a vector IDs of all nodes in the network.
TNode& TNodeEDatNet< TNodeData, TEdgeData >::GetNode | ( | const int & | NId | ) | [inline, protected] |
const TNode& TNodeEDatNet< TNodeData, TEdgeData >::GetNode | ( | const int & | NId | ) | const [inline] |
Returns node element for the node of ID NId in the network.
int TNodeEDatNet< TNodeData, TEdgeData >::GetNodes | ( | ) | const [inline] |
Returns the number of nodes in the network.
TNodeI TNodeEDatNet< TNodeData, TEdgeData >::GetRndNI | ( | TRnd & | Rnd = TInt::Rnd | ) | [inline] |
Returns an interator referring to a random node in the network.
int TNodeEDatNet< TNodeData, TEdgeData >::GetRndNId | ( | TRnd & | Rnd = TInt::Rnd | ) | [inline] |
Returns an ID of a random node in the network.
bool TNodeEDatNet< TNodeData, TEdgeData >::HasFlag | ( | const TGraphFlag & | Flag | ) | const |
Allows for run-time checking the type of the network (see the TGraphFlag for flags).
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.
bool TNodeEDatNet< TNodeData, TEdgeData >::IsNode | ( | const int & | NId | ) | const [inline] |
Tests whether ID NId is a node.
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.
static PNet TNodeEDatNet< TNodeData, TEdgeData >::Load | ( | TSIn & | SIn | ) | [inline, static] |
Static constructor that loads the network from a stream SIn and returns a pointer to it.
static PNet TNodeEDatNet< TNodeData, TEdgeData >::New | ( | ) | [inline, static] |
Static constructor that returns a pointer to the network. Call: TPt <TNodeEDatNet<TNodeData, TEdgeData> > Net = TNodeEDatNet<TNodeData, TEdgeData>::New().
TNodeEDatNet& TNodeEDatNet< TNodeData, TEdgeData >::operator= | ( | const TNodeEDatNet< TNodeData, TEdgeData > & | NodeNet | ) | [inline] |
void TNodeEDatNet< TNodeData, TEdgeData >::Reserve | ( | const int & | Nodes, |
const int & | Edges | ||
) | [inline] |
Reserves memory for a network of Nodes nodes and Edges edges.
virtual void TNodeEDatNet< TNodeData, TEdgeData >::Save | ( | TSOut & | SOut | ) | const [inline, virtual] |
Saves the network to a (binary) stream SOut.
void TNodeEDatNet< TNodeData, TEdgeData >::SetAllEDat | ( | const TEdgeData & | EdgeDat | ) |
Sets edge data for all the edges in the network to EDat.
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.
void TNodeEDatNet< TNodeData, TEdgeData >::SetNDat | ( | const int & | NId, |
const TNodeData & | NodeDat | ||
) |
Sets node data for the node of ID NId in the network.
void TNodeEDatNet< TNodeData, TEdgeData >::SortNIdByDat | ( | const bool & | Asc = true | ) | [inline] |
Sorts nodes by node data.
void TNodeEDatNet< TNodeData, TEdgeData >::SortNIdById | ( | const bool & | Asc = true | ) | [inline] |
Sorts nodes by node IDs.
friend class TPt< TNodeEDatNet< TNodeData, TEdgeData > > [friend] |
TCRef TNodeEDatNet< TNodeData, TEdgeData >::CRef [protected] |
TInt TNodeEDatNet< TNodeData, TEdgeData >::MxNId [protected] |
THash<TInt, TNode> TNodeEDatNet< TNodeData, TEdgeData >::NodeH [protected] |