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
|
Bipartite graph. More...
#include <graph.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 | |
enum | TNodeTy { bgsUndef, bgsLeft, bgsRight, bgsBoth } |
typedef TBPGraph | TNet |
typedef TPt< TBPGraph > | PNet |
Public Member Functions | |
TBPGraph () | |
TBPGraph (const int &Nodes, const int &Edges) | |
Constructor that reserves enough memory for a graph of Nodes (LeftNodes+RightNodes) nodes and Edges edges. More... | |
TBPGraph (const TBPGraph &BPGraph) | |
!! Reserve(Nodes, Edges); } More... | |
TBPGraph (TSIn &SIn) | |
Constructor for loading the graph from a (binary) stream SIn. More... | |
void | Save (TSOut &SOut) const |
Saves the graph to a (binary) stream SOut. More... | |
bool | HasFlag (const TGraphFlag &Flag) const |
Allows for run-time checking the type of the graph (see the TGraphFlag for flags). More... | |
TBPGraph & | operator= (const TBPGraph &BPGraph) |
int | GetNodes () const |
Returns the total number of nodes in the graph. More... | |
int | GetLNodes () const |
Returns the number of nodes on the 'left' side of the biparite graph. More... | |
int | GetRNodes () const |
Returns the number of nodes on the 'right' side of the biparite graph. More... | |
int | AddNode (int NId=-1, const bool &LeftNode=true) |
Adds a node of ID NId to the graph. More... | |
int | AddNode (const TNodeI &NodeI) |
Adds a node of ID NodeI.GetId() to the graph. More... | |
void | DelNode (const int &NId) |
Deletes node of ID NId from the graph. More... | |
void | DelNode (const TNode &NodeI) |
Deletes node of ID NodeI.GetId() from the graph. More... | |
bool | IsNode (const int &NId) const |
Tests whether ID NId is a node. More... | |
bool | IsLNode (const int &NId) const |
Tests whether ID NId is a 'left' side node. More... | |
bool | IsRNode (const int &NId) const |
Tests whether ID NId is a 'right' side node. More... | |
int | GetMxNId () const |
Returns an ID that is larger than any node ID in the graph. More... | |
TNodeI | BegNI () const |
Returns an iterator referring to the first node in the graph. More... | |
TNodeI | EndNI () const |
Returns an iterator referring to the past-the-end node in the graph. More... | |
TNodeI | GetNI (const int &NId) const |
Returns an iterator referring to the node of ID NId in the graph. More... | |
TNodeI | BegLNI () const |
Returns an iterator referring to the first 'left' node in the graph. More... | |
TNodeI | EndLNI () const |
Returns an iterator referring to the past-the-end 'left' node in the graph. More... | |
TNodeI | BegRNI () const |
Returns an iterator referring to the first 'right' node in the graph. More... | |
TNodeI | EndRNI () const |
Returns an iterator referring to the past-the-end 'right' node in the graph. More... | |
int | GetEdges () const |
Returns the number of edges in the graph. More... | |
int | AddEdge (const int &LeftNId, const int &RightNId) |
Adds an edge between a node LeftNId on the left and a node RightNId on the right side of the bipartite graph. More... | |
int | AddEdge (const TEdgeI &EdgeI) |
Adds an edge between EdgeI.GetLNId() and EdgeI.GetRNId() to the graph. More... | |
void | DelEdge (const int &LeftNId, const int &RightNId) |
Deletes an edge between a node LeftNId on the left and a node RightNId on the right side of the bipartite graph. More... | |
bool | IsEdge (const int &LeftNId, const int &RightNId) const |
Tests whether an edge between node IDs LeftNId and RightNId exists in the graph. More... | |
TEdgeI | BegEI () const |
Returns an iterator referring to the first edge in the graph. More... | |
TEdgeI | EndEI () const |
Returns an iterator referring to the past-the-end edge in the graph. More... | |
TEdgeI | GetEI (const int &EId) const |
Not supported/implemented! More... | |
TEdgeI | GetEI (const int &LeftNId, const int &RightNId) const |
Returns an iterator referring to edge (LeftNId, RightNId) in the graph. More... | |
int | GetRndNId (TRnd &Rnd=TInt::Rnd) |
Returns an ID of a random node in the graph. More... | |
int | GetRndLNId (TRnd &Rnd=TInt::Rnd) |
Returns an ID of a random 'left' node in the graph. More... | |
int | GetRndRNId (TRnd &Rnd=TInt::Rnd) |
Returns an ID of a random 'right' node in the graph. More... | |
TNodeI | GetRndNI (TRnd &Rnd=TInt::Rnd) |
Returns an interator referring to a random node in the graph. More... | |
void | GetNIdV (TIntV &NIdV) const |
Gets a vector IDs of all nodes in the bipartite graph. More... | |
void | GetLNIdV (TIntV &NIdV) const |
Gets a vector IDs of all 'left' nodes in the bipartite graph. More... | |
void | GetRNIdV (TIntV &NIdV) const |
Gets a vector IDs of all 'right' nodes in the bipartite graph. More... | |
bool | Empty () const |
Tests whether the bipartite graph is empty (has zero nodes). More... | |
void | Clr () |
Deletes all nodes and edges from the bipartite graph. More... | |
void | Reserve (const int &Nodes, const int &Edges) |
Reserves memory for a biparite graph of Nodes nodes and Edges edges. More... | |
void | Defrag (const bool &OnlyNodeLinks=false) |
Defragments the biparite graph. More... | |
bool | IsOk (const bool &ThrowExcept=true) const |
Checks the bipartite graph data structure for internal consistency. More... | |
void | Dump (FILE *OutF=stdout) const |
Print the biparite graph in a human readable form to an output stream OutF. More... | |
Static Public Member Functions | |
static PBPGraph | New () |
Static constructor that returns a pointer to the graph. Call: PBPGraph BPGraph = TBPGraph::New();. More... | |
static PBPGraph | New (const int &Nodes, const int &Edges) |
Static constructor that returns a pointer to the graph and reserves enough memory for Nodes nodes and Edges edges. More... | |
static PBPGraph | Load (TSIn &SIn) |
Static constructor that loads the graph from a stream SIn and returns a pointer to it. More... | |
static PBPGraph | GetSmallGraph () |
Returns a small graph on 2 'left', 3 'right' nodes and 4 edges. More... | |
Private Attributes | |
TCRef | CRef |
TInt | MxNId |
THash< TInt, TNode > | LeftH |
THash< TInt, TNode > | RightH |
Friends | |
class | TPt< TBPGraph > |
typedef TPt<TBPGraph> TBPGraph::PNet |
typedef TBPGraph TBPGraph::TNet |
enum TBPGraph::TNodeTy |
Enumerator | |
---|---|
bgsUndef | |
bgsLeft | |
bgsRight | |
bgsBoth |
|
inlineexplicit |
|
inline |
|
inline |
int TBPGraph::AddEdge | ( | const int & | LeftNId, |
const int & | RightNId | ||
) |
Adds an edge between a node LeftNId on the left and a node RightNId on the right side of the bipartite graph.
Definition at line 705 of file graph.cpp.
|
inline |
Adds an edge between EdgeI.GetLNId() and EdgeI.GetRNId() to the graph.
Definition at line 1119 of file graph.h.
int TBPGraph::AddNode | ( | int | NId = -1 , |
const bool & | LeftNode = true |
||
) |
Adds a node of ID NId to the graph.
Definition at line 671 of file graph.cpp.
|
inline |
Adds a node of ID NodeI.GetId() to the graph.
Definition at line 1083 of file graph.h.
|
inline |
Returns an iterator referring to the first edge in the graph.
Definition at line 1126 of file graph.h.
|
inline |
|
inline |
|
inline |
|
inline |
Deletes all nodes and edges from the bipartite graph.
Definition at line 1153 of file graph.h.
void TBPGraph::Defrag | ( | const bool & | OnlyNodeLinks = false | ) |
void TBPGraph::DelEdge | ( | const int & | LeftNId, |
const int & | RightNId | ||
) |
Deletes an edge between a node LeftNId on the left and a node RightNId on the right side of the bipartite graph.
Definition at line 719 of file graph.cpp.
void TBPGraph::DelNode | ( | const int & | NId | ) |
Deletes node of ID NId from the graph.
Definition at line 682 of file graph.cpp.
|
inline |
Deletes node of ID NodeI.GetId() from the graph.
Definition at line 1088 of file graph.h.
void TBPGraph::Dump | ( | FILE * | OutF = stdout | ) | const |
Print the biparite graph in a human readable form to an output stream OutF.
Definition at line 845 of file graph.cpp.
|
inline |
Tests whether the bipartite graph is empty (has zero nodes).
Definition at line 1151 of file graph.h.
|
inline |
Returns an iterator referring to the past-the-end edge in the graph.
Definition at line 1128 of file graph.h.
|
inline |
Returns an iterator referring to the past-the-end 'left' node in the graph.
Definition at line 1107 of file graph.h.
|
inline |
|
inline |
Returns an iterator referring to the past-the-end 'right' node in the graph.
Definition at line 1111 of file graph.h.
int TBPGraph::GetEdges | ( | ) | const |
TEdgeI TBPGraph::GetEI | ( | const int & | EId | ) | const |
Not supported/implemented!
TBPGraph::TEdgeI TBPGraph::GetEI | ( | const int & | LeftNId, |
const int & | RightNId | ||
) | const |
Returns an iterator referring to edge (LeftNId, RightNId) in the graph.
Definition at line 740 of file graph.cpp.
void TBPGraph::GetLNIdV | ( | TIntV & | NIdV | ) | const |
Gets a vector IDs of all 'left' nodes in the bipartite graph.
Definition at line 778 of file graph.cpp.
|
inline |
|
inline |
|
inline |
Returns an iterator referring to the node of ID NId in the graph.
void TBPGraph::GetNIdV | ( | TIntV & | NIdV | ) | const |
Gets a vector IDs of all nodes in the bipartite graph.
Definition at line 770 of file graph.cpp.
|
inline |
Returns the total number of nodes in the graph.
Definition at line 1074 of file graph.h.
Returns an ID of a random 'left' node in the graph.
Definition at line 762 of file graph.cpp.
Returns an interator referring to a random node in the graph.
Definition at line 1142 of file graph.h.
Returns an ID of a random node in the graph.
Definition at line 754 of file graph.cpp.
Returns an ID of a random 'right' node in the graph.
Definition at line 766 of file graph.cpp.
void TBPGraph::GetRNIdV | ( | TIntV & | NIdV | ) | const |
Gets a vector IDs of all 'right' nodes in the bipartite graph.
Definition at line 784 of file graph.cpp.
|
inline |
|
static |
Returns a small graph on 2 'left', 3 'right' nodes and 4 edges.
Definition at line 868 of file graph.cpp.
bool TBPGraph::HasFlag | ( | const TGraphFlag & | Flag | ) | const |
Allows for run-time checking the type of the graph (see the TGraphFlag for flags).
bool TBPGraph::IsEdge | ( | const int & | LeftNId, |
const int & | RightNId | ||
) | const |
Tests whether an edge between node IDs LeftNId and RightNId exists in the graph.
Definition at line 735 of file graph.cpp.
|
inline |
|
inline |
Tests whether ID NId is a node.
Definition at line 1090 of file graph.h.
bool TBPGraph::IsOk | ( | const bool & | ThrowExcept = true | ) | const |
Checks the bipartite graph data structure for internal consistency.
Definition at line 803 of file graph.cpp.
|
inline |
|
inlinestatic |
Static constructor that returns a pointer to the graph. Call: PBPGraph BPGraph = TBPGraph::New();.
Definition at line 1062 of file graph.h.
|
inlinestatic |
void TBPGraph::Reserve | ( | const int & | Nodes, |
const int & | Edges | ||
) |
|
inline |