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
TUNGraphMtx Class Reference

#include <gsvd.h>

Inheritance diagram for TUNGraphMtx:
Collaboration diagram for TUNGraphMtx:

Public Member Functions

 TUNGraphMtx (const PUNGraph &GraphPt)
 
 TUNGraphMtx (const TUNGraphMtx &GraphMtx)
 
TUNGraphMtxoperator= (const TUNGraphMtx &GraphMtx)
 
int PGetRows () const
 
int PGetCols () const
 
void PMultiply (const TFltVV &B, int ColId, TFltV &Result) const
 
void PMultiply (const TFltV &Vec, TFltV &Result) const
 
void PMultiplyT (const TFltVV &B, int ColId, TFltV &Result) const
 
void PMultiplyT (const TFltV &Vec, TFltV &Result) const
 
- Public Member Functions inherited from TMatrix
 TMatrix ()
 
virtual ~TMatrix ()
 
void Multiply (const TFltVV &B, int ColId, TFltV &Result) const
 
void Multiply (const TFltV &Vec, TFltV &Result) const
 
void MultiplyT (const TFltVV &B, int ColId, TFltV &Result) const
 
void MultiplyT (const TFltV &Vec, TFltV &Result) const
 
int GetRows () const
 
int GetCols () const
 
void Transpose ()
 

Private Member Functions

bool CheckNodeIds ()
 

Private Attributes

PUNGraph Graph
 

Additional Inherited Members

Detailed Description

Undirected Graph Adjacency Matrix represented as sparse {0,1} row matrix. The class is used for computing spectral properties of graph adjacency matrices. The class assumes that node IDs have the range 0...Nodes-1.

Definition at line 29 of file gsvd.h.

Constructor & Destructor Documentation

TUNGraphMtx::TUNGraphMtx ( const PUNGraph GraphPt)

Definition at line 83 of file gsvd.cpp.

References CheckNodeIds(), TUNGraph::GetNodes(), and Graph.

83  : Graph() {
84  Graph = GraphPt;
85  if (! CheckNodeIds()) {
86  printf(" Renumbering %d nodes....", GraphPt->GetNodes());
87  TExeTm ExeTm;
88  Graph = TSnap::ConvertGraph<PUNGraph>(GraphPt, true);
89  /*TIntSet NIdSet;
90  for (TUNGraph::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++) {
91  NIdSet.AddKey(NI.GetId());
92  }
93  Graph = TUNGraph::New(); *Graph = *GraphPt; */
94  printf("done [%s]\n", ExeTm.GetStr());
95  }
96 }
Definition: tm.h:355
PUNGraph Graph
Definition: gsvd.h:31
bool CheckNodeIds()
Definition: gsvd.cpp:76

Here is the call graph for this function:

TUNGraphMtx::TUNGraphMtx ( const TUNGraphMtx GraphMtx)
inline

Definition at line 35 of file gsvd.h.

35 : Graph(GraphMtx.Graph) { }
PUNGraph Graph
Definition: gsvd.h:31

Member Function Documentation

bool TUNGraphMtx::CheckNodeIds ( )
private

Definition at line 76 of file gsvd.cpp.

References TUNGraph::GetNodes(), Graph, and TUNGraph::IsNode().

Referenced by TUNGraphMtx().

76  {
77  for (int NId = 0; NId < Graph->GetNodes(); NId++) {
78  if (! Graph->IsNode(NId)) { return false; }
79  }
80  return true;
81 }
int GetNodes() const
Returns the number of nodes in the graph.
Definition: graph.h:192
PUNGraph Graph
Definition: gsvd.h:31
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: graph.h:235

Here is the call graph for this function:

Here is the caller graph for this function:

TUNGraphMtx& TUNGraphMtx::operator= ( const TUNGraphMtx GraphMtx)
inline

Definition at line 36 of file gsvd.h.

References Graph.

36 { Graph=GraphMtx.Graph; return *this; }
PUNGraph Graph
Definition: gsvd.h:31
int TUNGraphMtx::PGetCols ( ) const
inlinevirtual

Implements TMatrix.

Definition at line 38 of file gsvd.h.

References TUNGraph::GetNodes(), and Graph.

38 { return Graph->GetNodes(); }
int GetNodes() const
Returns the number of nodes in the graph.
Definition: graph.h:192
PUNGraph Graph
Definition: gsvd.h:31

Here is the call graph for this function:

int TUNGraphMtx::PGetRows ( ) const
inlinevirtual

Implements TMatrix.

Definition at line 37 of file gsvd.h.

References TUNGraph::GetNodes(), and Graph.

37 { return Graph->GetNodes(); }
int GetNodes() const
Returns the number of nodes in the graph.
Definition: graph.h:192
PUNGraph Graph
Definition: gsvd.h:31

Here is the call graph for this function:

void TUNGraphMtx::PMultiply ( const TFltVV B,
int  ColId,
TFltV Result 
) const
virtual

Implements TMatrix.

