SNAP Library 2.1, User Reference  2013-09-25 10:47:25
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
TSnap::TSnapDetail::TGetSubGraph< PGraph, IsMultiGraph > Struct Template Reference

#include <subgraph.h>

List of all members.

Static Public Member Functions

static PGraph Do (const PGraph &Graph, const TIntV &NIdV)

Detailed Description

template<class PGraph, bool IsMultiGraph>
struct TSnap::TSnapDetail::TGetSubGraph< PGraph, IsMultiGraph >

Definition at line 142 of file subgraph.h.


Member Function Documentation

template<class PGraph, bool IsMultiGraph>
static PGraph TSnap::TSnapDetail::TGetSubGraph< PGraph, IsMultiGraph >::Do ( const PGraph &  Graph,
const TIntV NIdV 
) [inline, static]

Definition at line 143 of file subgraph.h.

                                                           {
    PGraph NewGraphPt = PGraph::TObj::New();
    typename PGraph::TObj& NewGraph = *NewGraphPt;
    NewGraph.Reserve(NIdV.Len(), -1);
    for (int n = 0; n < NIdV.Len(); n++) {
      if (Graph->IsNode(NIdV[n])) {
        NewGraph.AddNode(Graph->GetNI(NIdV[n])); }
    }
    for (typename PGraph::TObj::TEdgeI EI = Graph->BegEI(); EI < Graph->EndEI(); EI++) {
      if (NewGraph.IsNode(EI.GetSrcNId()) && NewGraph.IsNode(EI.GetDstNId())) {
        NewGraph.AddEdge(EI); }
    }
    NewGraph.Defrag();
    return NewGraphPt;
  }

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