template<class PGraph>
struct TSnap::TSnapDetail::TGetSubGraph< PGraph, false >
Definition at line 167 of file subgraph.h.
Definition at line 168 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().
170 PGraph NewGraphPt = PGraph::TObj::New();
171 typename PGraph::TObj& NewGraph = *NewGraphPt;
172 NewGraph.Reserve(NIdV.
Len(), -1);
174 for (
int n = 0; n < NIdV.
Len(); n++) {
176 if (Graph->IsNode(NIdV[n])) { NewGraph.AddNode(NIdV[n]); NodeSet.
AddKey(NIdV[n]); } }
178 if (Graph->IsNode(NIdV[n])) { NewGraph.AddNode(Graph->GetNI(NIdV[n])); NodeSet.
AddKey(NIdV[n]); } }
180 for (
int n = 0; n < NodeSet.
Len(); n++) {
181 const int SrcNId = NodeSet[n];
182 const typename PGraph::TObj::TNodeI NI = Graph->GetNI(SrcNId);
184 const int OutNId = NI.GetOutNId(
edge);
185 if (NewGraph.IsNode(OutNId)) {
187 NewGraph.AddEdge(SrcNId, OutNId); }
189 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