template<class PGraph>
struct TSnap::TSnapDetail::TGetSubGraph< PGraph, false >
Definition at line 199 of file subgraph.h.
Definition at line 200 of file subgraph.h.
References THashSet< TKey, THashFunc >::AddKey(), CAssert, THashSet< TKey, THashFunc >::Defrag(), edge, gfEdgeDat, gfMultiGraph, gfNodeDat, HasGraphFlag, TVec< TVal, TSizeTy >::Len(), and THashSet< TKey, THashFunc >::Len().
202 PGraph NewGraphPt = PGraph::TObj::New();
203 typename PGraph::TObj& NewGraph = *NewGraphPt;
204 NewGraph.Reserve(NIdV.
Len(), -1);
206 for (
int n = 0; n < NIdV.
Len(); n++) {
208 if (Graph->IsNode(NIdV[n])) { NewGraph.AddNode(NIdV[n]); NodeSet.
AddKey(NIdV[n]); } }
210 if (Graph->IsNode(NIdV[n])) { NewGraph.AddNode(Graph->GetNI(NIdV[n])); NodeSet.
AddKey(NIdV[n]); } }
212 for (
int n = 0; n < NodeSet.
Len(); n++) {
213 const int SrcNId = NodeSet[n];
214 const typename PGraph::TObj::TNodeI NI = Graph->GetNI(SrcNId);
216 const int OutNId = NI.GetOutNId(
edge);
217 if (NewGraph.IsNode(OutNId)) {
219 NewGraph.AddEdge(SrcNId, OutNId); }
221 NewGraph.AddEdge(Graph->GetEI(SrcNId, OutNId)); }
TSizeTy Len() const
Returns the number of elements in the vector.
have explicit edges (multigraph): TNEGraph, TNodeEdgeNet
#define HasGraphFlag(TGraph, Flag)
For quick testing of the properties of the graph/network object (see TGraphFlag). ...
network with data on edges
int AddKey(const TKey &Key)
network with data on nodes