#include <subgraph.h>
|
static POutGraph | Do (const PInGraph &InGraph, const TIntV &NIdV, const bool &RenumberNodes) |
|
template<class POutGraph, class PInGraph>
struct TSnap::TSnapDetail::TConvertSubGraph< POutGraph, PInGraph, false >
Definition at line 397 of file subgraph.h.
template<class POutGraph , class PInGraph >
Definition at line 398 of file subgraph.h.
399 POutGraph OutGraphPt = POutGraph::TObj::New();
400 typename POutGraph::TObj& OutGraph = *OutGraphPt;
401 if (! RenumberNodes) {
402 for (
int n = 0; n < NIdV.
Len(); n++) {
403 OutGraph.AddNode(NIdV[n]); }
404 for (
int n = 0; n < NIdV.
Len(); n++) {
405 typename PInGraph::TObj::TNodeI NI = InGraph->GetNI(NIdV[n]);
406 for (
int e = 0; e < NI.GetOutDeg(); e++) {
407 const int dst = NI.GetOutNId(e);
408 if (! OutGraph.IsNode(dst)) {
continue; }
409 OutGraph.AddEdge(NIdV[n], dst);
413 TIntSet NIdSet(InGraph->GetNodes());
414 for (
int n = 0; n < NIdV.
Len(); n++) {
415 const int NId = NIdSet.
AddKey(NIdV[n]);
416 OutGraph.AddNode(NId);
418 for (
int n = 0; n < NIdV.
Len(); n++) {
419 typename PInGraph::TObj::TNodeI NI = InGraph->GetNI(NIdV[n]);
420 const int src = NIdSet.GetKey(NIdV[n]);
421 for (
int e = 0; e < NI.GetOutDeg(); e++) {
422 const int dst = NIdSet.GetKey(NI.GetOutNId(e));
423 if (! OutGraph.IsNode(dst)) {
continue; }
424 OutGraph.AddEdge(src, dst);
TSizeTy Len() const
Returns the number of elements in the vector.
int AddKey(const TKey &Key)
The documentation for this struct was generated from the following file: