SNAP Library , Developer Reference  2013-01-07 14:03:36
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
TUNGraphMtx Class Reference

#include <gsvd.h>

Inheritance diagram for TUNGraphMtx:
Collaboration diagram for TUNGraphMtx:

List of all members.

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

Private Member Functions

bool CheckNodeIds ()

Private Attributes

PUNGraph Graph

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.

                                                : Graph() { 
  Graph = GraphPt;
  if (! CheckNodeIds()) {
    printf("  Renumbering %d nodes....", GraphPt->GetNodes());
    TExeTm ExeTm;
    Graph = TSnap::ConvertGraph<PUNGraph>(GraphPt, true);
    /*TIntSet NIdSet;
    for (TUNGraph::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++) {
      NIdSet.AddKey(NI.GetId());
    }
    Graph = TUNGraph::New();  *Graph = *GraphPt; */
    printf("done [%s]\n", ExeTm.GetStr());
  }
}

Here is the call graph for this function:

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

Definition at line 35 of file gsvd.h.

: Graph(GraphMtx.Graph) { }

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().

                               {
  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:

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

Definition at line 36 of file gsvd.h.

References Graph.

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

Implements TMatrix.

Definition at line 38 of file gsvd.h.

References TUNGraph::GetNodes(), and Graph.

{ return Graph->GetNodes(); }

Here is the call graph for this function:

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

Implements TMatrix.

Definition at line 37 of file gsvd.h.

References TUNGraph::GetNodes(), and Graph.

{ return Graph->GetNodes(); }

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 >::GetRows(), Graph, TVec< TVal >::Len(), and TUNGraph::NodeH.

                                                                           {
  const int RowN = GetRows();
  Assert(B.GetRows() >= RowN && Result.Len() >= RowN);
  const THash<TInt, TUNGraph::TNode>& NodeH = Graph->NodeH;
  for (int j = 0; j < RowN; j++) {
    const TIntV& RowV = NodeH[j].NIdV;
    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 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 >::Len(), and TUNGraph::NodeH.

                                                                 {
  const int RowN = GetRows();
  Assert(Vec.Len() >= RowN && Result.Len() >= RowN);
  const THash<TInt, TUNGraph::TNode>& NodeH = Graph->NodeH;
  for (int j = 0; j < RowN; j++) {
    const TIntV& RowV = NodeH[j].NIdV;
    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 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 >::GetRows(), Graph, TVec< TVal >::Len(), and TUNGraph::NodeH.

                                                                            {
  const int ColN = GetCols();
  Assert(B.GetRows() >= ColN && Result.Len() >= ColN);
  const THash<TInt, TUNGraph::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].NIdV;
    for (int i = 0; i < RowV.Len(); i++) {
      Result[RowV[i]] += B(j, ColId);
    }
  }
}

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 >::Len(), and TUNGraph::NodeH.

                                                                  {
  const int RowN = GetRows();
  Assert(Vec.Len() >= RowN && Result.Len() >= RowN);
  const THash<TInt, TUNGraph::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].NIdV;
    for (int i = 0; i < RowV.Len(); i++) {
      Result[RowV[i]] += Vec[j];
    }
  }
}

Here is the call graph for this function:


Member Data Documentation


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