SNAP Library, User Reference
2012-10-02 12:56:23
SNAP, a general purpose network analysis and graph mining library
|
Classes | |
class | TEdge |
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 TNodeEdgeNet < TNodeData, TEdgeData > | TNet |
typedef TPt< TNet > | PNet |
Public Member Functions | |
TNodeEdgeNet () | |
TNodeEdgeNet (const int &Nodes, const int &Edges) | |
Constructor that reserves enough memory for a network of Nodes nodes and Edges edges. | |
TNodeEdgeNet (const TNodeEdgeNet &Net) | |
TNodeEdgeNet (TSIn &SIn) | |
Constructor that loads the network from a (binary) stream SIn. | |
virtual | ~TNodeEdgeNet () |
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). | |
TNodeEdgeNet & | operator= (const TNodeEdgeNet &Net) |
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 node data to node with ID NId. | |
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. | |
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 | GetUniqEdges (const bool &IsDir=true) const |
Returns the number of edges in the network with a unique pair of nodes. | |
int | AddEdge (const int &SrcNId, const int &DstNId, int EId=-1) |
Adds an edge between node IDs SrcNId and DstNId to the graph. | |
int | AddEdge (const int &SrcNId, const int &DstNId, int EId, 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 &EId) |
Deletes an edge with ID EId from 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 &EId) const |
Tests whether an edge with ID EId exists in 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. | |
bool | IsEdge (const int &SrcNId, const int &DstNId, int &EId, const bool &IsDir=true) const |
Tests whether an edge from node IDs SrcNId to DstNId with edge ID EId exists in the network. | |
int | GetEId (const int &SrcNId, const int &DstNId) const |
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 |
TEdgeI | GetEI (const int &SrcNId, const int &DstNId) const |
void | SetEDat (const int &EId, const TEdgeData &EdgeDat) |
Sets edge data for the edge of ID NId in the network. | |
TEdgeData & | GetEDat (const int &EId) |
Returns edge data for the edge with ID EId. | |
const TEdgeData & | GetEDat (const int &EId) const |
Returns edge data for the edge with ID EId. | |
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. | |
int | GetRndEId (TRnd &Rnd=TInt::Rnd) |
Returns an ID of a random edge in the network. | |
TEdgeI | GetRndEI (TRnd &Rnd=TInt::Rnd) |
Returns an interator referring to a random edge in the network. | |
void | GetNIdV (TIntV &NIdV) const |
Returns a vector of all node IDs in the network. | |
void | GetEIdV (TIntV &EIdV) const |
Returns a vector of all edge IDs in the network. | |
bool | Empty () const |
Tests whether the network is empty (has zero nodes). | |
void | Clr () |
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 | SortEIdById (const bool &Asc=true) |
Sorts edges by edge IDs. | |
void | SortEIdByDat (const bool &Asc=true) |
Sorts edges by edge 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 <TNodeEdgeNet<TNodeData, TEdgeData> > Net = TNodeEdgeNet<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 Attributes | |
TCRef | CRef |
TInt | MxNId |
TInt | MxEId |
THash< TInt, TNode > | NodeH |
THash< TInt, TEdge > | EdgeH |
Friends | |
class | TPt< TNodeEdgeNet< TNodeData, TEdgeData > > |
Node Edge Network (directed multigraph, TNEGraph with data on nodes and edges).
typedef TPt<TNet> TNodeEdgeNet< TNodeData, TEdgeData >::PNet |
Reimplemented in TTimeNENet.
typedef TEdgeData TNodeEdgeNet< TNodeData, TEdgeData >::TEdgeDat |
typedef TNodeEdgeNet<TNodeData, TEdgeData> TNodeEdgeNet< TNodeData, TEdgeData >::TNet |
Reimplemented in TTimeNENet.
typedef TNodeData TNodeEdgeNet< TNodeData, TEdgeData >::TNodeDat |
TNodeEdgeNet< TNodeData, TEdgeData >::TNodeEdgeNet | ( | ) | [inline] |
TNodeEdgeNet< TNodeData, TEdgeData >::TNodeEdgeNet | ( | const int & | Nodes, |
const int & | Edges | ||
) | [inline, explicit] |
Constructor that reserves enough memory for a network of Nodes nodes and Edges edges.
TNodeEdgeNet< TNodeData, TEdgeData >::TNodeEdgeNet | ( | const TNodeEdgeNet< TNodeData, TEdgeData > & | Net | ) | [inline] |
TNodeEdgeNet< TNodeData, TEdgeData >::TNodeEdgeNet | ( | TSIn & | SIn | ) | [inline] |
Constructor that loads the network from a (binary) stream SIn.
virtual TNodeEdgeNet< TNodeData, TEdgeData >::~TNodeEdgeNet | ( | ) | [inline, virtual] |
int TNodeEdgeNet< TNodeData, TEdgeData >::AddEdge | ( | const int & | SrcNId, |
const int & | DstNId, | ||
int | EId = -1 |
||
) |
Adds an edge between node IDs SrcNId and DstNId to the graph.
Returns the ID of the edge being added. If EId is -1, edge ID is automatically assigned. Aborts, if an edge with ID EId already exists. Aborts, if SrcNId or DstNId are not nodes in the graph.
int TNodeEdgeNet< TNodeData, TEdgeData >::AddEdge | ( | const int & | SrcNId, |
const int & | DstNId, | ||
int | EId, | ||
const TEdgeData & | EdgeDat | ||
) |
Adds an edge and edge data from node IDs SrcNId to node DstNId.
Returns the ID of the edge being added. If EId is -1, edge ID is automatically assigned. Aborts, if an edge with ID EId already exists. Aborts, if SrcNId or DstNId are not nodes in the graph.
int TNodeEdgeNet< TNodeData, TEdgeData >::AddEdge | ( | const TEdgeI & | EdgeI | ) | [inline] |
Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() and its edge data to the network.
int TNodeEdgeNet< 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 TNodeEdgeNet< TNodeData, TEdgeData >::AddNode | ( | int | NId, |
const TNodeData & | NodeDat | ||
) |
Adds node data to node with ID NId.
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 TNodeEdgeNet< TNodeData, TEdgeData >::AddNode | ( | const TNodeI & | NodeId | ) | [inline] |
Adds a node NodeId and its node data to the network.
TEdgeI TNodeEdgeNet< TNodeData, TEdgeData >::BegEI | ( | ) | const [inline] |
Returns an iterator referring to the first edge in the network.
TNodeI TNodeEdgeNet< TNodeData, TEdgeData >::BegNI | ( | ) | const [inline] |
Returns an iterator referring to the first node in the network.
void TNodeEdgeNet< TNodeData, TEdgeData >::Clr | ( | ) | [inline] |
Deletes all nodes and edges from the network.
void TNodeEdgeNet< 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 TNodeEdgeNet< TNodeData, TEdgeData >::DelEdge | ( | const int & | EId | ) |
Deletes an edge with ID EId from the network.
void TNodeEdgeNet< 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 TNodeEdgeNet< 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 TNodeEdgeNet< TNodeData, TEdgeData >::DelNode | ( | const TNode & | NodeI | ) | [inline] |
Deletes node of ID NodeI.GetId() from the network.
bool TNodeEdgeNet< TNodeData, TEdgeData >::Empty | ( | ) | const [inline] |
Tests whether the network is empty (has zero nodes).
TEdgeI TNodeEdgeNet< TNodeData, TEdgeData >::EndEI | ( | ) | const [inline] |
Returns an iterator referring to the past-the-end edge in the network.
TNodeI TNodeEdgeNet< TNodeData, TEdgeData >::EndNI | ( | ) | const [inline] |
Returns an iterator referring to the past-the-end node in the network.
TEdgeData& TNodeEdgeNet< TNodeData, TEdgeData >::GetEDat | ( | const int & | EId | ) | [inline] |
Returns edge data for the edge with ID EId.
const TEdgeData& TNodeEdgeNet< TNodeData, TEdgeData >::GetEDat | ( | const int & | EId | ) | const [inline] |
Returns edge data for the edge with ID EId.
int TNodeEdgeNet< TNodeData, TEdgeData >::GetEdges | ( | ) | const [inline] |
Returns the number of edges in the network.
TEdgeI TNodeEdgeNet< TNodeData, TEdgeData >::GetEI | ( | const int & | EId | ) | const [inline] |
TEdgeI TNodeEdgeNet< TNodeData, TEdgeData >::GetEI | ( | const int & | SrcNId, |
const int & | DstNId | ||
) | const [inline] |
int TNodeEdgeNet< TNodeData, TEdgeData >::GetEId | ( | const int & | SrcNId, |
const int & | DstNId | ||
) | const [inline] |
void TNodeEdgeNet< TNodeData, TEdgeData >::GetEIdV | ( | TIntV & | EIdV | ) | const |
Returns a vector of all edge IDs in the network.
int TNodeEdgeNet< TNodeData, TEdgeData >::GetMxNId | ( | ) | const [inline] |
Returns the maximum id of a any node in the network.
TNodeData& TNodeEdgeNet< TNodeData, TEdgeData >::GetNDat | ( | const int & | NId | ) | [inline] |
Returns node data for the node of ID NId in the network.
const TNodeData& TNodeEdgeNet< TNodeData, TEdgeData >::GetNDat | ( | const int & | NId | ) | const [inline] |
Returns node data for the node of ID NId in the network.
TNodeI TNodeEdgeNet< TNodeData, TEdgeData >::GetNI | ( | const int & | NId | ) | const [inline] |
Returns an iterator referring to the node of ID NId in the network.
void TNodeEdgeNet< TNodeData, TEdgeData >::GetNIdV | ( | TIntV & | NIdV | ) | const |
Returns a vector of all node IDs in the network.
int TNodeEdgeNet< TNodeData, TEdgeData >::GetNodes | ( | ) | const [inline] |
Returns the number of nodes in the network.
TEdgeI TNodeEdgeNet< TNodeData, TEdgeData >::GetRndEI | ( | TRnd & | Rnd = TInt::Rnd | ) | [inline] |
Returns an interator referring to a random edge in the network.
int TNodeEdgeNet< TNodeData, TEdgeData >::GetRndEId | ( | TRnd & | Rnd = TInt::Rnd | ) | [inline] |
Returns an ID of a random edge in the network.
TNodeI TNodeEdgeNet< TNodeData, TEdgeData >::GetRndNI | ( | TRnd & | Rnd = TInt::Rnd | ) | [inline] |
Returns an interator referring to a random node in the network.
int TNodeEdgeNet< TNodeData, TEdgeData >::GetRndNId | ( | TRnd & | Rnd = TInt::Rnd | ) | [inline] |
Returns an ID of a random node in the network.
int TNodeEdgeNet< TNodeData, TEdgeData >::GetUniqEdges | ( | const bool & | IsDir = true | ) | const |
Returns the number of edges in the network with a unique pair of nodes.
bool TNodeEdgeNet< TNodeData, TEdgeData >::HasFlag | ( | const TGraphFlag & | Flag | ) | const |
Allows for run-time checking the type of the network (see the TGraphFlag for flags).
bool TNodeEdgeNet< TNodeData, TEdgeData >::IsEdge | ( | const int & | EId | ) | const [inline] |
Tests whether an edge with ID EId exists in the network.
bool TNodeEdgeNet< TNodeData, TEdgeData >::IsEdge | ( | const int & | SrcNId, |
const int & | DstNId, | ||
const bool & | IsDir = true |
||
) | const [inline] |
Tests whether an edge from node IDs SrcNId to DstNId exists in the network.
bool TNodeEdgeNet< TNodeData, TEdgeData >::IsEdge | ( | const int & | SrcNId, |
const int & | DstNId, | ||
int & | EId, | ||
const bool & | IsDir = true |
||
) | const |
Tests whether an edge from node IDs SrcNId to DstNId with edge ID EId exists in the network.
bool TNodeEdgeNet< TNodeData, TEdgeData >::IsNode | ( | const int & | NId | ) | const [inline] |
Tests whether ID NId is a node.
bool TNodeEdgeNet< 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 TNodeEdgeNet< TNodeData, TEdgeData >::Load | ( | TSIn & | SIn | ) | [inline, static] |
Static constructor that loads the network from a stream SIn and returns a pointer to it.
Reimplemented in TTimeNENet.
static PNet TNodeEdgeNet< TNodeData, TEdgeData >::New | ( | ) | [inline, static] |
Static constructor that returns a pointer to the network. Call: TPt <TNodeEdgeNet<TNodeData, TEdgeData> > Net = TNodeEdgeNet<TNodeData, TEdgeData>::New().
Reimplemented in TTimeNENet.
TNodeEdgeNet& TNodeEdgeNet< TNodeData, TEdgeData >::operator= | ( | const TNodeEdgeNet< TNodeData, TEdgeData > & | Net | ) | [inline] |
void TNodeEdgeNet< TNodeData, TEdgeData >::Reserve | ( | const int & | Nodes, |
const int & | Edges | ||
) | [inline] |
Reserves memory for a network of Nodes nodes and Edges edges.
virtual void TNodeEdgeNet< TNodeData, TEdgeData >::Save | ( | TSOut & | SOut | ) | const [inline, virtual] |
Saves the network to a (binary) stream SOut.
Reimplemented in TTimeNENet.
void TNodeEdgeNet< TNodeData, TEdgeData >::SetAllEDat | ( | const TEdgeData & | EdgeDat | ) |
Sets edge data for all the edges in the network to EDat.
void TNodeEdgeNet< TNodeData, TEdgeData >::SetEDat | ( | const int & | EId, |
const TEdgeData & | EdgeDat | ||
) |
Sets edge data for the edge of ID NId in the network.
void TNodeEdgeNet< TNodeData, TEdgeData >::SetNDat | ( | const int & | NId, |
const TNodeData & | NodeDat | ||
) |
Sets node data for the node of ID NId in the network.
void TNodeEdgeNet< TNodeData, TEdgeData >::SortEIdByDat | ( | const bool & | Asc = true | ) | [inline] |
Sorts edges by edge data.
void TNodeEdgeNet< TNodeData, TEdgeData >::SortEIdById | ( | const bool & | Asc = true | ) | [inline] |
Sorts edges by edge IDs.
void TNodeEdgeNet< TNodeData, TEdgeData >::SortNIdByDat | ( | const bool & | Asc = true | ) | [inline] |
Sorts nodes by node data.
void TNodeEdgeNet< TNodeData, TEdgeData >::SortNIdById | ( | const bool & | Asc = true | ) | [inline] |
Sorts nodes by node IDs.
friend class TPt< TNodeEdgeNet< TNodeData, TEdgeData > > [friend] |
TCRef TNodeEdgeNet< TNodeData, TEdgeData >::CRef [protected] |
THash<TInt, TEdge> TNodeEdgeNet< TNodeData, TEdgeData >::EdgeH [protected] |
TInt TNodeEdgeNet< TNodeData, TEdgeData >::MxEId [protected] |
TInt TNodeEdgeNet< TNodeData, TEdgeData >::MxNId [protected] |
THash<TInt, TNode> TNodeEdgeNet< TNodeData, TEdgeData >::NodeH [protected] |