SNAP Library 4.1, Developer Reference  2018-07-26 16:30:42
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
TSnap::TSnapDetail::TConvertSubGraph< POutGraph, PInGraph, false > Struct Template Reference

#include <subgraph.h>

Static Public Member Functions

static POutGraph Do (const PInGraph &InGraph, const TIntV &NIdV, const bool &RenumberNodes)
 

Detailed Description

template<class POutGraph, class PInGraph>
struct TSnap::TSnapDetail::TConvertSubGraph< POutGraph, PInGraph, false >

Definition at line 372 of file subgraph.h.

Member Function Documentation

template<class POutGraph , class PInGraph >
static POutGraph TSnap::TSnapDetail::TConvertSubGraph< POutGraph, PInGraph, false >::Do ( const PInGraph &  InGraph,
const TIntV NIdV,
const bool &  RenumberNodes 
)
inlinestatic

Definition at line 373 of file subgraph.h.

References THashSet< TKey, THashFunc >::AddKey(), and TVec< TVal, TSizeTy >::Len().

373  {
374  POutGraph OutGraphPt = POutGraph::TObj::New();
375  typename POutGraph::TObj& OutGraph = *OutGraphPt;
376  if (! RenumberNodes) {
377  for (int n = 0; n < NIdV.Len(); n++) {
378  OutGraph.AddNode(NIdV[n]); }
379  for (int n = 0; n < NIdV.Len(); n++) {
380  typename PInGraph::TObj::TNodeI NI = InGraph->GetNI(NIdV[n]);
381  for (int e = 0; e < NI.GetOutDeg(); e++) {
382  const int dst = NI.GetOutNId(e);
383  if (! OutGraph.IsNode(dst)) { continue; }
384  OutGraph.AddEdge(NIdV[n], dst);
385  }
386  }
387  } else { // renumber nodes so that node ids are 0...N-1
388  TIntSet NIdSet(InGraph->GetNodes());
389  for (int n = 0; n < NIdV.Len(); n++) {
390  const int NId = NIdSet.AddKey(NIdV[n]);
391  OutGraph.AddNode(NId);
392  }
393  for (int n = 0; n < NIdV.Len(); n++) {
394  typename PInGraph::TObj::TNodeI NI = InGraph->GetNI(NIdV[n]);
395  const int src = NIdSet.GetKey(NIdV[n]);
396  for (int e = 0; e < NI.GetOutDeg(); e++) {
397  const int dst = NIdSet.GetKey(NI.GetOutNId(e));
398  if (! OutGraph.IsNode(dst)) { continue; }
399  OutGraph.AddEdge(src, dst);
400  }
401  }
402  }
403  OutGraph.Defrag();
404  return OutGraphPt;
405  }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
int AddKey(const TKey &Key)
Definition: shash.h:1254

Here is the call graph for this function:


The documentation for this struct was generated from the following file: