|
SNAP Library, Developer Reference
2012-10-02 12:56:23
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] |
Definition at line 397 of file ghash.h.
References TVec< TVal >::Add(), and EdgeV.
Referenced by TSubGraphsEnum::RecurBfs().


| void TSimpleGraph::Dump | ( | const TStr & | Desc = TStr() | ) | const |
Definition at line 273 of file ghash.cpp.
References TStr::CStr(), EdgeV, TStr::Empty(), and TVec< TVal >::Len().
Referenced by TSubGraphsEnum::Gen2Graphs().
{
if (! Desc.Empty()) printf("%s. Edges: %d\n", Desc.CStr(), EdgeV.Len());
else printf("Edges: %d\n", EdgeV.Len());
for (int i = 0; i < EdgeV.Len(); i++) {
printf("\t%d\t%d\n", EdgeV[i].Val1(), EdgeV[i].Val2());
}
}


| int TSimpleGraph::GetEdges | ( | ) | const [inline] |
| TIntPrV& TSimpleGraph::GetEdgeV | ( | ) | [inline] |
Definition at line 399 of file ghash.h.
References EdgeV.
Referenced by TSubGraphsEnum::EnumSubGraphs(), and TSubGraphsEnum::Gen2Graphs().
{ return EdgeV; }

| bool TSimpleGraph::Join | ( | const TSimpleGraph & | G1, |
| const TSimpleGraph & | G2 | ||
| ) |
Definition at line 232 of file ghash.cpp.
References EdgeV, TVec< TVal >::Gen(), GetEdges(), IAssert, and TVec< TVal >::Last().
Referenced by TSubGraphsEnum::EnumSubGraphs().
{
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] |
Definition at line 389 of file ghash.h.
Referenced by AddEdge(), Dump(), GetEdges(), GetEdgeV(), Join(), operator()(), operator<(), and operator==().