Definition at line 99 of file gsvd.cpp.

References Assert, TMatrix::GetRows(), TVVec< TVal, TSizeTy >::GetRows(), Graph, TVec< TVal, TSizeTy >::Len(), and TUNGraph::NodeH.

99  {
100  const int RowN = GetRows();
101  Assert(B.GetRows() >= RowN && Result.Len() >= RowN);
102  const THash<TInt, TUNGraph::TNode>& NodeH = Graph->NodeH;
103  for (int j = 0; j < RowN; j++) {
104  const TIntV& RowV = NodeH[j].NIdV;
105  Result[j] = 0.0;
106  for (int i = 0; i < RowV.Len(); i++) {
107  Result[j] += B(RowV[i], ColId);
108  }
109  }
110 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
int GetRows() const
Definition: linalg.h:45
#define Assert(Cond)
Definition: bd.h:251
PUNGraph Graph
Definition: gsvd.h:31
TSizeTy GetRows() const
Definition: ds.h:2251
THash< TInt, TNode > NodeH
Definition: graph.h:145

Here is the call graph for this function:

void TUNGraphMtx::PMultiply ( const TFltV Vec,
TFltV Result 
) const
virtual

Implements TMatrix.

Definition at line 113 of file gsvd.cpp.

References Assert, TMatrix::GetRows(), Graph, TVec< TVal, TSizeTy >::Len(), and TUNGraph::NodeH.

113  {
114  const int RowN = GetRows();
115  Assert(Vec.Len() >= RowN && Result.Len() >= RowN);
116  const THash<TInt, TUNGraph::TNode>& NodeH = Graph->NodeH;
117  for (int j = 0; j < RowN; j++) {
118  const TIntV& RowV = NodeH[j].NIdV;
119  Result[j] = 0.0;
120  for (int i = 0; i < RowV.Len(); i++) {
121  Result[j] += Vec[RowV[i]];
122  }
123  }
124 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
int GetRows() const
Definition: linalg.h:45
#define Assert(Cond)
Definition: bd.h:251
PUNGraph Graph
Definition: gsvd.h:31
THash< TInt, TNode > NodeH
Definition: graph.h:145

Here is the call graph for this function:

void TUNGraphMtx::PMultiplyT ( const TFltVV B,
int  ColId,
TFltV Result 
) const
virtual

Implements TMatrix.

Definition at line 127 of file gsvd.cpp.

References Assert, TMatrix::GetCols(), TVVec< TVal, TSizeTy >::GetRows(), Graph, TVec< TVal, TSizeTy >::Len(), and TUNGraph::NodeH.

127  {
128  const int ColN = GetCols();
129  Assert(B.GetRows() >= ColN && Result.Len() >= ColN);
130  const THash<TInt, TUNGraph::TNode>& NodeH = Graph->NodeH;
131  for (int i = 0; i < ColN; i++) Result[i] = 0.0;
132  for (int j = 0; j < ColN; j++) {
133  const TIntV& RowV = NodeH[j].NIdV;
134  for (int i = 0; i < RowV.Len(); i++) {
135  Result[RowV[i]] += B(j, ColId);
136  }
137  }
138 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
#define Assert(Cond)
Definition: bd.h:251
int GetCols() const
Definition: linalg.h:47
PUNGraph Graph
Definition: gsvd.h:31
TSizeTy GetRows() const
Definition: ds.h:2251
THash< TInt, TNode > NodeH
Definition: graph.h:145

Here is the call graph for this function:

void TUNGraphMtx::PMultiplyT ( const TFltV Vec,
TFltV Result 
) const
virtual

Implements TMatrix.

Definition at line 141 of file gsvd.cpp.

References Assert, TMatrix::GetRows(), Graph, TVec< TVal, TSizeTy >::Len(), and TUNGraph::NodeH.

141  {
142  const int RowN = GetRows();
143  Assert(Vec.Len() >= RowN && Result.Len() >= RowN);
144  const THash<TInt, TUNGraph::TNode>& NodeH = Graph->NodeH;
145  for (int i = 0; i < RowN; i++) Result[i] = 0.0;
146  for (int j = 0; j < RowN; j++) {
147  const TIntV& RowV = NodeH[j].NIdV;
148  for (int i = 0; i < RowV.Len(); i++) {
149  Result[RowV[i]] += Vec[j];
150  }
151  }
152 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
int GetRows() const
Definition: linalg.h:45
#define Assert(Cond)
Definition: bd.h:251
PUNGraph Graph
Definition: gsvd.h:31
THash< TInt, TNode > NodeH
Definition: graph.h:145

Here is the call graph for this function:

Member Data Documentation

PUNGraph TUNGraphMtx::Graph
private

Definition at line 31 of file gsvd.h.

Referenced by CheckNodeIds(), operator=(), PGetCols(), PGetRows(), PMultiply(), PMultiplyT(), and TUNGraphMtx().


The documentation for this class was generated from the following files: