SNAP Library 2.0, Developer Reference  2013-05-13 16:33:57
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TNGraphMtx Class Reference

#include <gsvd.h>

Inheritance diagram for TNGraphMtx:
Collaboration diagram for TNGraphMtx:

List of all members.

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

Private Member Functions

bool CheckNodeIds ()

Private Attributes

PNGraph Graph

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.

References CheckNodeIds(), and Graph.

                                             : Graph() { 
  Graph = GraphPt;
  if (! CheckNodeIds()) {
    printf("  Renumbering nodes.\n");
    Graph = TSnap::ConvertGraph<PNGraph>(GraphPt, true);
  }
}

Here is the call graph for this function:

TNGraphMtx::TNGraphMtx ( const TNGraphMtx GraphMtx) [inline]

Definition at line 11 of file gsvd.h.

: Graph(GraphMtx.Graph) { }

Member Function Documentation

bool TNGraphMtx::CheckNodeIds ( ) [private]

Definition at line 3 of file gsvd.cpp.

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

Referenced by TNGraphMtx().

                              {
  for (int NId = 0; NId < Graph->GetNodes(); NId++) {
    if (! Graph->IsNode(NId)) { return false; }
  }
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

TNGraphMtx& TNGraphMtx::operator= ( const TNGraphMtx GraphMtx) [inline]

Definition at line 12 of file gsvd.h.

References Graph.

{ Graph=GraphMtx.Graph;  return *this; }
int TNGraphMtx::PGetCols ( ) const [inline, virtual]

Implements TMatrix.

Definition at line 14 of file gsvd.h.

References TNGraph::GetNodes(), and Graph.

{ return Graph->GetNodes(); }

Here is the call graph for this function:

int TNGraphMtx::PGetRows ( ) const [inline, virtual]

Implements TMatrix.

Definition at line 13 of file gsvd.h.

References TNGraph::GetNodes(), and Graph.

{ return Graph->GetNodes(); }

Here is the call graph for this function:

void TNGraphMtx::PMultiply ( const TFltVV B,
int  ColId,
TFltV Result 
) const [virtual]

Implements TMatrix.

Definition at line 19 of file gsvd.cpp.

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

                                                                          {
  const int RowN = GetRows();
  Assert(B.GetRows() >= RowN && Result.Len() >= RowN);
  const THash<TInt, TNGraph::TNode>& NodeH = Graph->NodeH;
  for (int j = 0; j < RowN; j++) {
    const TIntV& RowV = NodeH[j].OutNIdV;
    Result[j] = 0.0;
    for (int i = 0; i < RowV.Len(); i++) {
      Result[j] += B(RowV[i], ColId);
    }
  }
}

Here is the call graph for this function:

void TNGraphMtx::PMultiply ( const TFltV Vec,
TFltV Result 
) const [virtual]

Implements TMatrix.

Definition at line 33 of file gsvd.cpp.

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

                                                                {
  const int RowN = GetRows();
  Assert(Vec.Len() >= RowN && Result.Len() >= RowN);
  const THash<TInt, TNGraph::TNode>& NodeH = Graph->NodeH;
  for (int j = 0; j < RowN; j++) {
    const TIntV& RowV = NodeH[j].OutNIdV;
    Result[j] = 0.0;
    for (int i = 0; i < RowV.Len(); i++) {
      Result[j] += Vec[RowV[i]];
    }
  }
}

Here is the call graph for this function:

void TNGraphMtx::PMultiplyT ( const TFltVV B,
int  ColId,
TFltV Result 
) const [virtual]

Implements TMatrix.

Definition at line 47 of file gsvd.cpp.

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

                                                                           {
  const int ColN = GetCols();
  Assert(B.GetRows() >= ColN && Result.Len() >= ColN);
  const THash<TInt, TNGraph::TNode>& NodeH = Graph->NodeH;
  for (int i = 0; i < ColN; i++) Result[i] = 0.0;
  for (int j = 0; j < ColN; j++) {
    const TIntV& RowV = NodeH[j].OutNIdV;
    for (int i = 0; i < RowV.Len(); i++) {
      Result[RowV[i]] += B(j, ColId);
    }
  }
}

Here is the call graph for this function:

void TNGraphMtx::PMultiplyT ( const TFltV Vec,
TFltV Result 
) const [virtual]

Implements TMatrix.

Definition at line 61 of file gsvd.cpp.

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

                                                                 {
  const int RowN = GetRows();
  Assert(Vec.Len() >= RowN && Result.Len() >= RowN);
  const THash<TInt, TNGraph::TNode>& NodeH = Graph->NodeH;
  for (int i = 0; i < RowN; i++) Result[i] = 0.0;
  for (int j = 0; j < RowN; j++) {
    const TIntV& RowV = NodeH[j].OutNIdV;
    for (int i = 0; i < RowV.Len(); i++) {
      Result[RowV[i]] += Vec[j];
    }
  }
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 7 of file gsvd.h.

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


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