SNAP Library 6.0, Developer Reference
2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
Small Directed Graphs. More...
#include <ghash.h>
Public Member Functions | |
TGraphKey () | |
TGraphKey (const TSFltV &GraphSigV) | |
TGraphKey (const TIntV &GraphSigV) | |
TGraphKey (const TFltV &GraphSigV) | |
TGraphKey (const TGraphKey &GraphKey) | |
TGraphKey (TSIn &SIn) | |
void | Save (TSOut &SOut) const |
TGraphKey & | operator= (const TGraphKey &GraphKey) |
bool | operator== (const TGraphKey &GraphKey) const |
int | GetPrimHashCd () const |
int | GetSecHashCd () const |
int | GetNodes () const |
Returns the number of nodes in the graph. More... | |
int | GetEdges () const |
Returns the number of edges in the graph. More... | |
int | GetSigLen () const |
Returns the length of the signature vector of a graph. More... | |
int | GetVariant () const |
Returns the graph variant Id. More... | |
void | SetVariant (const int &Variant) |
Sets the Variant Id of a given graph. More... | |
void | SetEdgeV (const TIntPrV &EdgeIdV) |
Returns a vector of directed edges of a graph. More... | |
PNGraph | GetNGraph () const |
Returns the directed graph stored in the GraphKey object. More... | |
void | TakeGraph (const PNGraph &Graph) |
Creates a key from a given directed graph. More... | |
void | TakeGraph (const PNGraph &Graph, TIntPrV &NodeMap) |
Creates a key from a given directed graph. More... | |
void | TakeSig (const PNGraph &Graph, const int &MnSvdGraph, const int &MxSvdGraph) |
Creates a signature for a given directed graph. More... | |
void | SaveTxt (FILE *F) const |
Saves the graph as a list of edges. More... | |
void | SaveGViz (const TStr &OutFNm, const TStr &Desc=TStr(), const TStr &NodeAttrs="", const int &Size=-1) const |
Saves the graph to the .DOT file format used by GraphViz. More... | |
void | DrawGViz (const TStr &OutFNm, const TStr &Desc=TStr(), const TStr &NodeAttrs="", const int &Size=-1) const |
Saves the graph to the .DOT file format and calls GraphViz to draw it. More... | |
Static Public Member Functions | |
static bool | IsIsomorph (const TGraphKey &Key1, const TGraphKey &Key2, const TIntV &NodeIdMap) |
Checks whether directed graph Key1 is isomorphic to the directed graph Key2 under node Id permutation NodeIdMap. More... | |
static bool | IsIsomorph (const TGraphKey &Key1, const TGraphKey &Key2, const TVec< TIntV > &NodeIdMapV) |
Checks whether directed graph Key1 is isomorphic to the directed graph Key2 under all the permutations of node Ids stored in NodeIdMapV. More... | |
static bool | IsIsomorph (const TGraphKey &Key1, const TGraphKey &Key2, const TVec< TIntV > &NodeIdMapV, int &IsoPermId) |
Checks whether directed graph Key1 is isomorphic to the directed graph Key2 under all the permutations of node Ids stored in NodeIdMapV and returns the Id of the permutation of node Ids (IsoPermId) which makes the two graphs isomorphic. More... | |
Public Attributes | |
TInt | Nodes |
TIntPrV | EdgeV |
TFltV | SigV |
TInt | VariantId |
Static Public Attributes | |
static const int | RoundTo = 4 |
Small Directed Graphs.
These graphs are used as keys of the TGHash graph hash table. The main functionality of TGraphKey is that it performs fast graph isomorphism checking to determine whether two graphs (two keys) are the same (i.e., isomorphic).
TGraphKey::TGraphKey | ( | const TSFltV & | GraphSigV | ) |
Definition at line 5 of file ghash.cpp.
References TVec< TVal, TSizeTy >::Gen(), TVec< TVal, TSizeTy >::Len(), TMath::Round(), RoundTo, and SigV.
TGraphKey::TGraphKey | ( | const TIntV & | GraphSigV | ) |
Definition at line 12 of file ghash.cpp.
References TVec< TVal, TSizeTy >::Gen(), TVec< TVal, TSizeTy >::Len(), and SigV.
TGraphKey::TGraphKey | ( | const TFltV & | GraphSigV | ) |
Definition at line 19 of file ghash.cpp.
References TVec< TVal, TSizeTy >::Gen(), TVec< TVal, TSizeTy >::Len(), TMath::Round(), RoundTo, and SigV.
void TGraphKey::DrawGViz | ( | const TStr & | OutFNm, |
const TStr & | Desc = TStr() , |
||
const TStr & | NodeAttrs = "" , |
||
const int & | Size = -1 |
||
) | const |
Saves the graph to the .DOT file format and calls GraphViz to draw it.
Output type is determined by the OutFNm file extension (.ps, .png).
Definition at line 180 of file ghash.cpp.
References TStr::GetFMid(), TSnap::TSnapDetail::GVizDoLayout(), gvlDot, and SaveGViz().
|
inline |
Returns the number of edges in the graph.
Definition at line 33 of file ghash.h.
References TVec< TVal, TSizeTy >::Len().
Referenced by TGHash< TDat >::DrawGViz(), GetNGraph(), SaveGViz(), SaveTxt(), and TGHash< TDat >::SaveTxt().
PNGraph TGraphKey::GetNGraph | ( | ) | const |
Returns the directed graph stored in the GraphKey object.
Definition at line 47 of file ghash.cpp.
References TNGraph::AddEdge(), TNGraph::AddNode(), TNGraph::Defrag(), EdgeV, GetEdges(), GetNodes(), and TNGraph::New().
|
inline |
Returns the number of nodes in the graph.
Definition at line 31 of file ghash.h.
References Nodes.
Referenced by TGHash< TDat >::AddKey(), TGHash< TDat >::DrawGViz(), GetNGraph(), TGHash< TDat >::IsGetKeyId(), SaveGViz(), SaveTxt(), and TGHash< TDat >::SaveTxt().
|
inline |
Definition at line 27 of file ghash.h.
References TVec< TVal, TSizeTy >::GetPrimHashCd(), and VariantId.
|
inline |
Definition at line 28 of file ghash.h.
References TVec< TVal, TSizeTy >::GetSecHashCd().
|
inline |
Returns the length of the signature vector of a graph.
Signature is a set of statistics that is used to quickly determine whether the two graphs could be isomorphic. Graphs that differ in their signatures are guaranteed to be non-isomorphic while graphs with identical signatures could still be isomorphic.
Definition at line 40 of file ghash.h.
References TVec< TVal, TSizeTy >::Len().
|
inline |
|
static |
Checks whether directed graph Key1 is isomorphic to the directed graph Key2 under node Id permutation NodeIdMap.
The function does not consider all possible permutations (mappings) between node Ids but only considers mapping in NodeIdMap.
Definition at line 186 of file ghash.cpp.
References EdgeV, TVec< TVal, TSizeTy >::Len(), Nodes, and TVec< TVal, TSizeTy >::SearchBin().
Referenced by TGHash< TDat >::AddKey(), TGHash< TDat >::GetNodeMap(), TGHash< TDat >::IsGetKeyId(), and IsIsomorph().
|
static |
Checks whether directed graph Key1 is isomorphic to the directed graph Key2 under all the permutations of node Ids stored in NodeIdMapV.
Definition at line 197 of file ghash.cpp.
References IsIsomorph().
|
static |
Checks whether directed graph Key1 is isomorphic to the directed graph Key2 under all the permutations of node Ids stored in NodeIdMapV and returns the Id of the permutation of node Ids (IsoPermId) which makes the two graphs isomorphic.
Definition at line 202 of file ghash.cpp.
References EdgeV, TVec< TVal, TSizeTy >::Len(), and Nodes.
|
inline |
void TGraphKey::Save | ( | TSOut & | SOut | ) | const |
Definition at line 32 of file ghash.cpp.
References EdgeV, Nodes, TVec< TVal, TSizeTy >::Save(), TInt::Save(), SigV, and VariantId.
void TGraphKey::SaveGViz | ( | const TStr & | OutFNm, |
const TStr & | Desc = TStr() , |
||
const TStr & | NodeAttrs = "" , |
||
const int & | Size = -1 |
||
) | const |
Saves the graph to the .DOT file format used by GraphViz.
Use ".dot" as file extension for OutFNm.
Definition at line 154 of file ghash.cpp.
References TStr::CStr(), EdgeV, TStr::Empty(), TVec< TVal, TSizeTy >::Empty(), GetEdges(), GetNodes(), TVec< TVal, TSizeTy >::Len(), and Nodes.
Referenced by DrawGViz(), and TGHash< TDat >::DrawGViz().
void TGraphKey::SaveTxt | ( | FILE * | F | ) | const |
Saves the graph as a list of edges.
Definition at line 147 of file ghash.cpp.
References EdgeV, GetEdges(), GetNodes(), and TVec< TVal, TSizeTy >::Len().
|
inline |
|
inline |
Sets the Variant Id of a given graph.
Definition at line 47 of file ghash.h.
Referenced by TGHash< TDat >::AddKey(), TGHash< TDat >::GetNodeMap(), and TGHash< TDat >::IsGetKeyId().
void TGraphKey::TakeGraph | ( | const PNGraph & | Graph | ) |
Creates a key from a given directed graph.
Nodes get renumbered to have Ids 0...N-1. Does not create a graph signature.
Definition at line 58 of file ghash.cpp.
References TVec< TVal, TSizeTy >::Add(), THash< TKey, TDat, THashFunc >::AddKey(), TNGraph::BegNI(), EdgeV, TNGraph::EndNI(), TVec< TVal, TSizeTy >::Gen(), THash< TKey, TDat, THashFunc >::GetKeyId(), TNGraph::GetNodes(), Nodes, TVec< TVal, TSizeTy >::Pack(), and TVec< TVal, TSizeTy >::Sort().
Referenced by TGHash< TDat >::AddKey(), TGHash< TDat >::GetNodeMap(), and TGHash< TDat >::IsGetKeyId().
Creates a key from a given directed graph.
Parameter NodeMap stores the correspondence of old to new node Ids (0...N-1). Does not create a graph signature. Nodes are renumbered.
Definition at line 74 of file ghash.cpp.
References TVec< TVal, TSizeTy >::Add(), THashSet< TKey, THashFunc >::AddKey(), TNGraph::BegNI(), EdgeV, TNGraph::EndNI(), TVec< TVal, TSizeTy >::Gen(), THashSet< TKey, THashFunc >::GetKeyId(), TNGraph::GetNodes(), Nodes, TVec< TVal, TSizeTy >::Pack(), and TVec< TVal, TSizeTy >::Sort().
void TGraphKey::TakeSig | ( | const PNGraph & | Graph, |
const int & | MnSvdGraph, | ||
const int & | MxSvdGraph | ||
) |
Creates a signature for a given directed graph.
The function only creates the signature vector but does not copy the graph.
Definition at line 94 of file ghash.cpp.
References TVec< TVal, TSizeTy >::Add(), THash< TKey, TDat, THashFunc >::AddKey(), TVVec< TVal, TSizeTy >::At(), TNGraph::BegNI(), TNGraph::EndNI(), TVec< TVal, TSizeTy >::Gen(), TNGraph::GetEdges(), THash< TKey, TDat, THashFunc >::GetKeyId(), TNGraph::GetNodes(), TVec< TVal, TSizeTy >::Len(), Nodes, TVec< TVal, TSizeTy >::Pack(), TMath::Round(), RoundTo, SigV, TVec< TVal, TSizeTy >::Sort(), TSvd::Svd(), and VariantId.
Referenced by TGHash< TDat >::AddKey(), TGHash< TDat >::GetNodeMap(), and TGHash< TDat >::IsGetKeyId().
TIntPrV TGraphKey::EdgeV |
Definition at line 13 of file ghash.h.
Referenced by GetNGraph(), IsIsomorph(), operator=(), Save(), SaveGViz(), SaveTxt(), and TakeGraph().
TInt TGraphKey::Nodes |
Definition at line 12 of file ghash.h.
Referenced by GetNodes(), IsIsomorph(), operator=(), Save(), SaveGViz(), TakeGraph(), and TakeSig().
|
static |
Definition at line 9 of file ghash.h.
Referenced by TakeSig(), and TGraphKey().
TFltV TGraphKey::SigV |
Definition at line 14 of file ghash.h.
Referenced by operator=(), operator==(), Save(), TakeSig(), and TGraphKey().
TInt TGraphKey::VariantId |
Definition at line 15 of file ghash.h.
Referenced by GetPrimHashCd(), GetVariant(), operator=(), operator==(), Save(), and TakeSig().