#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 372 of file subgraph.h.
template<class POutGraph , class PInGraph >
Definition at line 373 of file subgraph.h.
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);
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);
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);
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: