|
SNAP Library, User Reference
2012-10-15 15:06:59
SNAP, a general purpose network analysis and graph mining library
|
#include <ghash.h>
Public Member Functions | |
| TSimpleGraph () | |
| TSimpleGraph (const TIntPrV &GEdgeV) | |
| bool | operator== (const TSimpleGraph &Graph) const |
| bool | operator< (const TSimpleGraph &Graph) const |
| int | GetEdges () const |
| void | AddEdge (const int &SrcNId, const int &DstNId) |
| bool | Join (const TSimpleGraph &G1, const TSimpleGraph &G2) |
| TIntPrV & | GetEdgeV () |
| TIntPrV & | operator() () |
| void | Dump (const TStr &Desc=TStr()) const |
Private Attributes | |
| TIntPrV | EdgeV |
| TSimpleGraph::TSimpleGraph | ( | ) | [inline] |
| TSimpleGraph::TSimpleGraph | ( | const TIntPrV & | GEdgeV | ) | [inline] |
| void TSimpleGraph::AddEdge | ( | const int & | SrcNId, |
| const int & | DstNId | ||
| ) | [inline] |
| void TSimpleGraph::Dump | ( | const TStr & | Desc = TStr() | ) | const |
| int TSimpleGraph::GetEdges | ( | ) | const [inline] |
| TIntPrV& TSimpleGraph::GetEdgeV | ( | ) | [inline] |
| bool TSimpleGraph::Join | ( | const TSimpleGraph & | G1, |
| const TSimpleGraph & | G2 | ||
| ) |
Definition at line 233 of file ghash.cpp.
{
const int Edges1 = G1.GetEdges();
const int Edges2 = G2.GetEdges();
const TIntPrV& EdgeV1 = G1.EdgeV;
const TIntPrV& EdgeV2 = G2.EdgeV;
const int MxEdges = Edges1+1;
if (GetEdges() != MxEdges) EdgeV.Gen(MxEdges);
IAssert(Edges1 == Edges2);
int e=0, g1=0, g2=0;
while (g1 < Edges1 && g2 < Edges2) {
if (e == MxEdges) return false;
if (abs(g1 - g2) > 1) return false;
if (EdgeV1[g1] == EdgeV2[g2]) { e++; g1++; g2++; }
else if (EdgeV1[g1] < EdgeV2[g2]) { e++; g1++; }
else { e++; g2++; }
}
e=0; g1=0; g2=0;
while (g1 < Edges1 && g2 < Edges2) {
if (EdgeV1[g1] == EdgeV2[g2]) {
EdgeV[e] = EdgeV1[g1]; e++; g1++; g2++; }
else if (EdgeV1[g1] < EdgeV2[g2]) {
EdgeV[e] = EdgeV1[g1]; e++; g1++; }
else {
EdgeV[e] = EdgeV2[g2]; e++; g2++; }
}
if (g1 == Edges1 && g2 == Edges2 && e == MxEdges) return true;
if (e+1 == MxEdges) {
if (g1+1 == Edges1 && g2 == Edges2) {
EdgeV[e] = EdgeV1.Last();
return true;
}
if (g1 == Edges1 && g2+1 == Edges2) {
EdgeV[e] = EdgeV2.Last();
return true;
}
}
return false;
}
| TIntPrV& TSimpleGraph::operator() | ( | ) | [inline] |
| bool TSimpleGraph::operator< | ( | const TSimpleGraph & | Graph | ) | const [inline] |
| bool TSimpleGraph::operator== | ( | const TSimpleGraph & | Graph | ) | const [inline] |
TIntPrV TSimpleGraph::EdgeV [private] |