SNAP Library 3.0, User Reference  2016-07-20 17:56:49
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
TNGraphMtx Class Reference

#include <gsvd.h>

Inherits TMatrix.

Public Member Functions

 TNGraphMtx (const PNGraph &GraphPt)
 
 TNGraphMtx (const TNGraphMtx &GraphMtx)
 
TNGraphMtxoperator= (const TNGraphMtx &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

PNGraph Graph
 

Additional Inherited Members

Detailed Description

Directed 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 5 of file gsvd.h.

Constructor & Destructor Documentation

TNGraphMtx::TNGraphMtx ( const PNGraph GraphPt)

Definition at line 10 of file gsvd.cpp.

10  : Graph() {
11  Graph = GraphPt;
12  if (! CheckNodeIds()) {
13  printf(" Renumbering nodes.\n");
14  Graph = TSnap::ConvertGraph<PNGraph>(GraphPt, true);
15  }
16 }
PNGraph Graph
Definition: gsvd.h:7
bool CheckNodeIds()
Definition: gsvd.cpp:3
TNGraphMtx::TNGraphMtx ( const TNGraphMtx GraphMtx)
inline

Definition at line 11 of file gsvd.h.

11 : Graph(GraphMtx.Graph) { }
PNGraph Graph
Definition: gsvd.h:7

Member Function Documentation

bool TNGraphMtx::CheckNodeIds ( )
private

Definition at line 3 of file gsvd.cpp.

3  {
4  for (int NId = 0; NId < Graph->GetNodes(); NId++) {
5  if (! Graph->IsNode(NId)) { return false; }
6  }
7  return true;
8 }
int GetNodes() const
Returns the number of nodes in the graph.
Definition: graph.h:438
PNGraph Graph
Definition: gsvd.h:7
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: graph.h:477
TNGraphMtx& TNGraphMtx::operator= ( const TNGraphMtx GraphMtx)
inline

Definition at line 12 of file gsvd.h.

12 { Graph=GraphMtx.Graph; return *this; }
PNGraph Graph
Definition: gsvd.h:7
int TNGraphMtx::PGetCols ( ) const
inlinevirtual

Implements TMatrix.

Definition at line 14 of file gsvd.h.

14 { return Graph->GetNodes(); }
int GetNodes() const
Returns the number of nodes in the graph.
Definition: graph.h:438
PNGraph Graph
Definition: gsvd.h:7
int TNGraphMtx::PGetRows ( ) const
inlinevirtual

Implements TMatrix.

Definition at line 13 of file gsvd.h.

13 { return Graph->GetNodes(); }
int GetNodes() const
Returns the number of nodes in the graph.
Definition: graph.h:438
PNGraph Graph
Definition: gsvd.h:7
void TNGraphMtx::PMultiply ( const TFltVV B,
int  ColId,
TFltV Result 
) const
virtual

Implements TMatrix.

Definition at line 19 of file gsvd.cpp.

19  {
20  const int RowN = GetRows();
21  Assert(B.GetRows() >= RowN && Result.Len() >= RowN);
22  const THash<TInt, TNGraph::TNode>& NodeH = Graph->NodeH;
23  for (int j = 0; j < RowN; j++) {
24  const TIntV& RowV = NodeH[j].OutNIdV;
25  Result[j] = 0.0;
26  for (int i = 0; i < RowV.Len(); i++) {
27  Result[j] += B(RowV[i], ColId);
28  }
29  }
30 }
THash< TInt, TNode > NodeH
Definition: graph.h:411
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:547
int GetRows() const
Definition: linalg.h:45
PNGraph Graph
Definition: gsvd.h:7
#define Assert(Cond)
Definition: bd.h:251
int GetRows() const
Definition: ds.h:2186
void TNGraphMtx::PMultiply ( const TFltV Vec,
TFltV Result 
) const
virtual

Implements TMatrix.

Definition at line 33 of file gsvd.cpp.

33  {
34  const int RowN = GetRows();
35  Assert(Vec.Len() >= RowN && Result.Len() >= RowN);
36  const THash<TInt, TNGraph::TNode>& NodeH = Graph->NodeH;
37  for (int j = 0; j < RowN; j++) {
38  const TIntV& RowV = NodeH[j].OutNIdV;
39  Result[j] = 0.0;
40  for (int i = 0; i < RowV.Len(); i++) {
41  Result[j] += Vec[RowV[i]];
42  }
43  }
44 }
THash< TInt, TNode > NodeH
Definition: graph.h:411
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:547
int GetRows() const
Definition: linalg.h:45
PNGraph Graph
Definition: gsvd.h:7
#define Assert(Cond)
Definition: bd.h:251
void TNGraphMtx::PMultiplyT ( const TFltVV B,
int  ColId,
TFltV Result 
) const
virtual

Implements TMatrix.

Definition at line 47 of file gsvd.cpp.

47  {
48  const int ColN = GetCols();
49  Assert(B.GetRows() >= ColN && Result.Len() >= ColN);
50  const THash<TInt, TNGraph::TNode>& NodeH = Graph->NodeH;
51  for (int i = 0; i < ColN; i++) Result[i] = 0.0;
52  for (int j = 0; j < ColN; j++) {
53  const TIntV& RowV = NodeH[j].OutNIdV;
54  for (int i = 0; i < RowV.Len(); i++) {
55  Result[RowV[i]] += B(j, ColId);
56  }
57  }
58 }
THash< TInt, TNode > NodeH
Definition: graph.h:411
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:547
PNGraph Graph
Definition: gsvd.h:7
#define Assert(Cond)
Definition: bd.h:251
int GetCols() const
Definition: linalg.h:47
int GetRows() const
Definition: ds.h:2186
void TNGraphMtx::PMultiplyT ( const TFltV Vec,
TFltV Result 
) const
virtual

Implements TMatrix.

Definition at line 61 of file gsvd.cpp.

61  {
62  const int RowN = GetRows();
63  Assert(Vec.Len() >= RowN && Result.Len() >= RowN);
64  const THash<TInt, TNGraph::TNode>& NodeH = Graph->NodeH;
65  for (int i = 0; i < RowN; i++) Result[i] = 0.0;
66  for (int j = 0; j < RowN; j++) {
67  const TIntV& RowV = NodeH[j].OutNIdV;
68  for (int i = 0; i < RowV.Len(); i++) {
69  Result[RowV[i]] += Vec[j];
70  }
71  }
72 }
THash< TInt, TNode > NodeH
Definition: graph.h:411
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:547
int GetRows() const
Definition: linalg.h:45
PNGraph Graph
Definition: gsvd.h:7
#define Assert(Cond)
Definition: bd.h:251

Member Data Documentation

PNGraph TNGraphMtx::Graph
private

Definition at line 7 of file gsvd.h.


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