SNAP Library 4.0, Developer Reference  2017-07-27 13:18:06
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
graphcounter.h
Go to the documentation of this file.
1 #ifndef Snap_GraphCounter
2 #define Snap_GraphCounter
3 
4 #include "Snap.h"
5 
7 // Directed 3 or 4 graph counter
9 public:
10  TD34GraphCounter(int GraphSz); // IAssert(GraphSz==3 || GraphSz==4);
11 public:
12  void operator()(const PNGraph &G, const TIntV &sg);
13  //THash<TInt,TUInt64> &GraphCounters() { return m_graphCounters; }
14  int Len() const { return m_graphCounters.Len(); }
15  int GetId(const int& i) const { return m_graphCounters.GetKey(i); }
16  uint64 GetCnt(const int& GraphId) const { return m_graphCounters.GetDat(GraphId); }
17  PNGraph GetGraph(const int& GraphId) const;
18 private:
22 };
23 
25 // Directed graph counter
27 public:
28  void operator()(const PNGraph &G, const TIntV &sg);
30 private:
33 };
34 
36 // Directed ghash graph counter
38 public:
40 public:
41  void operator()(const PNGraph &G, const TIntV &sg);
43 private:
45 };
46 
48 // Directed 3 graph
49 class TD3Graph {
50 public:
51  static inline int getId(const PNGraph &G, const TIntV &sg);
52 public:
53  static int m_numOfGraphs;
54  static int m_graphIds[];
55 };
56 
58 // Directed 4 graph
59 class TD4Graph {
60 public:
61  static inline int getId(const PNGraph &G, const TIntV &sg);
62 public:
63  static int m_numOfGraphs;
64  static int m_graphIds[];
65 };
66 
68 // TSNodeTest
69 class TSNodeTest{
70 public:
71  void operator()(const PNGraph &G, const TIntV &sg) {
72  for(int i=0; i<sg.Len(); i++) printf("%d, ", sg[i].Val);
73  printf("\n");
74  }
75 };
76 
78 // TGraphEnumUtils
80 private:
81  static void GetNormalizedMap(const PNGraph &G, THash<TInt,TInt> &map);
82  static void GetPermutations(TIntV &v, int start, TVec<TIntV> &perms);
83 public:
84  static inline bool IsEdge(const PNGraph &G, int SrcNId, int DstNId) {
85  // JURE return G->GetNodeC(SrcNId).IsOutNId(DstNId);
86  return G->IsEdge(SrcNId, DstNId, true);
87  }
88  static void GetEdges(uint64 graphId, int nodes, TVec<TPair<int,int> > &edges);
89 public:
90  static void GetNormalizedGraph(const PNGraph &G, PNGraph &nG);
91  static void GetIndGraph(const PNGraph &G, const TIntV &sg, PNGraph &indG);
92  static void GetGraph(uint64 graphId, int nodes, PNGraph &G);
93 public:
94  static void GetIsoGraphs(uint64 graphId, int nodes, TVec<PNGraph> &isoG);
95  static void GetIsoGraphs(const PNGraph &G, TVec<PNGraph> &isoG);
96 public:
97  static uint64 GraphId(const PNGraph &G);
98  static uint64 GraphId(const PNGraph &G, const TIntV &sg);
99  static uint64 GetMinAndGraphIds(const TVec<PNGraph> &isoG, TVec<uint64> &graphIds);
100 };
101 
102 #endif
THash< TUInt64, TUInt64 > m_graphMaps
Definition: graphcounter.h:31
int GetId(const int &i) const
Definition: graphcounter.h:15
uint64 GetCnt(const int &GraphId) const
Definition: graphcounter.h:16
THash< TUInt64, TUInt64 > m_graphCounters
Definition: graphcounter.h:32
void operator()(const PNGraph &G, const TIntV &sg)
Definition: graphcounter.h:71
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
static int m_graphIds[]
Definition: graphcounter.h:54
void operator()(const PNGraph &G, const TIntV &sg)
static void GetPermutations(TIntV &v, int start, TVec< TIntV > &perms)
static int getId(const PNGraph &G, const TIntV &sg)
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
void operator()(const PNGraph &G, const TIntV &sg)
TGHash< TUInt64 > & Graphs()
Definition: graphcounter.h:42
PNGraph GetGraph(const int &GraphId) const
THash< TUInt64, TUInt64 > & GraphCounters()
Definition: graphcounter.h:29
static int m_numOfGraphs
Definition: graphcounter.h:53
static void GetIsoGraphs(uint64 graphId, int nodes, TVec< PNGraph > &isoG)
static bool IsEdge(const PNGraph &G, int SrcNId, int DstNId)
Definition: graphcounter.h:84
static void GetNormalizedMap(const PNGraph &G, THash< TInt, TInt > &map)
unsigned long long uint64
Definition: bd.h:38
static uint64 GraphId(const PNGraph &G)
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 graph.
Definition: graph.cpp:363
static void GetEdges(uint64 graphId, int nodes, TVec< TPair< int, int > > &edges)
int Len() const
Definition: graphcounter.h:14
static int getId(const PNGraph &G, const TIntV &sg)
static void GetNormalizedGraph(const PNGraph &G, PNGraph &nG)
static int m_numOfGraphs
Definition: graphcounter.h:63
TGHash< TUInt64 > m_graphs
Definition: graphcounter.h:44
Definition: ds.h:32
static uint64 GetMinAndGraphIds(const TVec< PNGraph > &isoG, TVec< uint64 > &graphIds)
THash< TInt, TInt > m_graphMaps
Definition: graphcounter.h:19
THash< TInt, TUInt64 > m_graphCounters
Definition: graphcounter.h:20
static void GetIndGraph(const PNGraph &G, const TIntV &sg, PNGraph &indG)
void operator()(const PNGraph &G, const TIntV &sg)
static void GetGraph(uint64 graphId, int nodes, PNGraph &G)
int Len() const
Definition: hash.h:228
static int m_graphIds[]
Definition: graphcounter.h:64
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:252
TD34GraphCounter(int GraphSz)