|
SNAP Library 2.1, User Reference
2013-09-25 10:47:25
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <graphcounter.h>
Static Public Member Functions | |
| static bool | IsEdge (const PNGraph &G, int SrcNId, int DstNId) |
| static void | GetEdges (uint64 graphId, int nodes, TVec< TPair< int, int > > &edges) |
| static void | GetNormalizedGraph (const PNGraph &G, PNGraph &nG) |
| static void | GetIndGraph (const PNGraph &G, const TIntV &sg, PNGraph &indG) |
| static void | GetGraph (uint64 graphId, int nodes, PNGraph &G) |
| static void | GetIsoGraphs (uint64 graphId, int nodes, TVec< PNGraph > &isoG) |
| static void | GetIsoGraphs (const PNGraph &G, TVec< PNGraph > &isoG) |
| static uint64 | GraphId (const PNGraph &G) |
| static uint64 | GraphId (const PNGraph &G, const TIntV &sg) |
| static uint64 | GetMinAndGraphIds (const TVec< PNGraph > &isoG, TVec< uint64 > &graphIds) |
Static Private Member Functions | |
| static void | GetNormalizedMap (const PNGraph &G, THash< TInt, TInt > &map) |
| static void | GetPermutations (TIntV &v, int start, TVec< TIntV > &perms) |
Definition at line 79 of file graphcounter.h.
| void TGraphEnumUtils::GetEdges | ( | uint64 | graphId, |
| int | nodes, | ||
| TVec< TPair< int, int > > & | edges | ||
| ) | [static] |
Definition at line 190 of file graphcounter.cpp.
{
for(int row=0; row<nodes; row++) {
for(int col=0; col<nodes; col++) {
int n = row*nodes+col;
//
uint64 bits = graphId >> n;
uint64 mask = 1;
if((bits & mask)==1) edges.Add(TPair<int,int>(row, col));
}
}
}
| void TGraphEnumUtils::GetGraph | ( | uint64 | graphId, |
| int | nodes, | ||
| PNGraph & | G | ||
| ) | [static] |
Definition at line 269 of file graphcounter.cpp.
| void TGraphEnumUtils::GetIndGraph | ( | const PNGraph & | G, |
| const TIntV & | sg, | ||
| PNGraph & | indG | ||
| ) | [static] |
Definition at line 251 of file graphcounter.cpp.
{
//Add nodes
for(int i=0; i<sg.Len(); i++) indG->AddNode(sg[i]);
//Add edges
for(int i=0; i<sg.Len(); i++) {
int nId = sg[i];
TNGraph::TNodeI nIt = G->GetNI(nId);
//
int deg = nIt.GetOutDeg();
for(int j=0; j<deg; j++) {
int dstId = nIt.GetNbrNId(j);
if(nId == dstId) continue;
//
if(indG->IsNode(dstId)) indG->AddEdge(nId, dstId);
}
}
}
| void TGraphEnumUtils::GetIsoGraphs | ( | uint64 | graphId, |
| int | nodes, | ||
| TVec< PNGraph > & | isoG | ||
| ) | [static] |
Definition at line 202 of file graphcounter.cpp.
{
TIntV v(nodes); for(int i=0; i<nodes; i++) v[i]=i;
TVec<TIntV> perms; GetPermutations(v, 0, perms);
isoG.Gen(perms.Len());
//
TVec<TPair<int,int> > edges;
GetEdges(graphId, nodes, edges);
//
for(int i=0; i<perms.Len(); i++) {
isoG[i] = TNGraph::New();
//Add nodes
for(int j=0; j<nodes; j++) isoG[i]->AddNode(j);
//Add edges
for(int j=0; j<edges.Len(); j++) {
int srcId = edges[j].Val1;
int dstId = edges[j].Val2;
//
int pSrcId = perms[i][srcId];
int pDstId = perms[i][dstId];
//
isoG[i]->AddEdge(pSrcId, pDstId);
}
}
}
| void TGraphEnumUtils::GetIsoGraphs | ( | const PNGraph & | G, |
| TVec< PNGraph > & | isoG | ||
| ) | [static] |
Definition at line 227 of file graphcounter.cpp.
{
int nodes = G->GetNodes();
//
TIntV v(nodes); for(int i=0; i<nodes; i++) v[i]=i;
TVec<TIntV> perms; GetPermutations(v, 0, perms);
isoG.Gen(perms.Len());
//
for(int i=0; i<perms.Len(); i++) {
isoG[i] = TNGraph::New();
//Add nodes
for(int j=0; j<nodes; j++) isoG[i]->AddNode(j);
//Add edges
for(TNGraph::TEdgeI eIt=G->BegEI(); eIt<G->EndEI(); eIt++) {
int srcId = eIt.GetSrcNId();
int dstId = eIt.GetDstNId();
//
int pSrcId = perms[i][srcId];
int pDstId = perms[i][dstId];
//
isoG[i]->AddEdge(pSrcId, pDstId);
}
}
}
| uint64 TGraphEnumUtils::GetMinAndGraphIds | ( | const TVec< PNGraph > & | isoG, |
| TVec< uint64 > & | graphIds | ||
| ) | [static] |
Definition at line 311 of file graphcounter.cpp.
| void TGraphEnumUtils::GetNormalizedGraph | ( | const PNGraph & | G, |
| PNGraph & | nG | ||
| ) | [static] |
Definition at line 172 of file graphcounter.cpp.
{
//Get bijective map from original node ids to normalized node ids(0,1,2,...)
THash<TInt,TInt> map;
GetNormalizedMap(G, map);
//Add nodes
for(int i=0; i<G->GetNodes(); i++) nG->AddNode(i);
//Add edges
for(TNGraph::TEdgeI eIt=G->BegEI(); eIt<G->EndEI(); eIt++) {
int srcId = eIt.GetSrcNId();
int dstId = eIt.GetDstNId();
//
int mSrcId = map.GetDat(srcId);
int mDstId = map.GetDat(dstId);
//
nG->AddEdge(mSrcId, mDstId);
}
}
| void TGraphEnumUtils::GetNormalizedMap | ( | const PNGraph & | G, |
| THash< TInt, TInt > & | map | ||
| ) | [static, private] |
Definition at line 147 of file graphcounter.cpp.
{
int nId=0;
for(TNGraph::TNodeI it=G->BegNI(); it<G->EndNI(); it++) {
//printf("%d -> %d\n", it.GetId(), nId);
map.AddDat(it.GetId(), nId);
nId++;
}
}
| void TGraphEnumUtils::GetPermutations | ( | TIntV & | v, |
| int | start, | ||
| TVec< TIntV > & | perms | ||
| ) | [static, private] |
Definition at line 156 of file graphcounter.cpp.
{
int n = v.Len();
if (start == n-1) perms.Add(v);
else {
for (int i = start; i < n; i++) {
int tmp = v[i];
v[i] = v[start];
v[start] = tmp;
GetPermutations(v, start+1, perms);
//
v[start] = v[i];
v[i] = tmp;
}
}
}
| uint64 TGraphEnumUtils::GraphId | ( | const PNGraph & | G | ) | [static] |
Definition at line 285 of file graphcounter.cpp.
{
int nodes = G->GetNodes();
uint64 id=0;
for(TNGraph::TEdgeI it=G->BegEI(); it<G->EndEI(); it++) {
int srcId = it.GetSrcNId();
int dstId = it.GetDstNId();
//
id += TMath::Pow2(srcId*nodes + dstId);
}
//
return id;
}
| uint64 TGraphEnumUtils::GraphId | ( | const PNGraph & | G, |
| const TIntV & | sg | ||
| ) | [static] |
Definition at line 298 of file graphcounter.cpp.
{
int nodes = sg.Len();
uint64 graphId = 0;
for(int i=0; i<nodes; i++) {
for(int j=0; j<nodes; j++) {
if(i==j) continue;
//
if(TGraphEnumUtils::IsEdge(G, sg[i], sg[j])) graphId+=TMath::Pow2(i*nodes + j);
}
}
return graphId;
}
| static bool TGraphEnumUtils::IsEdge | ( | const PNGraph & | G, |
| int | SrcNId, | ||
| int | DstNId | ||
| ) | [inline, static] |
Definition at line 84 of file graphcounter.h.
{
// JURE return G->GetNodeC(SrcNId).IsOutNId(DstNId);
return G->IsEdge(SrcNId, DstNId, true);
}