18 template<
class PGraph> PGraph
GetSubGraph(
const PGraph& Graph,
const TIntV& NIdV);
52 template<
class PGraph> PGraph
GetESubGraph(
const PGraph& Graph,
const TIntV& EIdV);
71 template<
class PGraph,
class TEdgeDat> PGraph
GetEDatSubGraph(
const PGraph& Graph,
const TEdgeDat& EDat,
const int&
Cmp);
87 template<
class PGraph,
class TEdgeDat> PGraph
GetEDatSubGraph(
const PGraph& Graph,
const TIntV& NIdV,
const TEdgeDat& EDat,
const int&
Cmp);
102 template<
class POutGraph,
class PInGraph> POutGraph
ConvertGraph(
const PInGraph& InGraph,
const bool& RenumberNodes=
false);
115 template<
class POutGraph,
class PInGraph> POutGraph
ConvertSubGraph(
const PInGraph& InGraph,
const TIntV& NIdV,
const bool& RenumberNodes=
false);
129 template<
class POutGraph,
class PInGraph> POutGraph
ConvertESubGraph(
const PInGraph& InGraph,
const TIntV& EIdV,
const bool& RenumberNodes=
false);
137 template<
class PGraph> PGraph
GetRndSubGraph(
const PGraph& Graph,
const int& NNodes);
142 template<
class PGraph> PGraph
GetRndESubGraph(
const PGraph& Graph,
const int& NEdges);
152 template<
class PGraph> PGraph
GetEgonetHop(
const PGraph &Graph,
const int CtrNId,
const int Radius);
154 template<
class PGraph> PGraph
GetInEgonetHop(
const PGraph& Graph,
const int CtrNId,
const int Radius);
156 template<
class PGraph> PGraph
GetOutEgonetHop(
const PGraph &Graph,
const int CtrNId,
const int Radius);
166 template<
class PGraph> PGraph
GetInEgonetSub(
const PGraph &Graph,
const int CtrNId,
const int Radius,
const int MaxNum = 2,
const float percent = -1.0);
171 template<
class PGraph> PGraph
GetGraphUnion(PGraph& DstGraph,
const PGraph& SrcGraph);
177 namespace TSnapDetail {
179 template <
class PGraph,
bool IsMultiGraph>
181 static PGraph
Do(
const PGraph& Graph,
const TIntV& NIdV) {
182 PGraph NewGraphPt = PGraph::TObj::New();
183 typename PGraph::TObj& NewGraph = *NewGraphPt;
184 NewGraph.Reserve(NIdV.
Len(), -1);
185 for (
int n = 0; n < NIdV.
Len(); n++) {
186 if (Graph->IsNode(NIdV[n])) {
187 NewGraph.AddNode(Graph->GetNI(NIdV[n])); }
189 for (
typename PGraph::TObj::TEdgeI EI = Graph->BegEI(); EI < Graph->EndEI(); EI++) {
190 if (NewGraph.IsNode(EI.GetSrcNId()) && NewGraph.IsNode(EI.GetDstNId())) {
191 NewGraph.AddEdge(EI); }
198 template <
class PGraph>
200 static PGraph
Do(
const PGraph& Graph,
const TIntV& NIdV) {
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)); }
231 template<
class PGraph>
237 template<
class PGraph>
242 template<
class PGraph>
245 PGraph NewGraphPt = PGraph::TObj::New();
246 typename PGraph::TObj& NewGraph = *NewGraphPt;
247 NewGraph.Reserve(-1, EIdV.
Len());
249 const int EId = EIdV[
edge];
251 const typename PGraph::TObj::TEdgeI EI = Graph->GetEI(EId);
252 if (! NewGraph.IsNode(EI.GetSrcNId())) {
253 NewGraph.AddNode(Graph->GetNI(EI.GetSrcNId()));
255 if (! NewGraph.IsNode(EI.GetDstNId())) {
256 NewGraph.AddNode(Graph->GetNI(EI.GetDstNId()));
258 NewGraph.AddEdge(EI);
263 template<
class PGraph>
265 PGraph NewGraphPt = PGraph::TObj::New();
266 typename PGraph::TObj& NewGraph = *NewGraphPt;
267 NewGraph.Reserve(-1, EdgeV.
Len());
270 const int SrcNId = EdgeV[
edge].Val1;
271 const int DstNId = EdgeV[
edge].Val2;
272 if (! NewGraph.IsNode(SrcNId)) {
273 NewGraph.AddNode(Graph->GetNI(SrcNId));
275 if (! NewGraph.IsNode(DstNId)) {
276 NewGraph.AddNode(Graph->GetNI(DstNId));
279 NewGraph.AddEdge(SrcNId, DstNId);
285 template<
class PGraph,
class TEdgeDat>
288 PGraph NewGraphPt = PGraph::TObj::New();
289 typename PGraph::TObj& NewGraph = *NewGraphPt;
290 for (
typename PGraph::TObj::TEdgeI EI = Graph->BegEI(); EI < Graph->EndEI(); EI++) {
291 if ((Cmp==1 && EI()>EDat) || (Cmp==-1 && EI()<EDat) || (Cmp==0 && EI()==EDat)) {
292 if (! NewGraph.IsNode(EI.GetSrcNId())) {
293 NewGraph.AddNode(Graph->GetNI(EI.GetSrcNId()));
295 if (! NewGraph.IsNode(EI.GetDstNId())) {
296 NewGraph.AddNode(Graph->GetNI(EI.GetDstNId()));
298 NewGraph.AddEdge(EI);
305 template<
class PGraph,
class TEdgeDat>
308 PGraph NewGraphPt = PGraph::TObj::New();
309 typename PGraph::TObj& NewGraph = *NewGraphPt;
310 NewGraph.Reserve(NIdV.
Len(), -1);
311 for (
int n = 0; n < NIdV.
Len(); n++) {
312 NewGraph.AddNode(Graph->GetNI(NIdV[n]));
314 for (
typename PGraph::TObj::TEdgeI EI = Graph->BegEI(); EI < Graph->EndEI(); EI++) {
315 if (NewGraph.IsNode(EI.GetSrcNId()) && NewGraph.IsNode(EI.GetDstNId()) &&
316 ((Cmp==1 && EI()>EDat)|| (Cmp==-1 && EI()<EDat) || (Cmp==0 && EI()==EDat))) {
317 NewGraph.AddEdge(EI); }
325 template<
class POutGraph,
class PInGraph>
326 POutGraph
ConvertGraph(
const PInGraph& InGraph,
const bool& RenumberNodes) {
327 POutGraph OutGraphPt = POutGraph::TObj::New();
328 typename POutGraph::TObj& OutGraph = *OutGraphPt;
329 OutGraph.Reserve(InGraph->GetNodes(), InGraph->GetEdges());
330 if (! RenumberNodes) {
331 for (
typename PInGraph::TObj::TNodeI NI = InGraph->BegNI(); NI < InGraph->EndNI(); NI++) {
332 OutGraph.AddNode(NI.GetId());
334 for (
typename PInGraph::TObj::TEdgeI EI = InGraph->BegEI(); EI < InGraph->EndEI(); EI++) {
335 OutGraph.AddEdge(EI.GetSrcNId(), EI.GetDstNId());
337 OutGraph.AddEdge(EI.GetDstNId(), EI.GetSrcNId()); }
340 TIntSet NIdSet(InGraph->GetNodes());
341 for (
typename PInGraph::TObj::TNodeI NI = InGraph->BegNI(); NI < InGraph->EndNI(); NI++) {
342 const int nid = NIdSet.
AddKey(NI.GetId());
343 OutGraph.AddNode(nid);
345 for (
typename PInGraph::TObj::TEdgeI EI = InGraph->BegEI(); EI < InGraph->EndEI(); EI++) {
346 const int SrcNId = NIdSet.GetKeyId(EI.GetSrcNId());
347 const int DstNId = NIdSet.GetKeyId(EI.GetDstNId());
348 OutGraph.AddEdge(SrcNId, DstNId);
350 OutGraph.AddEdge(DstNId, SrcNId); }
357 namespace TSnapDetail {
359 template <
class POutGraph,
class PInGraph,
bool IsMultiGraph>
361 static POutGraph
Do(
const PInGraph& InGraph,
const TIntV& NIdV,
const bool& RenumberNodes) {
362 POutGraph OutGraphPt = POutGraph::TObj::New();
363 typename POutGraph::TObj& OutGraph = *OutGraphPt;
364 if (! RenumberNodes) {
365 for (
int n = 0; n < NIdV.
Len(); n++) {
366 OutGraph.AddNode(NIdV[n]);
368 for (
typename PInGraph::TObj::TEdgeI EI = InGraph->BegEI(); EI < InGraph->EndEI(); EI++) {
369 if (! OutGraph.IsNode(EI.GetSrcNId()) || ! OutGraph.IsNode(EI.GetDstNId())) {
continue; }
370 OutGraph.AddEdge(EI.GetSrcNId(), EI.GetDstNId());
372 OutGraph.AddEdge(EI.GetDstNId(), EI.GetSrcNId());
376 TIntSet NIdSet(InGraph->GetNodes());
377 for (
int n = 0; n < NIdV.
Len(); n++) {
378 const int NId = NIdSet.
AddKey(NIdV[n]);
379 OutGraph.AddNode(NId);
381 for (
typename PInGraph::TObj::TEdgeI EI = InGraph->BegEI(); EI < InGraph->EndEI(); EI++) {
382 const int SrcNId = NIdSet.GetKeyId(EI.GetSrcNId());
383 const int DstNId = NIdSet.GetKeyId(EI.GetDstNId());
384 if (! OutGraph.IsNode(SrcNId) || ! OutGraph.IsNode(DstNId)) {
continue; }
385 OutGraph.AddEdge(SrcNId, DstNId);
387 OutGraph.AddEdge(DstNId, SrcNId);
396 template <
class POutGraph,
class PInGraph>
398 static POutGraph
Do(
const PInGraph& InGraph,
const TIntV& NIdV,
const bool& RenumberNodes) {
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);
435 template<
class POutGraph,
class PInGraph>
440 template<
class POutGraph,
class PInGraph>
443 POutGraph NewGraphPt = POutGraph::TObj::New();
444 typename POutGraph::TObj& NewGraph = *NewGraphPt;
445 NewGraph.Reserve(-1, EIdV.
Len());
446 if (! RenumberNodes) {
448 const int EId = EIdV[
edge];
450 const typename PInGraph::TObj::TEdgeI EI = InGraph->GetEI(EId);
451 const int SrcNId = EI.GetSrcNId();
452 const int DstNId = EI.GetDstNId();
453 if (! NewGraph.IsNode(SrcNId)) {
454 NewGraph.AddNode(SrcNId); }
455 if (! NewGraph.IsNode(DstNId)) {
456 NewGraph.AddNode(DstNId); }
457 NewGraph.AddEdge(SrcNId, DstNId);
461 TIntSet NIdSet(InGraph->GetNodes());
463 const int EId = EIdV[
edge];
465 const typename PInGraph::TObj::TEdgeI EI = InGraph->GetEI(EId);
466 const int SrcNId = NIdSet.AddKey(EI.GetSrcNId());
467 const int DstNId = NIdSet.AddKey(EI.GetDstNId());
468 if (! NewGraph.IsNode(SrcNId)) {
469 NewGraph.AddNode(SrcNId); }
470 if (! NewGraph.IsNode(DstNId)) {
471 NewGraph.AddNode(DstNId); }
472 NewGraph.AddEdge(SrcNId, DstNId);
478 template<
class PGraph>
480 IAssert(NNodes <= Graph->GetNodes());
482 Graph->GetNIdV(NIdV);
484 NIdV.
Del(NNodes, NIdV.
Len()-1);
489 template<
class PGraph>
492 TIntPrV EdgeV(Graph->GetEdges(), 0);
493 for (
typename PGraph::TObj::TEdgeI EI = Graph->BegEI(); EI < Graph->EndEI(); EI++) {
494 EdgeV.
Add(
TIntPr(EI.GetSrcNId(), EI.GetDstNId()));
497 EdgeV.Del(NEdges, EdgeV.Len()-1);
498 IAssert(EdgeV.Len() == NEdges);
505 template<
class PGraph>
506 PGraph
GetEgonetHop(
const PGraph &Graph,
const int CtrNId,
const int Radius) {
507 PGraph NewGraphPt = PGraph::TObj::New();
508 typename PGraph::TObj& NewGraph = *NewGraphPt;
512 NewGraph.AddNode(CtrNId);
515 for (
int r = 0; r < Radius; ++r) {
516 while (!Queue1.
Empty()) {
517 const int NId = Queue1.
Top();
519 const typename PGraph::TObj::TNodeI &Node = Graph->GetNI(NId);
520 for (
int i = 0; i < Node.GetInDeg(); ++i) {
521 const int InNId = Node.GetInNId(i);
522 if (!NewGraph.IsNode(InNId)) {
523 NewGraph.AddNode(InNId);
526 if (!NewGraph.IsEdge(InNId, NId)) {
527 NewGraph.AddEdge(InNId, NId);
530 for (
int i = 0; i < Node.GetOutDeg(); ++i) {
531 const int OutNId = Node.GetOutNId(i);
532 if (!NewGraph.IsNode(OutNId)) {
533 NewGraph.AddNode(OutNId);
536 if (!NewGraph.IsEdge(NId, OutNId)) {
537 NewGraph.AddEdge(NId, OutNId);
540 for (
int i = 0; i < Node.GetInDeg(); ++i) {
541 int InNId = Node.GetInNId(i);
542 const typename PGraph::TObj::TNodeI &InNode = Graph->GetNI(InNId);
543 for (
int j = 0; j < InNode.GetInDeg(); ++j) {
544 int NbrInNId = InNode.GetInNId(j);
545 if (NewGraph.IsNode(NbrInNId)) {
546 if (!NewGraph.IsEdge(NbrInNId, InNId)) {
547 NewGraph.AddEdge(NbrInNId, InNId);
551 for (
int j = 0; j < InNode.GetOutDeg(); ++j) {
552 int NbrOutNId = InNode.GetOutNId(j);
553 if (NewGraph.IsNode(NbrOutNId)) {
554 if (!NewGraph.IsEdge(InNId, NbrOutNId)) {
555 NewGraph.AddEdge(InNId, NbrOutNId);
560 for (
int i = 0; i < Node.GetOutDeg(); ++i) {
561 int OutNId = Node.GetOutNId(i);
562 const typename PGraph::TObj::TNodeI &OutNode = Graph->GetNI(OutNId);
563 for (
int j = 0; j < OutNode.GetInDeg(); ++j) {
564 int NbrInNId = OutNode.GetInNId(j);
565 if (NewGraph.IsNode(NbrInNId)) {
566 if (!NewGraph.IsEdge(NbrInNId, OutNId)) {
567 NewGraph.AddEdge(NbrInNId, OutNId);
571 for (
int j = 0; j < OutNode.GetOutDeg(); ++j) {
572 int NbrOutNId = OutNode.GetOutNId(j);
573 if (NewGraph.IsNode(NbrOutNId)) {
574 if (!NewGraph.IsEdge(OutNId, NbrOutNId)) {
575 NewGraph.AddEdge(OutNId, NbrOutNId);
581 tempSwapQueue = Queue1;
583 Queue2 = tempSwapQueue;
588 template<
class PGraph>
590 PGraph NewGraphPt = PGraph::TObj::New();
591 typename PGraph::TObj& NewGraph = *NewGraphPt;
595 NewGraph.AddNode(CtrNId);
598 for (
int r = 0; r < Radius; ++r) {
599 while (!Queue1.
Empty()) {
600 const int NId = Queue1.
Top();
602 const typename PGraph::TObj::TNodeI &Node = Graph->GetNI(NId);
603 for (
int i = 0; i < Node.GetInDeg(); ++i) {
604 const int InNId = Node.GetInNId(i);
605 if (!NewGraph.IsNode(InNId)) {
606 NewGraph.AddNode(InNId);
609 if (!NewGraph.IsEdge(InNId, NId)) {
610 NewGraph.AddEdge(InNId, NId);
613 for (
int i = 0; i < Node.GetInDeg(); ++i) {
614 int InNId = Node.GetInNId(i);
615 const typename PGraph::TObj::TNodeI &InNode = Graph->GetNI(InNId);
616 for (
int j = 0; j < InNode.GetInDeg(); ++j) {
617 int NbrInNId = InNode.GetInNId(j);
618 if (NewGraph.IsNode(NbrInNId)) {
619 if (!NewGraph.IsEdge(NbrInNId, InNId)) {
620 NewGraph.AddEdge(NbrInNId, InNId);
624 for (
int j = 0; j < InNode.GetOutDeg(); ++j) {
625 int NbrOutNId = InNode.GetOutNId(j);
626 if (NewGraph.IsNode(NbrOutNId)) {
627 if (!NewGraph.IsEdge(InNId, NbrOutNId)) {
628 NewGraph.AddEdge(InNId, NbrOutNId);
634 tempSwapQueue = Queue1;
636 Queue2 = tempSwapQueue;
641 template<
class PGraph>
643 PGraph NewGraphPt = PGraph::TObj::New();
644 typename PGraph::TObj& NewGraph = *NewGraphPt;
648 NewGraph.AddNode(CtrNId);
651 for (
int r = 0; r < Radius; ++r) {
652 while (!Queue1.
Empty()) {
653 const int NId = Queue1.
Top();
655 const typename PGraph::TObj::TNodeI &Node = Graph->GetNI(NId);
656 for (
int i = 0; i < Node.GetOutDeg(); ++i) {
657 const int OutNId = Node.GetOutNId(i);
658 if (!NewGraph.IsNode(OutNId)) {
659 NewGraph.AddNode(OutNId);
662 if (!NewGraph.IsEdge(NId, OutNId)) {
663 NewGraph.AddEdge(NId, OutNId);
666 for (
int i = 0; i < Node.GetOutDeg(); ++i) {
667 int OutNId = Node.GetOutNId(i);
668 const typename PGraph::TObj::TNodeI &OutNode = Graph->GetNI(OutNId);
669 for (
int j = 0; j < OutNode.GetInDeg(); ++j) {
670 int NbrInNId = OutNode.GetInNId(j);
671 if (NewGraph.IsNode(NbrInNId)) {
672 if (!NewGraph.IsEdge(NbrInNId, OutNId)) {
673 NewGraph.AddEdge(NbrInNId, OutNId);
677 for (
int j = 0; j < OutNode.GetOutDeg(); ++j) {
678 int NbrOutNId = OutNode.GetOutNId(j);
679 if (NewGraph.IsNode(NbrOutNId)) {
680 if (!NewGraph.IsEdge(OutNId, NbrOutNId)) {
681 NewGraph.AddEdge(OutNId, NbrOutNId);
687 tempSwapQueue = Queue1;
689 Queue2 = tempSwapQueue;
694 template<
class PGraph>
695 PGraph
GetInEgonetSub(
const PGraph &Graph,
const int CtrNId,
const int Radius,
const int MaxNum,
const float percent) {
696 PGraph NewGraphPt = PGraph::TObj::New();
697 typename PGraph::TObj& NewGraph = *NewGraphPt;
702 NewGraph.AddNode(CtrNId);
705 bool usePercent = (percent != -1.0);
706 int numSamples = MaxNum;
707 for (
int r = 0; r < Radius; ++r) {
708 while (!Queue1.
Empty()) {
709 const int NId = Queue1.
Top();
711 const typename PGraph::TObj::TNodeI &Node = Graph->GetNI(NId);
712 sampleQueue.
Clr(
true);
713 for (
int i = 0; i < Node.GetInDeg(); ++i) {
714 const int InNId = Node.GetInNId(i);
715 if (!NewGraph.IsNode(InNId)) {
716 sampleQueue.
Push(InNId);
720 numSamples = (int) (percent * sampleQueue.
Len());
722 sampleQueue.
Sample(numSamples);
723 for (
int i = 0; i < numSamples && !sampleQueue.
Empty(); ++i) {
724 const int InNId = sampleQueue.
Top();
726 if (!NewGraph.IsNode(InNId)) {
727 NewGraph.AddNode(InNId);
730 if (!NewGraph.IsEdge(InNId, NId)) {
731 NewGraph.AddEdge(InNId, NId);
734 for (
int i = 0; i < Node.GetInDeg(); ++i) {
735 int InNId = Node.GetInNId(i);
736 if (!NewGraph.IsNode(InNId)) {
continue; }
737 const typename PGraph::TObj::TNodeI &InNode = Graph->GetNI(InNId);
738 for (
int j = 0; j < InNode.GetInDeg(); ++j) {
739 int NbrInNId = InNode.GetInNId(j);
740 if (NewGraph.IsNode(NbrInNId)) {
741 if (!NewGraph.IsEdge(NbrInNId, InNId)) {
742 NewGraph.AddEdge(NbrInNId, InNId);
746 for (
int j = 0; j < InNode.GetOutDeg(); ++j) {
747 int NbrOutNId = InNode.GetOutNId(j);
748 if (NewGraph.IsNode(NbrOutNId)) {
749 if (!NewGraph.IsEdge(InNId, NbrOutNId)) {
750 NewGraph.AddEdge(InNId, NbrOutNId);
756 tempSwapQueue = Queue1;
758 Queue2 = tempSwapQueue;
763 template<
class PGraph>
765 for (
typename PGraph::TObj::TNodeI NI = SrcGraph->BegNI(); NI < SrcGraph->EndNI(); NI++) {
766 if (! DstGraph->IsNode(NI.GetId())){
767 DstGraph->AddNode(NI.GetId());
770 for (
typename PGraph::TObj::TEdgeI EI = SrcGraph->BegEI(); EI < SrcGraph->EndEI(); EI++) {
772 if (! DstGraph->IsEdge(EI.GetSrcNId(), EI.GetDstNId())){
773 DstGraph->AddEdge(EI.GetSrcNId(), EI.GetDstNId());
777 if (! DstGraph->IsEdge(EI.GetSrcNId(), EI.GetDstNId()) || ! DstGraph->IsEdge(EI.GetId())){
778 if (! DstGraph->IsEdge(EI.GetId())){
779 DstGraph->AddEdge(EI.GetSrcNId(), EI.GetDstNId(), EI.GetId());
781 DstGraph->AddEdge(EI.GetSrcNId(), EI.GetDstNId());
TPair< TInt, TInt > TIntPr
Main namespace for all the Snap global entities.
PNEANet GetEgonetAttr(const PNEANet &Graph, const int CtrNId, const int Radius)
Returns the complete egonet of at given radius and copies node and edge attributes.
void Del(const TSizeTy &ValN)
Removes the element at position ValN.
PNEANet GetInEgonetSubAttr(const PNEANet &Graph, const int CtrNId, const int Radius, const int MaxNum, const float percent)
Returns the randomly sampled egonet with nodes sampled based on percentage or raw number...
PGraph GetEgonetHop(const PGraph &Graph, const int CtrNId, const int Radius)
Returns the egonet of node CtrNId as center for a Graph for a given radius.
TSizeTy Len() const
Returns the number of elements in the vector.
PNEANet GetGraphUnionAttr(PNEANet &DstGraph, const PNEANet &SrcGraph)
have explicit edges (multigraph): TNEGraph, TNodeEdgeNet
void Pop()
Removes the first element from the queue.
bool Empty() const
Tests whether the queue is empty (contains no elements).
PNEANet GetInEgonetAttr(const PNEANet &Graph, const int CtrNId, const int Radius)
Returns the in-egonet of at given radius and copies node and edge attributes.
PGraph GetInEgonetSub(const PGraph &Graph, const int CtrNId, const int Radius, const int MaxNum=2, const float percent=-1.0)
Returns the randomly sampled in-egonet with nodes sampled based on percentage, if percent != -1...
POutGraph ConvertSubGraph(const PInGraph &InGraph, const TIntV &NIdV, const bool &RenumberNodes=false)
Returns an induced subgraph of graph InGraph with NIdV nodes with an optional node renumbering...
#define HasGraphFlag(TGraph, Flag)
For quick testing of the properties of the graph/network object (see TGraphFlag). ...
static PGraph Do(const PGraph &Graph, const TIntV &NIdV)
network with data on edges
PGraph GetRndESubGraph(const PGraph &Graph, const int &NEdges)
Returns a random subgraph of graph Graph with NEdges edges.
PUNGraph GetSubGraph(const PUNGraph &Graph, const TIntV &NIdV, const bool &RenumberNodes)
Returns an induced subgraph of an undirected graph Graph with NIdV nodes with an optional node renumb...
static POutGraph Do(const PInGraph &InGraph, const TIntV &NIdV, const bool &RenumberNodes)
static PGraph Do(const PGraph &Graph, const TIntV &NIdV)
int AddKey(const TKey &Key)
static POutGraph Do(const PInGraph &InGraph, const TIntV &NIdV, const bool &RenumberNodes)
int Len() const
Returns the number of elements in the queue.
PGraph GetSubGraphRenumber(const PGraph &Graph, const TIntV &NIdV)
Returns an induced subgraph of graph Graph with NIdV nodes with an node renumbering.
void Clr(const bool &DoDel=true)
Deletes all elements from the queue.
directed graph (TNGraph, TNEGraph), else graph is undirected TUNGraph
PGraph GetGraphUnion(PGraph &DstGraph, const PGraph &SrcGraph)
PGraph GetEDatSubGraph(const PGraph &Graph, const TEdgeDat &EDat, const int &Cmp)
Returns a subgraph of graph Graph with edges where edge data matches the parameters.
void Sample(const int num, TRnd &Rnd=TInt::Rnd)
POutGraph ConvertESubGraph(const PInGraph &InGraph, const TIntV &EIdV, const bool &RenumberNodes=false)
Returns a subgraph of graph InGraph with EIdV edges with an optional node renumbering.
PUNGraph GetEgonet(const PUNGraph &Graph, const int CtrNId, int &ArndEdges)
Returns the egonet of node CtrNId as center in undirected graph Graph. And returns number of edges ar...
void Push(const TVal &Val)
Adds an element at the end of the queue.
void Shuffle(TRnd &Rnd)
Randomly shuffles the elements of the vector.
const TVal & Top() const
Returns the value of the first element in the queue, but does not remove the element.
PGraph GetOutEgonetHop(const PGraph &Graph, const int CtrNId, const int Radius)
Returns the out-egonet of node CtrNId as center in directed graph Graph for a given radius...
bool Cmp(const int &RelOp, const TRec &Rec1, const TRec &Rec2)
PGraph GetESubGraph(const PGraph &Graph, const TIntV &EIdV)
Returns a subgraph of graph Graph with EIdV edges.
PGraph GetRndSubGraph(const PGraph &Graph, const int &NNodes)
Returns an induced random subgraph of graph Graph with NNodes nodes.
network with data on nodes
PGraph GetInEgonetHop(const PGraph &Graph, const int CtrNId, const int Radius)
Returns the in-egonet of node CtrNId as center in directed graph Graph for a given radius...
POutGraph ConvertGraph(const PInGraph &InGraph, const bool &RenumberNodes=false)
Performs conversion of graph InGraph with an optional node renumbering.
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
PNEANet GetOutEgonetAttr(const PNEANet &Graph, const int CtrNId, const int Radius)
Returns the out-egonet of at given radius and copies node and edge attributes.