#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 359 of file subgraph.h.
template<class POutGraph , class PInGraph >
Definition at line 360 of file subgraph.h.
361 POutGraph OutGraphPt = POutGraph::TObj::New();
362 typename POutGraph::TObj& OutGraph = *OutGraphPt;
363 if (! RenumberNodes) {
364 for (
int n = 0; n < NIdV.
Len(); n++) {
365 OutGraph.AddNode(NIdV[n]); }
366 for (
int n = 0; n < NIdV.
Len(); n++) {
367 typename PInGraph::TObj::TNodeI NI = InGraph->GetNI(NIdV[n]);
368 for (
int e = 0; e < NI.GetOutDeg(); e++) {
369 const int dst = NI.GetOutNId(e);
370 if (! OutGraph.IsNode(dst)) {
continue; }
371 OutGraph.AddEdge(NIdV[n], dst);
375 TIntSet NIdSet(InGraph->GetNodes());
376 for (
int n = 0; n < NIdV.
Len(); n++) {
377 const int NId = NIdSet.
AddKey(NIdV[n]);
378 OutGraph.AddNode(NId);
380 for (
int n = 0; n < NIdV.
Len(); n++) {
381 typename PInGraph::TObj::TNodeI NI = InGraph->GetNI(NIdV[n]);
382 const int src = NIdSet.GetKey(NIdV[n]);
383 for (
int e = 0; e < NI.GetOutDeg(); e++) {
384 const int dst = NIdSet.GetKey(NI.GetOutNId(e));
385 if (! OutGraph.IsNode(dst)) {
continue; }
386 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: