16 template <
class TNodeData>
84 int GetInNId(
const int& NodeN)
const {
return NodeHI.GetDat().GetInNId(NodeN); }
88 int GetOutNId(
const int& NodeN)
const {
return NodeHI.GetDat().GetOutNId(NodeN); }
92 int GetNbrNId(
const int& NodeN)
const {
return NodeHI.GetDat().GetNbrNId(NodeN); }
94 bool IsInNId(
const int& NId)
const {
return NodeHI.GetDat().IsInNId(NId); }
96 bool IsOutNId(
const int& NId)
const {
return NodeHI.GetDat().IsOutNId(NId); }
181 return PNet(Network);
207 int AddNode(
int NId,
const TNodeData& NodeDat);
209 int AddNode(
const TNodeI& NodeI) {
return AddNode(NodeI.GetId(), NodeI.GetDat()); }
213 virtual void DelNode(
const int& NId);
227 void SetNDat(
const int& NId,
const TNodeData& NodeDat);
245 int AddEdge(
const int& SrcNId,
const int& DstNId);
247 int AddEdge(
const TEdgeI& EdgeI) {
return AddEdge(EdgeI.GetSrcNId(), EdgeI.GetDstNId()); }
253 void DelEdge(
const int& SrcNId,
const int& DstNId,
const bool& IsDir =
true);
255 bool IsEdge(
const int& SrcNId,
const int& DstNId,
const bool& IsDir =
true)
const;
261 TEdgeI
GetEI(
const int& EId)
const;
263 TEdgeI
GetEI(
const int& SrcNId,
const int& DstNId)
const;
275 void Clr(
const bool& DoDel=
true,
const bool& ResetDat=
true) {
278 void Reserve(
const int& Nodes,
const int& Edges) {
if (Nodes>0) {
NodeH.
Gen(Nodes/2); } }
289 void Defrag(
const bool& OnlyNodeLinks=
false);
294 bool IsOk(
const bool& ThrowExcept=
true)
const;
305 template <
class TNodeData>
310 template <
class TNodeData>
313 NId = MxNId; MxNId++;
318 NodeH.AddDat(NId,
TNode(NId));
322 template <
class TNodeData>
325 NId = MxNId; MxNId++;
327 if (IsNode(NId)) {
return -1;}
330 NodeH.AddDat(NId,
TNode(NId));
334 template <
class TNodeData>
337 NId = MxNId; MxNId++;
342 NodeH.AddDat(NId,
TNode(NId, NodeDat));
346 template <
class TNodeData>
348 {
TNode& Node = GetNode(NId);
349 for (
int e = 0; e < Node.
GetOutDeg(); e++) {
351 if (nbr == NId) {
continue; }
352 TNode& N = GetNode(nbr);
356 for (
int e = 0; e < Node.
GetInDeg(); e++) {
358 if (nbr == NId) {
continue; }
359 TNode& N = GetNode(nbr);
366 template <
class TNodeData>
369 NodeH.GetDat(NId).NodeDat = NodeDat;
372 template <
class TNodeData>
375 for (
int N=NodeH.FFirstKeyId(); NodeH.FNextKeyId(N);) {
376 edges+=NodeH[N].GetOutDeg(); }
380 template <
class TNodeData>
382 IAssertR(IsNode(SrcNId) && IsNode(DstNId),
TStr::Fmt(
"%d or %d not a node.", SrcNId, DstNId).CStr());
383 if (IsEdge(SrcNId, DstNId)) {
return -2; }
384 GetNode(SrcNId).OutNIdV.AddSorted(DstNId);
385 GetNode(DstNId).InNIdV.AddSorted(SrcNId);
389 template <
class TNodeData>
391 IAssertR(IsNode(SrcNId) && IsNode(DstNId),
TStr::Fmt(
"%d or %d not a node.", SrcNId, DstNId).CStr());
392 GetNode(SrcNId).OutNIdV.DelIfIn(DstNId);
393 GetNode(DstNId).InNIdV.DelIfIn(SrcNId);
395 GetNode(DstNId).OutNIdV.DelIfIn(SrcNId);
396 GetNode(SrcNId).InNIdV.DelIfIn(DstNId);
400 template <
class TNodeData>
402 if (! IsNode(SrcNId) || ! IsNode(DstNId)) {
return false; }
403 if (IsDir) {
return GetNode(SrcNId).IsOutNId(DstNId); }
404 else {
return GetNode(SrcNId).IsOutNId(DstNId) || GetNode(DstNId).IsOutNId(SrcNId); }
407 template <
class TNodeData>
410 for (
int N=NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
411 NIdV.
Add(NodeH.GetKey(N)); }
414 template <
class TNodeData>
416 const TNodeI SrcNI = GetNI(SrcNId);
417 const int NodeN = SrcNI.
NodeHI.GetDat().OutNIdV.SearchBin(DstNId);
418 if (NodeN == -1) {
return EndEI(); }
419 return TEdgeI(SrcNI, EndNI(), NodeN);
422 template <
class TNodeData>
424 for (
int n = NodeH.FFirstKeyId(); NodeH.FNextKeyId(n); ) {
425 TNode& Node = NodeH[n];
428 if (! OnlyNodeLinks && ! NodeH.IsKeyIdEqKeyN()) {
432 template <
class TNodeData>
435 for (
int N = NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
436 const TNode& Node = NodeH[N];
438 const TStr Msg =
TStr::Fmt(
"Out-neighbor list of node %d is not sorted.", Node.
GetId());
442 const TStr Msg =
TStr::Fmt(
"In-neighbor list of node %d is not sorted.", Node.
GetId());
447 for (
int e = 0; e < Node.
GetOutDeg(); e++) {
449 const TStr Msg =
TStr::Fmt(
"Out-edge %d --> %d: node %d does not exist.",
453 if (e > 0 && prevNId == Node.
GetOutNId(e)) {
454 const TStr Msg =
TStr::Fmt(
"Node %d has duplidate out-edge %d --> %d.",
462 for (
int e = 0; e < Node.
GetInDeg(); e++) {
464 const TStr Msg =
TStr::Fmt(
"In-edge %d <-- %d: node %d does not exist.",
468 if (e > 0 && prevNId == Node.
GetInNId(e)) {
469 const TStr Msg =
TStr::Fmt(
"Node %d has duplidate in-edge %d <-- %d.",
490 template <
class TNodeData,
class TEdgeData>
591 const TEdgeData&
GetOutEDat(
const int& EdgeN)
const {
return NodeHI.GetDat().GetOutEDat(EdgeN); }
672 return PNet(Network);
698 int AddNode(
int NId,
const TNodeData& NodeDat);
700 int AddNode(
const TNodeI& NodeI) {
return AddNode(NodeI.GetId(), NodeI.GetDat()); }
718 void SetNDat(
const int& NId,
const TNodeData& NodeDat);
736 int AddEdge(
const int& SrcNId,
const int& DstNId);
744 int AddEdge(
const int& SrcNId,
const int& DstNId,
const TEdgeData& EdgeDat);
746 int AddEdge(
const TEdgeI& EdgeI) {
return AddEdge(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), EdgeI()); }
752 void DelEdge(
const int& SrcNId,
const int& DstNId,
const bool& IsDir =
true);
754 bool IsEdge(
const int& SrcNId,
const int& DstNId,
const bool& IsDir =
true)
const;
760 TEdgeI
GetEI(
const int& EId)
const;
762 TEdgeI
GetEI(
const int& SrcNId,
const int& DstNId)
const;
764 void SetEDat(
const int& SrcNId,
const int& DstNId,
const TEdgeData& EdgeDat);
768 bool GetEDat(
const int& SrcNId,
const int& DstNId, TEdgeData& EdgeDat)
const;
770 TEdgeData&
GetEDat(
const int& SrcNId,
const int& DstNId);
772 const TEdgeData&
GetEDat(
const int& SrcNId,
const int& DstNId)
const;
786 void Clr(
const bool& DoDel=
true,
const bool& ResetDat=
true) {
789 void Reserve(
const int& Nodes,
const int& Edges) {
if (Nodes>0) {
NodeH.
Gen(Nodes/2); } }
800 void Defrag(
const bool& OnlyNodeLinks=
false);
805 bool IsOk(
const bool& ThrowExcept=
true)
const;
817 template <
class TNodeData,
class TEdgeData>
822 template <
class TNodeData,
class TEdgeData>
824 int LValN=0, RValN = NIdV.Len()-1;
825 while (RValN >= LValN) {
826 const int ValN = (LValN+RValN)/2;
827 const int CurNId = NIdV[ValN].Val1;
828 if (NId == CurNId) {
return ValN; }
829 if (NId < CurNId) { RValN=ValN-1; }
830 else { LValN=ValN+1; }
835 template <
class TNodeData,
class TEdgeData>
838 NId = MxNId; MxNId++;
843 NodeH.AddDat(NId,
TNode(NId));
847 template <
class TNodeData,
class TEdgeData>
850 NId = MxNId; MxNId++;
852 if (IsNode(NId)) {
return -1;}
855 NodeH.AddDat(NId,
TNode(NId));
859 template <
class TNodeData,
class TEdgeData>
862 NId = MxNId; MxNId++;
867 NodeH.AddDat(NId,
TNode(NId, NodeDat));
871 template <
class TNodeData,
class TEdgeData>
874 NodeH.GetDat(NId).NodeDat = NodeDat;
877 template <
class TNodeData,
class TEdgeData>
879 const TNode& Node = GetNode(NId);
880 for (
int out = 0; out < Node.
GetOutDeg(); out++) {
882 if (nbr == NId) {
continue; }
883 TIntV& NIdV = GetNode(nbr).InNIdV;
885 if (pos != -1) { NIdV.
Del(pos); }
887 for (
int in = 0; in < Node.
GetInDeg(); in++) {
889 if (nbr == NId) {
continue; }
891 const int pos = GetNIdPos(NIdDatV, NId);
892 if (pos != -1) { NIdDatV.
Del(pos); }
897 template <
class TNodeData,
class TEdgeData>
900 for (
int N=NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
901 edges+=NodeH[N].GetOutDeg(); }
905 template <
class TNodeData,
class TEdgeData>
907 return AddEdge(SrcNId, DstNId, TEdgeData());
910 template <
class TNodeData,
class TEdgeData>
912 IAssertR(IsNode(SrcNId) && IsNode(DstNId),
TStr::Fmt(
"%d or %d not a node.", SrcNId, DstNId).CStr());
914 if (IsEdge(SrcNId, DstNId)) {
915 GetEDat(SrcNId, DstNId) = EdgeDat;
919 GetNode(DstNId).InNIdV.AddSorted(SrcNId);
923 template <
class TNodeData,
class TEdgeData>
925 IAssertR(IsNode(SrcNId) && IsNode(DstNId),
TStr::Fmt(
"%d or %d not a node.", SrcNId, DstNId).CStr());
926 int pos = GetNIdPos(GetNode(SrcNId).OutNIdV, DstNId);
927 if (pos != -1) { GetNode(SrcNId).OutNIdV.Del(pos); }
928 pos = GetNode(DstNId).InNIdV.SearchBin(SrcNId);
929 if (pos != -1) { GetNode(DstNId).InNIdV.Del(pos); }
931 pos = GetNIdPos(GetNode(DstNId).OutNIdV, SrcNId);
932 if (pos != -1) { GetNode(DstNId).OutNIdV.Del(pos); }
933 pos = GetNode(SrcNId).InNIdV.SearchBin(DstNId);
934 if (pos != -1) { GetNode(SrcNId).InNIdV.Del(pos); }
938 template <
class TNodeData,
class TEdgeData>
940 if (! IsNode(SrcNId) || ! IsNode(DstNId)) {
return false; }
941 if (IsDir) {
return GetNode(SrcNId).IsOutNId(DstNId); }
942 else {
return GetNode(SrcNId).IsOutNId(DstNId) || GetNode(DstNId).IsOutNId(SrcNId); }
945 template <
class TNodeData,
class TEdgeData>
947 IAssertR(IsNode(SrcNId) && IsNode(DstNId),
TStr::Fmt(
"%d or %d not a node.", SrcNId, DstNId).CStr());
948 IAssertR(IsEdge(SrcNId, DstNId),
TStr::Fmt(
"Edge between %d and %d does not exist.", SrcNId, DstNId).CStr());
949 GetEDat(SrcNId, DstNId) = EdgeDat;
952 template <
class TNodeData,
class TEdgeData>
954 if (! IsEdge(SrcNId, DstNId)) {
return false; }
955 const TNode& N = GetNode(SrcNId);
960 template <
class TNodeData,
class TEdgeData>
962 Assert(IsEdge(SrcNId, DstNId));
963 TNode& N = GetNode(SrcNId);
967 template <
class TNodeData,
class TEdgeData>
969 Assert(IsEdge(SrcNId, DstNId));
970 const TNode& N = GetNode(SrcNId);
974 template <
class TNodeData,
class TEdgeData>
976 for (
TEdgeI EI = BegEI(); EI < EndEI(); EI++) {
981 template <
class TNodeData,
class TEdgeData>
983 const TNodeI SrcNI = GetNI(SrcNId);
987 int LValN=0, RValN=NIdDatV.
Len()-1;
988 while (RValN>=LValN){
989 int ValN=(LValN+RValN)/2;
990 if (DstNId==NIdDatV[ValN].Val1){ NodeN=ValN;
break; }
991 if (DstNId<NIdDatV[ValN].Val1){RValN=ValN-1;}
else {LValN=ValN+1;}
993 if (NodeN == -1) {
return EndEI(); }
994 else {
return TEdgeI(SrcNI, EndNI(), NodeN); }
997 template <
class TNodeData,
class TEdgeData>
1000 for (
int N=NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
1001 NIdV.
Add(NodeH.GetKey(N)); }
1004 template <
class TNodeData,
class TEdgeData>
1006 for (
int n = NodeH.FFirstKeyId(); NodeH.FNextKeyId(n);) {
1007 TNode& Node = NodeH[n];
1010 if (! OnlyNodeLinks && ! NodeH.IsKeyIdEqKeyN()) {
1015 template <
class TNodeData,
class TEdgeData>
1018 for (
int N = NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
1019 const TNode& Node = NodeH[N];
1021 const TStr Msg =
TStr::Fmt(
"Out-neighbor list of node %d is not sorted.", Node.
GetId());
1025 const TStr Msg =
TStr::Fmt(
"In-neighbor list of node %d is not sorted.", Node.
GetId());
1030 for (
int e = 0; e < Node.
GetOutDeg(); e++) {
1032 const TStr Msg =
TStr::Fmt(
"Out-edge %d --> %d: node %d does not exist.",
1036 if (e > 0 && prevNId == Node.
GetOutNId(e)) {
1037 const TStr Msg =
TStr::Fmt(
"Node %d has duplidate out-edge %d --> %d.",
1045 for (
int e = 0; e < Node.
GetInDeg(); e++) {
1047 const TStr Msg =
TStr::Fmt(
"In-edge %d <-- %d: node %d does not exist.",
1051 if (e > 0 && prevNId == Node.
GetInNId(e)) {
1052 const TStr Msg =
TStr::Fmt(
"Node %d has duplidate in-edge %d <-- %d.",
1073 template <
class TNodeData,
class TEdgeData>
1122 TEdge(
const int& EId,
const int& SourceNId,
const int& DestNId,
const TEdgeData& EdgeData) :
Id(EId),
SrcNId(SourceNId),
DstNId(DestNId),
EdgeDat(EdgeData) { }
1134 EdgeDat = TEdgeData(InStream);
1179 bool IsInNId(
const int& NId)
const;
1181 bool IsOutNId(
const int& NId)
const;
1271 LoadTNodeFunctor fn;
1299 return PNet(Network);
1325 int AddNode(
int NId,
const TNodeData& NodeDat);
1344 void SetNDat(
const int& NId,
const TNodeData& NodeDat);
1363 int AddEdge(
const int& SrcNId,
const int& DstNId,
int EId = -1);
1370 int AddEdge(
const int& SrcNId,
const int& DstNId,
int EId,
const TEdgeData& EdgeDat);
1372 int AddEdge(
const TEdgeI& EdgeI) {
return AddEdge(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), EdgeI.GetId(), EdgeI.GetDat()); }
1380 void DelEdge(
const int& SrcNId,
const int& DstNId,
const bool& IsDir =
true);
1384 bool IsEdge(
const int& SrcNId,
const int& DstNId,
const bool& IsDir =
true)
const {
int EId;
return IsEdge(SrcNId, DstNId, EId, IsDir); }
1386 bool IsEdge(
const int& SrcNId,
const int& DstNId,
int& EId,
const bool& IsDir =
true)
const;
1387 int GetEId(
const int& SrcNId,
const int& DstNId)
const {
int EId;
return IsEdge(SrcNId, DstNId, EId)?EId:-1; }
1395 TEdgeI
GetEI(
const int& SrcNId,
const int& DstNId)
const {
return GetEI(
GetEId(SrcNId, DstNId)); }
1397 void SetEDat(
const int& EId,
const TEdgeData& EdgeDat);
1423 void Reserve(
const int& Nodes,
const int& Edges) {
1424 if (Nodes>0) {
NodeH.
Gen(Nodes/2); }
if (Edges>0) {
EdgeH.
Gen(Edges/2); } }
1439 void Defrag(
const bool& OnlyNodeLinks=
false);
1444 bool IsOk(
const bool& ThrowExcept=
true)
const;
1457 template <
class TNodeData,
class TEdgeData>
1462 template <
class TNodeData,
class TEdgeData>
1472 template <
class TNodeData,
class TEdgeData>
1482 template <
class TNodeData,
class TEdgeData>
1494 template <
class TNodeData,
class TEdgeData>
1499 if (
IsNode(NId)) {
return -1;}
1506 template <
class TNodeData,
class TEdgeData>
1518 template <
class TNodeData,
class TEdgeData>
1521 for (
int out = 0; out < Node.
GetOutDeg(); out++) {
1528 for (
int in = 0; in < Node.
GetInDeg(); in++) {
1538 template <
class TNodeData,
class TEdgeData>
1544 template <
class TNodeData,
class TEdgeData>
1548 const int Src = EI.GetSrcNId();
1549 const int Dst = EI.GetDstNId();
1553 return UniqESet.
Len();
1556 template <
class TNodeData,
class TEdgeData>
1568 template <
class TNodeData,
class TEdgeData>
1580 template <
class TNodeData,
class TEdgeData>
1590 template <
class TNodeData,
class TEdgeData>
1599 template <
class TNodeData,
class TEdgeData>
1601 if (!
IsNode(SrcNId)) {
return false; }
1602 if (!
IsNode(DstNId)) {
return false; }
1607 EId = Edge.
GetId();
return true; }
1613 EId = Edge.
GetId();
return true; }
1619 template <
class TNodeData,
class TEdgeData>
1625 template <
class TNodeData,
class TEdgeData>
1633 template <
class TNodeData,
class TEdgeData>
1641 template <
class TNodeData,
class TEdgeData>
1649 template <
class TNodeData,
class TEdgeData>
1659 template <
class TNodeData,
class TEdgeData>
1674 for (
int e = 0; e < Node.
GetOutDeg(); e++) {
1679 if (e > 0 && prevEId == Node.
GetOutEId(e)) {
1687 for (
int e = 0; e < Node.
GetInDeg(); e++) {
1692 if (e > 0 && prevEId == Node.
GetInEId(e)) {
1751 TNode() : Id(-1), InEIdV(), OutEIdV() { }
1752 TNode(
const int& NId) : Id(NId), InEIdV(), OutEIdV() { }
1753 TNode(
const TNode& Node) : Id(Node.Id), InEIdV(Node.InEIdV), OutEIdV(Node.OutEIdV) { }
1755 void Save(
TSOut& SOut)
const { Id.Save(SOut); InEIdV.Save(SOut); OutEIdV.Save(SOut); }
1757 int GetDeg()
const {
return GetInDeg() + GetOutDeg(); }
1760 int GetInEId(
const int& EdgeN)
const {
return InEIdV[EdgeN]; }
1761 int GetOutEId(
const int& EdgeN)
const {
return OutEIdV[EdgeN]; }
1762 int GetNbrEId(
const int& EdgeN)
const {
return EdgeN<GetOutDeg()?GetOutEId(EdgeN):GetInEId(EdgeN-GetOutDeg()); }
1763 bool IsInEId(
const int& EId)
const {
return InEIdV.SearchBin(EId) != -1; }
1764 bool IsOutEId(
const int& EId)
const {
return OutEIdV.SearchBin(EId) != -1; }
1767 InEIdV.LoadShM(MStream);
1768 OutEIdV.LoadShM(MStream);
1776 TEdge() : Id(-1), SrcNId(-1), DstNId(-1) { }
1777 TEdge(
const int& EId,
const int& SourceNId,
const int& DestNId) : Id(EId), SrcNId(SourceNId), DstNId(DestNId) { }
1778 TEdge(
const TEdge& Edge) : Id(Edge.Id), SrcNId(Edge.SrcNId), DstNId(Edge.DstNId) { }
1780 void Save(
TSOut& SOut)
const { Id.Save(SOut); SrcNId.Save(SOut); DstNId.Save(SOut); }
1785 Id =
TInt(InStream);
1786 SrcNId =
TInt(InStream);
1787 DstNId =
TInt(InStream);
1803 TNodeI& operator++ (
int) { NodeHI++;
return *
this; }
1804 bool operator < (
const TNodeI& NodeI)
const {
return NodeHI < NodeI.
NodeHI; }
1805 bool operator == (
const TNodeI& NodeI)
const {
return NodeHI == NodeI.
NodeHI; }
1807 int GetId()
const {
return NodeHI.GetDat().GetId(); }
1809 int GetDeg()
const {
return NodeHI.GetDat().GetDeg(); }
1811 int GetInDeg()
const {
return NodeHI.GetDat().GetInDeg(); }
1813 int GetOutDeg()
const {
return NodeHI.GetDat().GetOutDeg(); }
1817 int GetInNId(
const int& EdgeN)
const {
return Graph->GetEdge(NodeHI.GetDat().GetInEId(EdgeN)).GetSrcNId(); }
1821 int GetOutNId(
const int& EdgeN)
const {
return Graph->GetEdge(NodeHI.GetDat().GetOutEId(EdgeN)).GetDstNId(); }
1827 bool IsInNId(
const int& NId)
const;
1829 bool IsOutNId(
const int& NId)
const;
1831 bool IsNbrNId(
const int& NId)
const {
return IsOutNId(NId) || IsInNId(NId); }
1833 int GetInEId(
const int& EdgeN)
const {
return NodeHI.GetDat().GetInEId(EdgeN); }
1835 int GetOutEId(
const int& EdgeN)
const {
return NodeHI.GetDat().GetOutEId(EdgeN); }
1837 int GetNbrEId(
const int& EdgeN)
const {
return NodeHI.GetDat().GetNbrEId(EdgeN); }
1839 bool IsInEId(
const int& EId)
const {
return NodeHI.GetDat().IsInEId(EId); }
1841 bool IsOutEId(
const int& EId)
const {
return NodeHI.GetDat().IsOutEId(EId); }
1843 bool IsNbrEId(
const int& EId)
const {
return IsInEId(EId) || IsOutEId(EId); }
1878 TEdgeI& operator++ (
int) { EdgeHI++;
return *
this; }
1879 bool operator < (
const TEdgeI& EdgeI)
const {
return EdgeHI < EdgeI.
EdgeHI; }
1880 bool operator == (
const TEdgeI& EdgeI)
const {
return EdgeHI == EdgeI.
EdgeHI; }
1882 int GetId()
const {
return EdgeHI.GetDat().GetId(); }
1884 int GetSrcNId()
const {
return EdgeHI.GetDat().GetSrcNId(); }
1886 int GetDstNId()
const {
return EdgeHI.GetDat().GetDstNId(); }
1920 TAIntI(
const TIntVecIter& HIter,
TStr attribute,
bool isEdgeIter,
const TNEANet* GraphPt) : HI(HIter), attr(), Graph(GraphPt) { isNode = !isEdgeIter; attr = attribute; }
1923 bool operator < (
const TAIntI& I)
const {
return HI < I.
HI; }
1924 bool operator == (
const TAIntI& I)
const {
return HI == I.
HI; }
1928 bool IsDeleted()
const {
return isNode ? GetDat() == Graph->GetIntAttrDefaultN(attr) : GetDat() == Graph->GetIntAttrDefaultE(attr); };
1944 TAIntVI() : HI(), IsDense(), HHI(), attr(), Graph(NULL) { }
1946 isNode = !isEdgeIter; attr = attribute;
1948 TAIntVI(
const TAIntVI& I) : HI(I.HI), IsDense(I.IsDense), HHI(I.HHI), attr(I.attr), Graph(I.Graph) { isNode = I.
isNode; }
1950 bool operator < (
const TAIntVI& I)
const {
return HI == I.
HI ? HHI < I.
HHI : HI < I.
HI; }
1951 bool operator == (
const TAIntVI& I)
const {
return HI == I.
HI && HHI == I.
HHI; }
1968 TAStrI(
const TStrVecIter& HIter,
TStr attribute,
bool isEdgeIter,
const TNEANet* GraphPt) : HI(HIter), attr(), Graph(GraphPt) { isNode = !isEdgeIter; attr = attribute; }
1971 bool operator < (
const TAStrI& I)
const {
return HI < I.
HI; }
1972 bool operator == (
const TAStrI& I)
const {
return HI == I.
HI; }
1976 bool IsDeleted()
const {
return isNode ? GetDat() == Graph->GetStrAttrDefaultN(attr) : GetDat() == Graph->GetStrAttrDefaultE(attr); };
1991 TAFltI(
const TFltVecIter& HIter,
TStr attribute,
bool isEdgeIter,
const TNEANet* GraphPt) : HI(HIter), attr(), Graph(GraphPt) { isNode = !isEdgeIter; attr = attribute; }
1994 bool operator < (
const TAFltI& I)
const {
return HI < I.
HI; }
1995 bool operator == (
const TAFltI& I)
const {
return HI == I.
HI; }
1999 bool IsDeleted()
const {
return isNode ? GetDat() == Graph->GetFltAttrDefaultN(attr) : GetDat() == Graph->GetFltAttrDefaultE(attr); };
2056 template<
typename TElem>
2064 template<
typename TElem>
2067 n->LoadShM(ShMIn, f);
2074 template<
typename TElem>
2077 n->LoadShM(ShMIn, f);
2084 if (!KeyToDenseN.IsKey(attr))
return -1;
2085 if (KeyToDenseN.GetDat(attr))
return 1;
2090 if (!KeyToDenseE.IsKey(attr))
return -1;
2091 if (KeyToDenseE.GetDat(attr))
return 1;
2098 KeyToIndexTypeN(), KeyToIndexTypeE(), KeyToDenseN(), KeyToDenseE(), IntDefaultsN(), IntDefaultsE(),
2099 StrDefaultsN(), StrDefaultsE(), FltDefaultsN(), FltDefaultsE(),
2100 VecOfIntVecsN(), VecOfIntVecsE(), VecOfStrVecsN(), VecOfStrVecsE(),
2101 VecOfFltVecsN(), VecOfFltVecsE(), VecOfIntVecVecsN(), VecOfIntVecVecsE(),
2102 VecOfIntHashVecsN(), VecOfIntHashVecsE(), SAttrN(), SAttrE(){ }
2105 MxNId(0),
MxEId(0),
NodeH(),
EdgeH(), KeyToIndexTypeN(), KeyToIndexTypeE(), KeyToDenseN(), KeyToDenseE(),
2106 IntDefaultsN(), IntDefaultsE(), StrDefaultsN(), StrDefaultsE(),
2107 FltDefaultsN(), FltDefaultsE(), VecOfIntVecsN(), VecOfIntVecsE(),
2108 VecOfStrVecsN(), VecOfStrVecsE(), VecOfFltVecsN(), VecOfFltVecsE(), VecOfIntVecVecsN(), VecOfIntVecVecsE(),
2109 VecOfIntHashVecsN(), VecOfIntHashVecsE(), SAttrN(), SAttrE()
2112 NodeH(Graph.
NodeH),
EdgeH(Graph.
EdgeH), KeyToIndexTypeN(), KeyToIndexTypeE(), KeyToDenseN(), KeyToDenseE(),
2113 IntDefaultsN(), IntDefaultsE(), StrDefaultsN(), StrDefaultsE(),
2114 FltDefaultsN(), FltDefaultsE(), VecOfIntVecsN(), VecOfIntVecsE(),
2115 VecOfStrVecsN(), VecOfStrVecsE(), VecOfFltVecsN(), VecOfFltVecsE(), VecOfIntVecVecsN(), VecOfIntVecVecsE(),
2116 VecOfIntHashVecsN(), VecOfIntHashVecsE(), SAttrN(), SAttrE() { }
2119 KeyToIndexTypeN(SIn), KeyToIndexTypeE(SIn), KeyToDenseN(SIn), KeyToDenseE(SIn), IntDefaultsN(SIn), IntDefaultsE(SIn),
2120 StrDefaultsN(SIn), StrDefaultsE(SIn), FltDefaultsN(SIn), FltDefaultsE(SIn),
2121 VecOfIntVecsN(SIn), VecOfIntVecsE(SIn), VecOfStrVecsN(SIn),VecOfStrVecsE(SIn),
2122 VecOfFltVecsN(SIn), VecOfFltVecsE(SIn), VecOfIntVecVecsN(SIn), VecOfIntVecVecsE(SIn), VecOfIntHashVecsN(SIn), VecOfIntHashVecsE(SIn),
2123 SAttrN(SIn), SAttrE(SIn) { }
2126 NodeH(Graph.
NodeH),
EdgeH(Graph.
EdgeH), KeyToIndexTypeN(), KeyToIndexTypeE(Graph.KeyToIndexTypeE), KeyToDenseN(), KeyToDenseE(Graph.KeyToDenseE),
2127 IntDefaultsN(Graph.IntDefaultsN), IntDefaultsE(Graph.IntDefaultsE), StrDefaultsN(Graph.StrDefaultsN), StrDefaultsE(Graph.StrDefaultsE),
2128 FltDefaultsN(Graph.FltDefaultsN), FltDefaultsE(Graph.FltDefaultsE), VecOfIntVecsN(Graph.VecOfIntVecsN), VecOfIntVecsE(Graph.VecOfIntVecsE),
2129 VecOfStrVecsN(Graph.VecOfStrVecsN), VecOfStrVecsE(Graph.VecOfStrVecsE), VecOfFltVecsN(Graph.VecOfFltVecsN), VecOfFltVecsE(Graph.VecOfFltVecsE),
2130 VecOfIntVecVecsN(), VecOfIntVecVecsE(Graph.VecOfIntVecVecsE), VecOfIntHashVecsN(), VecOfIntHashVecsE(Graph.VecOfIntHashVecsE) { }
2132 NodeH(Graph.
NodeH),
EdgeH(Graph.
EdgeH), KeyToIndexTypeN(Graph.KeyToIndexTypeN), KeyToIndexTypeE(Graph.KeyToIndexTypeE), KeyToDenseN(Graph.KeyToDenseN), KeyToDenseE(Graph.KeyToDenseE),
2133 IntDefaultsN(Graph.IntDefaultsN), IntDefaultsE(Graph.IntDefaultsE), StrDefaultsN(Graph.StrDefaultsN), StrDefaultsE(Graph.StrDefaultsE),
2134 FltDefaultsN(Graph.FltDefaultsN), FltDefaultsE(Graph.FltDefaultsE), VecOfIntVecsN(Graph.VecOfIntVecsN), VecOfIntVecsE(Graph.VecOfIntVecsE),
2135 VecOfStrVecsN(Graph.VecOfStrVecsN), VecOfStrVecsE(Graph.VecOfStrVecsE), VecOfFltVecsN(Graph.VecOfFltVecsN), VecOfFltVecsE(Graph.VecOfFltVecsE),
2136 VecOfIntVecVecsN(Graph.VecOfIntVecVecsN), VecOfIntVecVecsE(Graph.VecOfIntVecVecsE), VecOfIntHashVecsN(Graph.VecOfIntHashVecsN), VecOfIntHashVecsE(Graph.VecOfIntHashVecsE), SAttrN(Graph.SAttrN), SAttrE(Graph.SAttrE) { }
2142 KeyToIndexTypeN.Save(SOut); KeyToIndexTypeE.Save(SOut);
2143 KeyToDenseN.Save(SOut); KeyToDenseE.Save(SOut);
2144 IntDefaultsN.Save(SOut); IntDefaultsE.Save(SOut);
2145 StrDefaultsN.Save(SOut); StrDefaultsE.Save(SOut);
2146 FltDefaultsN.Save(SOut); FltDefaultsE.Save(SOut);
2147 VecOfIntVecsN.Save(SOut); VecOfIntVecsE.Save(SOut);
2148 VecOfStrVecsN.Save(SOut); VecOfStrVecsE.Save(SOut);
2149 VecOfFltVecsN.Save(SOut); VecOfFltVecsE.Save(SOut);
2150 VecOfIntVecVecsN.Save(SOut); VecOfIntVecVecsE.Save(SOut);
2151 VecOfIntHashVecsN.Save(SOut); VecOfIntHashVecsE.Save(SOut);
2152 SAttrN.Save(SOut); SAttrE.Save(SOut); }
2156 KeyToIndexTypeN.Save(SOut); KeyToIndexTypeE.Save(SOut);
2157 IntDefaultsN.Save(SOut); IntDefaultsE.Save(SOut);
2158 StrDefaultsN.Save(SOut); StrDefaultsE.Save(SOut);
2159 FltDefaultsN.Save(SOut); FltDefaultsE.Save(SOut);
2160 VecOfIntVecsN.Save(SOut); VecOfIntVecsE.Save(SOut);
2161 VecOfStrVecsN.Save(SOut); VecOfStrVecsE.Save(SOut);
2162 VecOfFltVecsN.Save(SOut); VecOfFltVecsE.Save(SOut); }
2166 KeyToIndexTypeN.Save(SOut); KeyToIndexTypeE.Save(SOut);
2167 IntDefaultsN.Save(SOut); IntDefaultsE.Save(SOut);
2168 StrDefaultsN.Save(SOut); StrDefaultsE.Save(SOut);
2169 FltDefaultsN.Save(SOut); FltDefaultsE.Save(SOut);
2170 VecOfIntVecsN.Save(SOut); VecOfIntVecsE.Save(SOut);
2171 VecOfStrVecsN.Save(SOut); VecOfStrVecsE.Save(SOut);
2172 VecOfFltVecsN.Save(SOut); VecOfFltVecsE.Save(SOut);
2173 VecOfIntVecVecsN.Save(SOut); VecOfIntVecVecsE.Save(SOut);
2174 SAttrN.Save(SOut); SAttrE.Save(SOut); }
2186 Graph->MxNId.Load(SIn); Graph->MxEId.Load(SIn);
2187 Graph->NodeH.Load(SIn); Graph->EdgeH.Load(SIn);
2188 Graph->KeyToIndexTypeN.Load(SIn); Graph->KeyToIndexTypeE.Load(SIn);
2189 Graph->IntDefaultsN.Load(SIn); Graph->IntDefaultsE.Load(SIn);
2190 Graph->StrDefaultsN.Load(SIn); Graph->StrDefaultsE.Load(SIn);
2191 Graph->FltDefaultsN.Load(SIn); Graph->FltDefaultsE.Load(SIn);
2192 Graph->VecOfIntVecsN.Load(SIn); Graph->VecOfIntVecsE.Load(SIn);
2193 Graph->VecOfStrVecsN.Load(SIn); Graph->VecOfStrVecsE.Load(SIn);
2194 Graph->VecOfFltVecsN.Load(SIn); Graph->VecOfFltVecsE.Load(SIn);
2201 Graph->MxNId.Load(SIn); Graph->MxEId.Load(SIn);
2202 Graph->NodeH.Load(SIn); Graph->EdgeH.Load(SIn);
2203 Graph->KeyToIndexTypeN.Load(SIn); Graph->KeyToIndexTypeE.Load(SIn);
2204 Graph->IntDefaultsN.Load(SIn); Graph->IntDefaultsE.Load(SIn);
2205 Graph->StrDefaultsN.Load(SIn); Graph->StrDefaultsE.Load(SIn);
2206 Graph->FltDefaultsN.Load(SIn); Graph->FltDefaultsE.Load(SIn);
2207 Graph->VecOfIntVecsN.Load(SIn); Graph->VecOfIntVecsE.Load(SIn);
2208 Graph->VecOfStrVecsN.Load(SIn); Graph->VecOfStrVecsE.Load(SIn);
2209 Graph->VecOfFltVecsN.Load(SIn); Graph->VecOfFltVecsE.Load(SIn);
2210 Graph->VecOfIntVecVecsN.Load(SIn); Graph->VecOfIntVecVecsE.Load(SIn);
2211 Graph->SAttrN.Load(SIn); Graph->SAttrE.Load(SIn);
2229 TInt VecLength = VecOfIntVecVecsN.Len();
2231 if (VecLength != 0) {
2233 for (iter = KeyToIndexTypeN.
BegI(); !iter.IsEnd(); iter=iter.Next()) {
2237 for (
int i=0; i<VecOfIntVecVecsN[index].Len(); i++) {
2238 if(VecOfIntVecVecsN[index][i].Len() > 0) {
2239 VecOfIntHashVecsN[index].AddDat(
TInt(i), VecOfIntVecVecsN[index][i]);
2242 KeyToDenseN.AddDat(attribute,
TBool(
false));
2246 VecOfIntVecVecsN.Clr();
2248 VecLength = VecOfIntVecVecsE.Len();
2249 if (VecLength != 0) {
2251 for (iter = KeyToIndexTypeE.
BegI(); !iter.IsEnd(); iter=iter.Next()) {
2255 for (
int i=0; i<VecOfIntVecVecsE[index].Len(); i++) {
2256 if(VecOfIntVecVecsE[index][i].Len() > 0) {
2257 VecOfIntHashVecsE[index].AddDat(
TInt(i), VecOfIntVecVecsE[index][i]);
2260 KeyToDenseE.AddDat(attribute,
TBool(
false));
2264 VecOfIntVecVecsE.Clr();
2294 virtual void DelNode(
const int& NId);
2307 return TAIntI(VecOfIntVecsN[KeyToIndexTypeN.GetDat(attr).Val2].BegI(), attr,
false,
this); }
2310 return TAIntI(VecOfIntVecsN[KeyToIndexTypeN.GetDat(attr).Val2].EndI(), attr,
false,
this); }
2313 return TAIntI(VecOfIntVecsN[KeyToIndexTypeN.GetDat(attr).Val2].GetI(
NodeH.
GetKeyId(NId)), attr,
false,
this); }
2319 TInt location = CheckDenseOrSparseN(attr);
2320 TBool IsDense =
true;
2321 if (location != -1) {
2322 TInt index = KeyToIndexTypeN.GetDat(attr).Val2;
2323 if (location == 1) {
2324 HI = VecOfIntVecVecsN[index].
BegI();
2327 HHI = VecOfIntHashVecsN[index].
BegI();
2330 return TAIntVI(HI, HHI, attr,
false,
this, IsDense);
2336 TInt location = CheckDenseOrSparseN(attr);
2337 TBool IsDense =
true;
2338 if (location != -1) {
2339 TInt index = KeyToIndexTypeN.GetDat(attr).Val2;
2340 if (location == 1) {
2341 HI = VecOfIntVecVecsN[index].
EndI();
2344 HHI = VecOfIntHashVecsN[index].
EndI();
2347 return TAIntVI(HI, HHI, attr,
false,
this, IsDense);
2355 TInt location = CheckDenseOrSparseN(attr);
2356 TBool IsDense =
true;
2357 if (location != -1) {
2358 TInt index = KeyToIndexTypeN.GetDat(attr).Val2;
2359 if (location == 1) {
2366 return TAIntVI(HI, HHI, attr,
false,
this, IsDense);
2374 return TAStrI(VecOfStrVecsN[KeyToIndexTypeN.GetDat(attr).Val2].BegI(), attr,
false,
this); }
2377 return TAStrI(VecOfStrVecsN[KeyToIndexTypeN.GetDat(attr).Val2].EndI(), attr,
false,
this); }
2380 return TAStrI(VecOfStrVecsN[KeyToIndexTypeN.GetDat(attr).Val2].GetI(
NodeH.
GetKeyId(NId)), attr,
false,
this); }
2383 return TAFltI(VecOfFltVecsN[KeyToIndexTypeN.GetDat(attr).Val2].BegI(), attr,
false,
this); }
2386 return TAFltI(VecOfFltVecsN[KeyToIndexTypeN.GetDat(attr).Val2].EndI(), attr,
false,
this); }
2389 return TAFltI(VecOfFltVecsN[KeyToIndexTypeN.GetDat(attr).Val2].GetI(
NodeH.
GetKeyId(NId)), attr,
false,
this); }
2393 AttrNameNI(NId, KeyToIndexTypeN.BegI(), Names);}
2397 AttrValueNI(NId, KeyToIndexTypeN.BegI(), Values);}
2402 IntAttrNameNI(NId, KeyToIndexTypeN.BegI(), Names);}
2406 IntAttrValueNI(NId, KeyToIndexTypeN.BegI(), Values);}
2412 IntVAttrNameNI(NId, KeyToIndexTypeN.BegI(), Names);}
2416 IntVAttrValueNI(NId, KeyToIndexTypeN.BegI(), Values);}
2422 StrAttrNameNI(NId, KeyToIndexTypeN.BegI(), Names);}
2426 StrAttrValueNI(NId, KeyToIndexTypeN.BegI(), Values);}
2430 FltAttrNameNI(NId, KeyToIndexTypeN.BegI(), Names);}
2434 FltAttrValueNI(NId, KeyToIndexTypeN.BegI(), Values);}
2439 AttrNameEI(EId, KeyToIndexTypeE.BegI(), Names);}
2443 AttrValueEI(EId, KeyToIndexTypeE.BegI(), Values);}
2447 IntAttrNameEI(EId, KeyToIndexTypeE.BegI(), Names);}
2451 IntAttrValueEI(EId, KeyToIndexTypeE.BegI(), Values);}
2457 IntVAttrNameEI(EId, KeyToIndexTypeE.BegI(), Names);}
2461 IntVAttrValueEI(EId, KeyToIndexTypeE.BegI(), Values);}
2467 StrAttrNameEI(EId, KeyToIndexTypeE.BegI(), Names);}
2471 StrAttrValueEI(EId, KeyToIndexTypeE.BegI(), Values);}
2475 FltAttrNameEI(EId, KeyToIndexTypeE.BegI(), Names);}
2479 FltAttrValueEI(EId, KeyToIndexTypeE.BegI(), Values);}
2484 return TAIntI(VecOfIntVecsE[KeyToIndexTypeE.GetDat(attr).Val2].BegI(), attr,
true,
this);
2488 return TAIntI(VecOfIntVecsE[KeyToIndexTypeE.GetDat(attr).Val2].EndI(), attr,
true,
this);
2492 return TAIntI(VecOfIntVecsE[KeyToIndexTypeE.GetDat(attr).Val2].GetI(
EdgeH.
GetKeyId(EId)), attr,
true,
this);
2499 TInt location = CheckDenseOrSparseE(attr);
2500 TBool IsDense =
true;
2501 if (location != -1) {
2502 TInt index = KeyToIndexTypeE.GetDat(attr).Val2;
2503 if (location == 1) {
2504 HI = VecOfIntVecVecsE[index].
BegI();
2507 HHI = VecOfIntHashVecsE[index].
BegI();
2510 return TAIntVI(HI, HHI, attr,
true,
this, IsDense);
2516 TInt location = CheckDenseOrSparseE(attr);
2517 TBool IsDense =
true;
2518 if (location != -1) {
2519 TInt index = KeyToIndexTypeE.GetDat(attr).Val2;
2520 if (location == 1) {
2521 HI = VecOfIntVecVecsE[index].
EndI();
2524 HHI = VecOfIntHashVecsE[index].
EndI();
2527 return TAIntVI(HI, HHI, attr,
true,
this, IsDense);
2533 TInt location = CheckDenseOrSparseE(attr);
2534 TBool IsDense =
true;
2535 if (location != -1) {
2536 TInt index = KeyToIndexTypeE.GetDat(attr).Val2;
2537 if (location == 1) {
2544 return TAIntVI(HI, HHI, attr,
true,
this, IsDense);
2549 return TAStrI(VecOfStrVecsE[KeyToIndexTypeE.GetDat(attr).Val2].BegI(), attr,
true,
this); }
2552 return TAStrI(VecOfStrVecsE[KeyToIndexTypeE.GetDat(attr).Val2].EndI(), attr,
true,
this);
2556 return TAStrI(VecOfStrVecsE[KeyToIndexTypeE.GetDat(attr).Val2].GetI(
EdgeH.
GetKeyId(EId)), attr,
true,
this);
2560 return TAFltI(VecOfFltVecsE[KeyToIndexTypeE.GetDat(attr).Val2].BegI(), attr,
true,
this);
2564 return TAFltI(VecOfFltVecsE[KeyToIndexTypeE.GetDat(attr).Val2].EndI(), attr,
true,
this);
2568 return TAFltI(VecOfFltVecsE[KeyToIndexTypeE.GetDat(attr).Val2].GetI(
EdgeH.
GetKeyId(EId)), attr,
true,
this);
2583 int AddEdge(
const int& SrcNId,
const int& DstNId,
int EId = -1);
2593 void DelEdge(
const int& SrcNId,
const int& DstNId,
const bool& IsDir =
true);
2597 bool IsEdge(
const int& SrcNId,
const int& DstNId,
const bool& IsDir =
true)
const {
int EId;
return IsEdge(SrcNId, DstNId, EId, IsDir); }
2599 bool IsEdge(
const int& SrcNId,
const int& DstNId,
int& EId,
const bool& IsDir =
true)
const;
2601 int GetEId(
const int& SrcNId,
const int& DstNId)
const {
int EId;
return IsEdge(SrcNId, DstNId, EId)?EId:-1; }
2628 KeyToIndexTypeN.Clr(); KeyToIndexTypeE.Clr(); IntDefaultsN.Clr(); IntDefaultsE.Clr();
2629 StrDefaultsN.Clr(); StrDefaultsE.Clr(); FltDefaultsN.Clr(); FltDefaultsE.Clr();
2630 VecOfIntVecsN.Clr(); VecOfIntVecsE.Clr(); VecOfStrVecsN.Clr(); VecOfStrVecsE.Clr();
2631 VecOfFltVecsN.Clr(); VecOfFltVecsE.Clr(); VecOfIntVecVecsN.Clr(); VecOfIntVecVecsE.Clr();
2632 SAttrN.Clr(); SAttrE.Clr();}
2634 void Reserve(
const int& Nodes,
const int& Edges) {
2635 if (Nodes>0) {
NodeH.
Gen(Nodes/2); }
if (Edges>0) {
EdgeH.
Gen(Edges/2); } }
2642 void Defrag(
const bool& OnlyNodeLinks=
false);
2647 bool IsOk(
const bool& ThrowExcept=
true)
const;
2649 void Dump(FILE *OutF=stdout)
const;
2655 int AddIntAttrDatN(
const int& NId,
const TInt& value,
const TStr& attr);
2660 int AddStrAttrDatN(
const int& NId,
const TStr& value,
const TStr& attr);
2665 int AddFltAttrDatN(
const int& NId,
const TFlt& value,
const TStr& attr);
2670 int AddIntVAttrDatN(
const int& NId,
const TIntV& value,
const TStr& attr,
TBool UseDense=
true);
2673 int AppendIntVAttrDatN(
const int& NId,
const TInt& value,
const TStr& attr,
TBool UseDense=
true);
2676 int DelFromIntVAttrDatN(
const int& NId,
const TInt& value,
const TStr& attr);
2681 int AddIntAttrDatE(
const int& EId,
const TInt& value,
const TStr& attr);
2686 int AddStrAttrDatE(
const int& EId,
const TStr& value,
const TStr& attr);
2691 int AddFltAttrDatE(
const int& EId,
const TFlt& value,
const TStr& attr);
2696 int AddIntVAttrDatE(
const int& EId,
const TIntV& value,
const TStr& attr,
TBool UseDense=
true);
2699 int AppendIntVAttrDatE(
const int& EId,
const TInt& value,
const TStr& attr,
TBool UseDense=
true);
2702 TInt GetIntAttrDatN(
const int& NId,
const TStr& attr);
2706 TStr GetStrAttrDatN(
const int& NId,
const TStr& attr);
2709 TFlt GetFltAttrDatN(
const int& NId,
const TStr& attr);
2712 TIntV GetIntVAttrDatN(
const int& NId,
const TStr& attr)
const;
2715 int GetIntAttrIndN(
const TStr& attr);
2717 int GetAttrIndN(
const TStr& attr);
2722 TInt GetIntAttrIndDatN(
const int& NId,
const int& index);
2727 TStr GetStrAttrIndDatN(
const int& NId,
const int& index);
2732 TFlt GetFltAttrIndDatN(
const int& NId,
const int& index);
2736 TInt GetIntAttrDatE(
const int& EId,
const TStr& attr);
2739 TStr GetStrAttrDatE(
const int& EId,
const TStr& attr);
2742 TFlt GetFltAttrDatE(
const int& EId,
const TStr& attr);
2745 TIntV GetIntVAttrDatE(
const int& EId,
const TStr& attr);
2748 int GetIntAttrIndE(
const TStr& attr);
2750 int GetAttrIndE(
const TStr& attr);
2755 TInt GetIntAttrIndDatE(
const int& EId,
const int& index);
2760 TFlt GetFltAttrIndDatE(
const int& EId,
const int& index);
2765 TStr GetStrAttrIndDatE(
const int& EId,
const int& index);
2769 int DelAttrDatN(
const int& NId,
const TStr& attr);
2772 int DelAttrDatE(
const int& EId,
const TStr& attr);
2781 int AddIntVAttrN(
const TStr& attr,
TBool UseDense=
true);
2790 int AddIntVAttrE(
const TStr& attr,
TBool UseDense=
true);
2793 int DelAttrN(
const TStr& attr);
2795 int DelAttrE(
const TStr& attr);
2798 bool IsAttrDeletedN(
const int& NId,
const TStr& attr)
const;
2800 bool IsIntAttrDeletedN(
const int& NId,
const TStr& attr)
const;
2802 bool IsIntVAttrDeletedN(
const int& NId,
const TStr& attr)
const;
2804 bool IsStrAttrDeletedN(
const int& NId,
const TStr& attr)
const;
2806 bool IsFltAttrDeletedN(
const int& NId,
const TStr& attr)
const;
2811 bool NodeAttrIsIntDeleted(
const int& NId,
const TStrIntPrH::TIter& NodeHI)
const;
2813 bool NodeAttrIsIntVDeleted(
const int& NId,
const TStrIntPrH::TIter& NodeHI)
const;
2815 bool NodeAttrIsStrDeleted(
const int& NId,
const TStrIntPrH::TIter& NodeHI)
const;
2817 bool NodeAttrIsFltDeleted(
const int& NId,
const TStrIntPrH::TIter& NodeHI)
const;
2820 bool IsAttrDeletedE(
const int& EId,
const TStr& attr)
const;
2822 bool IsIntAttrDeletedE(
const int& EId,
const TStr& attr)
const;
2824 bool IsIntVAttrDeletedE(
const int& EId,
const TStr& attr)
const;
2826 bool IsStrAttrDeletedE(
const int& EId,
const TStr& attr)
const;
2828 bool IsFltAttrDeletedE(
const int& EId,
const TStr& attr)
const;
2833 bool EdgeAttrIsIntDeleted(
const int& EId,
const TStrIntPrH::TIter& EdgeHI)
const;
2835 bool EdgeAttrIsIntVDeleted(
const int& EId,
const TStrIntPrH::TIter& EdgeHI)
const;
2837 bool EdgeAttrIsStrDeleted(
const int& EId,
const TStrIntPrH::TIter& EdgeHI)
const;
2839 bool EdgeAttrIsFltDeleted(
const int& EId,
const TStrIntPrH::TIter& EdgeHI)
const;
2847 TFlt GetWeightOutEdges(
const TNodeI& NI,
const TStr& attr);
2849 bool IsFltAttrE(
const TStr& attr);
2851 bool IsIntAttrE(
const TStr& attr);
2853 bool IsStrAttrE(
const TStr& attr);
2857 int GetFltKeyIdE(
const int& EId);
2860 void GetWeightOutEdgesV(
TFltV& OutWeights,
const TFltV& AttrVal) ;
2862 void GetAttrNNames(
TStrV& IntAttrNames,
TStrV& FltAttrNames,
TStrV& StrAttrNames)
const;
2864 void GetAttrENames(
TStrV& IntAttrNames,
TStrV& FltAttrNames,
TStrV& StrAttrNames)
const;
2868 int AddSAttrDatN(
const TInt& NId,
const TStr& AttrName,
const TInt& Val);
2870 int AddSAttrDatN(
const TInt& NId,
const TInt& AttrId,
const TInt& Val);
2874 return AddSAttrDatN(NodeI.
GetId(), AttrName, Val);
2878 return AddSAttrDatN(NodeI.
GetId(), AttrId, Val);
2882 int AddSAttrDatN(
const TInt& NId,
const TStr& AttrName,
const TFlt& Val);
2884 int AddSAttrDatN(
const TInt& NId,
const TInt& AttrId,
const TFlt& Val);
2888 return AddSAttrDatN(NodeI.
GetId(), AttrName, Val);
2892 return AddSAttrDatN(NodeI.
GetId(), AttrId, Val);
2896 int AddSAttrDatN(
const TInt& NId,
const TStr& AttrName,
const TStr& Val);
2898 int AddSAttrDatN(
const TInt& NId,
const TInt& AttrId,
const TStr& Val);
2902 return AddSAttrDatN(NodeI.
GetId(), AttrName, Val);
2906 return AddSAttrDatN(NodeI.
GetId(), AttrId, Val);
2910 int GetSAttrDatN(
const TInt& NId,
const TStr& AttrName,
TInt& ValX)
const;
2912 int GetSAttrDatN(
const TInt& NId,
const TInt& AttrId,
TInt& ValX)
const;
2916 return GetSAttrDatN(NodeI.
GetId(), AttrName, ValX);
2920 return GetSAttrDatN(NodeI.
GetId(), AttrId, ValX);
2924 int GetSAttrDatN(
const TInt& NId,
const TStr& AttrName,
TFlt& ValX)
const;
2926 int GetSAttrDatN(
const TInt& NId,
const TInt& AttrId,
TFlt& ValX)
const;
2930 return GetSAttrDatN(NodeI.
GetId(), AttrName, ValX);
2934 return GetSAttrDatN(NodeI.
GetId(), AttrId, ValX);
2938 int GetSAttrDatN(
const TInt& NId,
const TStr& AttrName,
TStr& ValX)
const;
2940 int GetSAttrDatN(
const TInt& NId,
const TInt& AttrId,
TStr& ValX)
const;
2944 return GetSAttrDatN(NodeI.
GetId(), AttrName, ValX);
2948 return GetSAttrDatN(NodeI.
GetId(), AttrId, ValX);
2952 int DelSAttrDatN(
const TInt& NId,
const TStr& AttrName);
2954 int DelSAttrDatN(
const TInt& NId,
const TInt& AttrId);
2958 return DelSAttrDatN(NodeI.
GetId(), AttrName);
2962 return DelSAttrDatN(NodeI.
GetId(), AttrId);
2969 return GetSAttrVN(NodeI.
GetId(), AttrType, AttrV);
2973 int GetIdVSAttrN(
const TStr& AttrName,
TIntV& IdV)
const;
2975 int GetIdVSAttrN(
const TInt& AttrId,
TIntV& IdV)
const;
2986 int AddSAttrDatE(
const TInt& EId,
const TStr& AttrName,
const TInt& Val);
2988 int AddSAttrDatE(
const TInt& EId,
const TInt& AttrId,
const TInt& Val);
2992 return AddSAttrDatE(EdgeI.
GetId(), AttrName, Val);
2996 return AddSAttrDatE(EdgeI.
GetId(), AttrId, Val);
3000 int AddSAttrDatE(
const TInt& EId,
const TStr& AttrName,
const TFlt& Val);
3002 int AddSAttrDatE(
const TInt& EId,
const TInt& AttrId,
const TFlt& Val);
3006 return AddSAttrDatE(EdgeI.
GetId(), AttrName, Val);
3010 return AddSAttrDatE(EdgeI.
GetId(), AttrId, Val);
3014 int AddSAttrDatE(
const TInt& EId,
const TStr& AttrName,
const TStr& Val);
3016 int AddSAttrDatE(
const TInt& EId,
const TInt& AttrId,
const TStr& Val);
3020 return AddSAttrDatE(EdgeI.
GetId(), AttrName, Val);
3024 return AddSAttrDatE(EdgeI.
GetId(), AttrId, Val);
3028 int GetSAttrDatE(
const TInt& EId,
const TStr& AttrName,
TInt& ValX)
const;
3030 int GetSAttrDatE(
const TInt& EId,
const TInt& AttrId,
TInt& ValX)
const;
3034 return GetSAttrDatE(EdgeI.
GetId(), AttrName, ValX);
3038 return GetSAttrDatE(EdgeI.
GetId(), AttrId, ValX);
3042 int GetSAttrDatE(
const TInt& EId,
const TStr& AttrName,
TFlt& ValX)
const;
3044 int GetSAttrDatE(
const TInt& EId,
const TInt& AttrId,
TFlt& ValX)
const;
3048 return GetSAttrDatE(EdgeI.
GetId(), AttrName, ValX);
3052 return GetSAttrDatE(EdgeI.
GetId(), AttrId, ValX);
3056 int GetSAttrDatE(
const TInt& EId,
const TStr& AttrName,
TStr& ValX)
const;
3058 int GetSAttrDatE(
const TInt& EId,
const TInt& AttrId,
TStr& ValX)
const;
3062 return GetSAttrDatE(EdgeI.
GetId(), AttrName, ValX);
3066 return GetSAttrDatE(EdgeI.
GetId(), AttrId, ValX);
3070 int DelSAttrDatE(
const TInt& EId,
const TStr& AttrName);
3072 int DelSAttrDatE(
const TInt& EId,
const TInt& AttrId);
3076 return DelSAttrDatE(EdgeI.
GetId(), AttrName);
3080 return DelSAttrDatE(EdgeI.
GetId(), AttrId);
3086 return GetSAttrVE(EdgeI.
GetId(), AttrType, AttrV);
3090 int GetIdVSAttrE(
const TStr& AttrName,
TIntV& IdV)
const;
3092 int GetIdVSAttrE(
const TInt& AttrId,
TIntV& IdV)
const;
3107 static PNEANet GetSmallGraph();
3156 TNode(
const int& NId) : Id(NId), NIdV() { }
3159 void Save(
TSOut& SOut)
const { Id.Save(SOut); NIdV.Save(SOut); }
3164 int GetInNId(
const int& NodeN)
const {
return GetNbrNId(NodeN); }
3165 int GetOutNId(
const int& NodeN)
const {
return GetNbrNId(NodeN); }
3166 int GetNbrNId(
const int& NodeN)
const {
return NIdV[NodeN]; }
3167 bool IsNbrNId(
const int& NId)
const {
return NIdV.SearchBin(NId)!=-1; }
3168 bool IsInNId(
const int& NId)
const {
return IsNbrNId(NId); }
3169 bool IsOutNId(
const int& NId)
const {
return IsNbrNId(NId); }
3175 NIdV.LoadShM(MStream);
3178 friend class TUndirNetMtx;
3192 TNodeI& operator++ (
int) { NodeHI++;
return *
this; }
3194 TNodeI& operator-- (
int) { NodeHI--;
return *
this; }
3197 bool operator < (
const TNodeI& NodeI)
const {
return NodeHI < NodeI.
NodeHI; }
3198 bool operator == (
const TNodeI& NodeI)
const {
return NodeHI == NodeI.
NodeHI; }
3201 int GetId()
const {
return NodeHI.GetDat().GetId(); }
3203 int GetDeg()
const {
return NodeHI.GetDat().GetDeg(); }
3205 int GetInDeg()
const {
return NodeHI.GetDat().GetInDeg(); }
3207 int GetOutDeg()
const {
return NodeHI.GetDat().GetOutDeg(); }
3214 int GetInNId(
const int& NodeN)
const {
return NodeHI.GetDat().GetInNId(NodeN); }
3219 int GetOutNId(
const int& NodeN)
const {
return NodeHI.GetDat().GetOutNId(NodeN); }
3224 int GetNbrNId(
const int& NodeN)
const {
return NodeHI.GetDat().GetNbrNId(NodeN); }
3226 bool IsInNId(
const int& NId)
const {
return NodeHI.GetDat().IsInNId(NId); }
3228 bool IsOutNId(
const int& NId)
const {
return NodeHI.GetDat().IsOutNId(NId); }
3230 bool IsNbrNId(
const int& NId)
const {
return NodeHI.GetDat().IsNbrNId(NId); }
3239 TEdgeI() : CurNode(), EndNode(), CurEdge(0) { }
3240 TEdgeI(
const TNodeI& NodeI,
const TNodeI& EndNodeI,
const int& EdgeN=0) : CurNode(NodeI), EndNode(EndNodeI), CurEdge(EdgeN) { }
3241 TEdgeI(
const TEdgeI& EdgeI) : CurNode(EdgeI.CurNode), EndNode(EdgeI.EndNode), CurEdge(EdgeI.CurEdge) { }
3244 TEdgeI& operator++ (
int) {
do { CurEdge++;
if (CurEdge >= CurNode.GetOutDeg()) { CurEdge=0; CurNode++;
while (CurNode < EndNode && CurNode.GetOutDeg()==0) { CurNode++; } } }
while (CurNode < EndNode && GetSrcNId()>GetDstNId());
return *
this; }
3252 int GetDstNId()
const {
return CurNode.GetOutNId(CurEdge); }
3275 NEdges =
TInt(ShMIn);
3284 explicit TUndirNet(
const int& Nodes,
const int& Edges) :
MxNId(0), NEdges(0), SAttrN(), SAttrE() {
Reserve(Nodes, Edges); }
3286 SAttrN(), SAttrE() { }
3291 SAttrN.Save(SOut); SAttrE.Save(SOut); }
3299 static PUndirNet
New(
const int& Nodes,
const int& Edges) {
return new TUndirNet(Nodes, Edges); }
3304 Graph->MxNId.Load(SIn); Graph->NEdges.Load(SIn); Graph->NodeH.Load(SIn);
return Graph;
3387 int AddEdge(
const int& SrcNId,
const int& DstNId);
3396 int AddEdgeUnchecked(
const int& SrcNId,
const int& DstNId);
3404 void DelEdge(
const int& SrcNId,
const int& DstNId);
3406 bool IsEdge(
const int& SrcNId,
const int& DstNId)
const;
3412 TEdgeI
GetEI(
const int& EId)
const;
3417 TEdgeI
GetEI(
const int& SrcNId,
const int& DstNId)
const;
3442 void Defrag(
const bool& OnlyNodeLinks=
false);
3447 bool IsOk(
const bool& ThrowExcept=
true)
const;
3449 void Dump(FILE *OutF=stdout)
const;
3457 static PUndirNet GetSmallGraph();
3460 int AddSAttrDatN(
const TInt& NId,
const TStr& AttrName,
const TInt& Val);
3462 int AddSAttrDatN(
const TInt& NId,
const TInt& AttrId,
const TInt& Val);
3466 return AddSAttrDatN(NodeI.
GetId(), AttrName, Val);
3470 return AddSAttrDatN(NodeI.
GetId(), AttrId, Val);
3474 int AddSAttrDatN(
const TInt& NId,
const TStr& AttrName,
const TFlt& Val);
3476 int AddSAttrDatN(
const TInt& NId,
const TInt& AttrId,
const TFlt& Val);
3480 return AddSAttrDatN(NodeI.
GetId(), AttrName, Val);
3484 return AddSAttrDatN(NodeI.
GetId(), AttrId, Val);
3488 int AddSAttrDatN(
const TInt& NId,
const TStr& AttrName,
const TStr& Val);
3490 int AddSAttrDatN(
const TInt& NId,
const TInt& AttrId,
const TStr& Val);
3494 return AddSAttrDatN(NodeI.
GetId(), AttrName, Val);
3498 return AddSAttrDatN(NodeI.
GetId(), AttrId, Val);
3502 int GetSAttrDatN(
const TInt& NId,
const TStr& AttrName,
TInt& ValX)
const;
3504 int GetSAttrDatN(
const TInt& NId,
const TInt& AttrId,
TInt& ValX)
const;
3508 return GetSAttrDatN(NodeI.
GetId(), AttrName, ValX);
3512 return GetSAttrDatN(NodeI.
GetId(), AttrId, ValX);
3516 int GetSAttrDatN(
const TInt& NId,
const TStr& AttrName,
TFlt& ValX)
const;
3518 int GetSAttrDatN(
const TInt& NId,
const TInt& AttrId,
TFlt& ValX)
const;
3522 return GetSAttrDatN(NodeI.
GetId(), AttrName, ValX);
3526 return GetSAttrDatN(NodeI.
GetId(), AttrId, ValX);
3530 int GetSAttrDatN(
const TInt& NId,
const TStr& AttrName,
TStr& ValX)
const;
3532 int GetSAttrDatN(
const TInt& NId,
const TInt& AttrId,
TStr& ValX)
const;
3536 return GetSAttrDatN(NodeI.
GetId(), AttrName, ValX);
3540 return GetSAttrDatN(NodeI.
GetId(), AttrId, ValX);
3544 int DelSAttrDatN(
const TInt& NId,
const TStr& AttrName);
3546 int DelSAttrDatN(
const TInt& NId,
const TInt& AttrId);
3550 return DelSAttrDatN(NodeI.
GetId(), AttrName);
3554 return DelSAttrDatN(NodeI.
GetId(), AttrId);
3561 return GetSAttrVN(NodeI.
GetId(), AttrType, AttrV);
3565 int GetIdVSAttrN(
const TStr& AttrName,
TIntV& IdV)
const;
3567 int GetIdVSAttrN(
const TInt& AttrId,
TIntV& IdV)
const;
3578 int AddSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName,
const TInt& Val);
3580 int AddSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId,
const TInt& Val);
3592 int AddSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName,
const TFlt& Val);
3594 int AddSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId,
const TFlt& Val);
3606 int AddSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName,
const TStr& Val);
3608 int AddSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId,
const TStr& Val);
3620 int GetSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName,
TInt& ValX)
const;
3622 int GetSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId,
TInt& ValX)
const;
3634 int GetSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName,
TFlt& ValX)
const;
3636 int GetSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId,
TFlt& ValX)
const;
3648 int GetSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName,
TStr& ValX)
const;
3650 int GetSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId,
TStr& ValX)
const;
3662 int DelSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName);
3664 int DelSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId);
3675 int GetSAttrVE(
const int& SrcNId,
const int& DstNId,
const TAttrType AttrType,
TAttrPrV& AttrV)
const;
3682 int GetIdVSAttrE(
const TStr& AttrName,
TIntPrV& IdV)
const;
3684 int GetIdVSAttrE(
const TInt& AttrId,
TIntPrV& IdV)
const;
3694 friend class TUndirNetMtx;
3724 TNode() : Id(-1), InNIdV(), OutNIdV() { }
3725 TNode(
const int& NId) : Id(NId), InNIdV(), OutNIdV() { }
3726 TNode(
const TNode& Node) : Id(Node.Id), InNIdV(Node.InNIdV), OutNIdV(Node.OutNIdV) { }
3728 void Save(
TSOut& SOut)
const { Id.Save(SOut); InNIdV.Save(SOut); OutNIdV.Save(SOut); }
3730 int GetDeg()
const {
return GetInDeg() + GetOutDeg(); }
3733 int GetInNId(
const int& NodeN)
const {
return InNIdV[NodeN]; }
3734 int GetOutNId(
const int& NodeN)
const {
return OutNIdV[NodeN]; }
3735 int GetNbrNId(
const int& NodeN)
const {
return NodeN<GetOutDeg()?GetOutNId(NodeN):GetInNId(NodeN-GetOutDeg()); }
3736 bool IsInNId(
const int& NId)
const {
return InNIdV.SearchBin(NId) != -1; }
3737 bool IsOutNId(
const int& NId)
const {
return OutNIdV.SearchBin(NId) != -1; }
3738 bool IsNbrNId(
const int& NId)
const {
return IsOutNId(NId) || IsInNId(NId); }
3744 InNIdV.LoadShM(MStream);
3745 OutNIdV.LoadShM(MStream);
3748 friend class TDirNetMtx;
3761 TNodeI& operator++ (
int) { NodeHI++;
return *
this; }
3763 TNodeI& operator-- (
int) { NodeHI--;
return *
this; }
3765 bool operator < (
const TNodeI& NodeI)
const {
return NodeHI < NodeI.
NodeHI; }
3766 bool operator == (
const TNodeI& NodeI)
const {
return NodeHI == NodeI.
NodeHI; }
3768 int GetId()
const {
return NodeHI.GetDat().GetId(); }
3770 int GetDeg()
const {
return NodeHI.GetDat().GetDeg(); }
3772 int GetInDeg()
const {
return NodeHI.GetDat().GetInDeg(); }
3774 int GetOutDeg()
const {
return NodeHI.GetDat().GetOutDeg(); }
3780 int GetInNId(
const int& NodeN)
const {
return NodeHI.GetDat().GetInNId(NodeN); }
3784 int GetOutNId(
const int& NodeN)
const {
return NodeHI.GetDat().GetOutNId(NodeN); }
3788 int GetNbrNId(
const int& NodeN)
const {
return NodeHI.GetDat().GetNbrNId(NodeN); }
3790 bool IsInNId(
const int& NId)
const {
return NodeHI.GetDat().IsInNId(NId); }
3792 bool IsOutNId(
const int& NId)
const {
return NodeHI.GetDat().IsOutNId(NId); }
3794 bool IsNbrNId(
const int& NId)
const {
return IsOutNId(NId) || IsInNId(NId); }
3803 TEdgeI() : CurNode(), EndNode(), CurEdge(0) { }
3804 TEdgeI(
const TNodeI& NodeI,
const TNodeI& EndNodeI,
const int& EdgeN=0) : CurNode(NodeI), EndNode(EndNodeI), CurEdge(EdgeN) { }
3805 TEdgeI(
const TEdgeI& EdgeI) : CurNode(EdgeI.CurNode), EndNode(EdgeI.EndNode), CurEdge(EdgeI.CurEdge) { }
3808 TEdgeI& operator++ (
int) { CurEdge++;
if (CurEdge >= CurNode.GetOutDeg()) { CurEdge=0; CurNode++;
3809 while (CurNode < EndNode && CurNode.GetOutDeg()==0) { CurNode++; } }
return *
this; }
3817 int GetDstNId()
const {
return CurNode.GetOutNId(CurEdge); }
3846 explicit TDirNet(
const int& Nodes,
const int& Edges) :
MxNId(0), SAttrN(), SAttrE() {
Reserve(Nodes, Edges); }
3859 static PDirNet
New(
const int& Nodes,
const int& Edges) {
return new TDirNet(Nodes, Edges); }
3864 Graph->MxNId.Load(SIn); Graph->NodeH.Load(SIn);
return Graph;
3948 int AddEdge(
const int& SrcNId,
const int& DstNId);
3957 int AddEdgeUnchecked(
const int& SrcNId,
const int& DstNId);
3965 void DelEdge(
const int& SrcNId,
const int& DstNId,
const bool& IsDir =
true);
3967 bool IsEdge(
const int& SrcNId,
const int& DstNId,
const bool& IsDir =
true)
const;
3973 TEdgeI
GetEI(
const int& EId)
const;
3975 TEdgeI
GetEI(
const int& SrcNId,
const int& DstNId)
const;
4002 void Defrag(
const bool& OnlyNodeLinks=
false);
4007 bool IsOk(
const bool& ThrowExcept=
true)
const;
4009 void Dump(FILE *OutF=stdout)
const;
4015 static PDirNet GetSmallGraph();
4018 int AddSAttrDatN(
const TInt& NId,
const TStr& AttrName,
const TInt& Val);
4020 int AddSAttrDatN(
const TInt& NId,
const TInt& AttrId,
const TInt& Val);
4024 return AddSAttrDatN(NodeI.
GetId(), AttrName, Val);
4028 return AddSAttrDatN(NodeI.
GetId(), AttrId, Val);
4032 int AddSAttrDatN(
const TInt& NId,
const TStr& AttrName,
const TFlt& Val);
4034 int AddSAttrDatN(
const TInt& NId,
const TInt& AttrId,
const TFlt& Val);
4038 return AddSAttrDatN(NodeI.
GetId(), AttrName, Val);
4042 return AddSAttrDatN(NodeI.
GetId(), AttrId, Val);
4046 int AddSAttrDatN(
const TInt& NId,
const TStr& AttrName,
const TStr& Val);
4048 int AddSAttrDatN(
const TInt& NId,
const TInt& AttrId,
const TStr& Val);
4052 return AddSAttrDatN(NodeI.
GetId(), AttrName, Val);
4056 return AddSAttrDatN(NodeI.
GetId(), AttrId, Val);
4060 int GetSAttrDatN(
const TInt& NId,
const TStr& AttrName,
TInt& ValX)
const;
4062 int GetSAttrDatN(
const TInt& NId,
const TInt& AttrId,
TInt& ValX)
const;
4066 return GetSAttrDatN(NodeI.
GetId(), AttrName, ValX);
4070 return GetSAttrDatN(NodeI.
GetId(), AttrId, ValX);
4074 int GetSAttrDatN(
const TInt& NId,
const TStr& AttrName,
TFlt& ValX)
const;
4076 int GetSAttrDatN(
const TInt& NId,
const TInt& AttrId,
TFlt& ValX)
const;
4080 return GetSAttrDatN(NodeI.
GetId(), AttrName, ValX);
4084 return GetSAttrDatN(NodeI.
GetId(), AttrId, ValX);
4088 int GetSAttrDatN(
const TInt& NId,
const TStr& AttrName,
TStr& ValX)
const;
4090 int GetSAttrDatN(
const TInt& NId,
const TInt& AttrId,
TStr& ValX)
const;
4094 return GetSAttrDatN(NodeI.
GetId(), AttrName, ValX);
4098 return GetSAttrDatN(NodeI.
GetId(), AttrId, ValX);
4102 int DelSAttrDatN(
const TInt& NId,
const TStr& AttrName);
4104 int DelSAttrDatN(
const TInt& NId,
const TInt& AttrId);
4108 return DelSAttrDatN(NodeI.
GetId(), AttrName);
4112 return DelSAttrDatN(NodeI.
GetId(), AttrId);
4119 return GetSAttrVN(NodeI.
GetId(), AttrType, AttrV);
4123 int GetIdVSAttrN(
const TStr& AttrName,
TIntV& IdV)
const;
4125 int GetIdVSAttrN(
const TInt& AttrId,
TIntV& IdV)
const;
4136 int AddSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName,
const TInt& Val);
4138 int AddSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId,
const TInt& Val);
4150 int AddSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName,
const TFlt& Val);
4152 int AddSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId,
const TFlt& Val);
4164 int AddSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName,
const TStr& Val);
4166 int AddSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId,
const TStr& Val);
4178 int GetSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName,
TInt& ValX)
const;
4180 int GetSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId,
TInt& ValX)
const;
4192 int GetSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName,
TFlt& ValX)
const;
4194 int GetSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId,
TFlt& ValX)
const;
4206 int GetSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName,
TStr& ValX)
const;
4208 int GetSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId,
TStr& ValX)
const;
4220 int DelSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName);
4222 int DelSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId);
4233 int GetSAttrVE(
const int& SrcNId,
const int& DstNId,
const TAttrType AttrType,
TAttrPrV& AttrV)
const;
4240 int GetIdVSAttrE(
const TStr& AttrName,
TIntPrV& IdV)
const;
4242 int GetIdVSAttrE(
const TInt& AttrId,
TIntPrV& IdV)
const;
4253 friend class TDirNetMtx;
int AddNodeUnchecked(int NId=-1)
Adds a node of ID NId to the network, noop if the node already exists.
int GetSAttrVE(const TEdgeI &EdgeI, const TAttrType AttrType, TAttrPrV &AttrV) const
Gets a list of all sparse attributes of type AttrType for EdgeI.
int GetNbrEId(const int &EdgeN) const
int AddEdge(const TEdgeI &EdgeI)
Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() to the network.
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the network.
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
TEdgeI GetEI(const int &EId) const
Not supported/implemented!
void LoadNetworkShM(TShMIn &ShMIn)
TEdgeDat & GetOutEDat(const int &EdgeN)
static int GetNIdPos(const TVec< TPair< TInt, TEdgeData > > &NIdV, const int &NId)
TVec< TIntV > VecOfIntVecsN
int AddSAttrDatN(const TNodeI &NodeI, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to NodeI.
TNEANet(TSIn &SIn)
Constructor for loading the graph from a (binary) stream SIn.
bool IsNbrNId(const int &NId) const
Tests whether node with ID NId is a neighbor of the current node.
int GetSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName, TFlt &ValX) const
Gets Flt sparse attribute with name AttrName from EdgeI.
TEdgeI(const THashIter &EdgeHIter, const TNodeEdgeNet *NetPt)
static const T & Mn(const T &LVal, const T &RVal)
TNodeI & operator++(int)
Increment iterator.
THash< TStr, TBool > KeyToDenseE
TNodeNet(const TNodeNet &NodeNet)
TNodeI(const THashIter &NodeHIter, const TNodeNet *NetPt)
TPair< TInt, TInt > TIntPr
Tests (at compile time) if the graph is a network with data on nodes.
void IntVAttrNameNI(const TInt &NId, TStrV &Names) const
Returns a vector of int attr names for node NId.
int DelSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName)
Deletes sparse attribute with name AttrName from EdgeI.
void Reserve(const int &Nodes, const int &Edges)
Reserves memory for a network of Nodes nodes and Edges edges.
TNodeData & GetOutNDat(const int &EdgeN)
bool IsDeleted() const
Returns true if the attribute has been deleted.
TInt GetIntAttrDatN(const TNodeI &NodeI, const TStr &attr)
Gets the value of int attr from the node attr value vector.
bool IsOutNId(const int &NId) const
int GetSAttrDatN(const TNodeI &NodeI, const TStr &AttrName, TFlt &ValX) const
Gets Flt sparse attribute with name AttrName from NodeI.
int GetRndNId(TRnd &Rnd=TInt::Rnd)
Returns an ID of a random node in the graph.
bool DelIfIn(const TVal &Val)
Removes the first occurrence of element Val.
int GetDeg() const
Returns degree of the current node.
void Clr()
Deletes all nodes and edges from the network.
TIter EndI() const
Returns an iterator referring to the past-the-end element in the vector.
int GetInEId(const int &EdgeN) const
Returns ID of EdgeN-th in-edge.
const TNodeData & GetInNDat(const int &EdgeN) const
int GetNbrEId(const int &EdgeN) const
Returns ID of EdgeN-th in or out-edge.
static PUndirNet New()
Static constructor that returns a pointer to the network. Call: PUndirNet Graph = TUndirNet::New()...
int GetNodes() const
Returns the number of nodes in the network.
TPt< TIntNEDNet > PIntNEDNet
const TEdgeDat & GetOutEDat(const int &EdgeN) const
int GetSAttrDatN(const TNodeI &NodeI, const TInt &AttrId, TInt &ValX) const
Gets Int sparse attribute with id AttrId from NodeI.
void SetNDat(const int &NId, const TNodeData &NodeDat)
Sets node data for the node of ID NId in the network.
bool IsKeyIdEqKeyN() const
TPt< TIntFltNEDNet > PIntFltNEDNet
void SortEIdByDat(const bool &Asc=true)
Sorts edges by edge data.
void LoadShM(TShMIn &MStream)
THash< TInt, TNode >::TIter THashIter
#define IAssertR(Cond, Reason)
int GetOutNId(const int &EdgeN) const
Returns ID of EdgeN-th out-node (the node the current node points to).
void LoadNetworkShM(TShMIn &ShMIn)
TStr GetStrAttrDatN(const TNodeI &NodeI, const TStr &attr)
Gets the value of str attr from the node attr value vector.
THash< TStr, TFlt > FltDefaultsE
int AppendIntVAttrDatN(const TNodeI &NodeI, const TInt &value, const TStr &attr)
Appends value onto the TIntV attribute for the given node.
virtual void Save(TSOut &SOut) const
Saves the network to a (binary) stream SOut.
int AddSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId, const TInt &Val)
Adds Int sparse attribute with id AttrId to EdgeI.
int GetDeg() const
Returns degree of the current node.
int AddFltAttrDatE(const TEdgeI &EdgeI, const TFlt &value, const TStr &attr)
Attribute based add function for attr to Flt value.
bool IsOutNId(const int &NId) const
Tests whether the current node points to node with ID NId.
TNode(const int &NId, const TNodeData &NodeData)
int GetOutNId(const int &EdgeN) const
Returns ID of EdgeN-th out-node (the node the current node points to).
TDirNet(const TDirNet &Graph)
TNode & GetNode(const int &NId)
TAStrI GetNAStrI(const TStr &attr, const int &NId) const
Returns an iterator referring to the node of ID NId in the graph.
void Save_V1(TSOut &SOut) const
Saves the network to a (binary) stream SOut. Available for backwards compatibility.
THash< TInt, TNode > NodeH
int GetOutDeg() const
Returns out-degree of the current node.
TEdgeI(const TNodeI &NodeI, const TNodeI &EndNodeI, const int &EdgeN=0)
int GetSAttrDatN(const TNodeI &NodeI, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from NodeI.
enum TAttrType_ TAttrType
Types for tables, sparse and dense attributes.
TEdgeI BegEI() const
Returns an iterator referring to the first edge in the network.
const TNodeData & GetNDat(const int &NId) const
Returns node data for the node of ID NId in the network.
const TNodeData & GetDat() const
TVec< TStrV > VecOfStrVecsE
THash< TStr, TInt > IntDefaultsE
int GetInNId(const int &EdgeN) const
Returns ID of EdgeN-th in-node (the node pointing to the current node).
void Save(TSOut &SOut) const
int GetSAttrDatN(const TNodeI &NodeI, const TInt &AttrId, TFlt &ValX) const
Gets Flt sparse attribute with id AttrId from NodeI.
TNodeEDatNet & operator=(const TNodeEDatNet &NodeNet)
const TNodeData & operator()() const
void Save(TSOut &SOut) const
void Save_V1(TSOut &SOut) const
Saves the graph to a (binary) stream SOut. Available for backwards compatibility. ...
int AddNode(const TNodeI &NodeI)
Adds a node NodeI and its node data to the network.
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
TNode & GetNode(const int &NId)
int GetId() const
Returns edge ID. Always returns -1 since only edges in multigraphs have explicit IDs.
int GetSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName, TStr &ValX) const
Gets Str sparse attribute with name AttrName from EdgeI.
int GetInNId(const int &NodeN) const
Returns ID of NodeN-th in-node (the node pointing to the current node).
int AddEdge(const TEdgeI &EdgeI)
Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() and its edge data to the network...
int GetOutDeg() const
Returns out-degree of the current node (returns same as value GetDeg() since the network is undirecte...
int DelSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId)
Deletes sparse attribute with id AttrId from EdgeI.
int GetSAttrDatN(const TNodeI &NodeI, const TStr &AttrName, TFlt &ValX) const
Gets Flt sparse attribute with name AttrName from NodeI.
void SortNIdById(const bool &Asc=true)
Sorts nodes by node IDs.
bool Empty() const
Tests whether the network is empty (has zero nodes).
int GetInNId(const int &NodeN) const
int GetInNId(const int &NodeN) const
void Reserve(const int &Nodes, const int &Edges)
Reserves memory for a network of Nodes nodes and Edges edges.
TEdgeI GetEI(const int &EId) const
Returns an iterator referring to edge with edge ID EId.
void DelNode(const int &NId)
Deletes node of ID NId from the network.
int AddSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to EdgeI.
int GetEdges() const
Returns the number of edges in the network.
void DelEdge(const int &SrcNId, const int &DstNId, const bool &IsDir=true)
Deletes an edge from node IDs SrcNId to DstNId from the network.
int AddEdge(const TEdgeI &EdgeI)
Adds an edge between EdgeI.GetSrcNId() and EdgeI.GetDstNId() to the graph.
int GetSAttrDatN(const TNodeI &NodeI, const TInt &AttrId, TInt &ValX) const
Gets Int sparse attribute with id AttrId from NodeI.
bool operator<(const TEdgeI &EdgeI) const
void SortNIdV()
Sorts the adjacency lists of the current node.
const TNode & GetNode(const int &NId) const
Returns node element for the node of ID NId in the network.
bool IsNbrEId(const int &EId) const
TEdgeI(const THashIter &EdgeHIter, const TNEANet *GraphPt)
int AddNodeUnchecked(int NId=-1)
Adds a node of ID NId to the network, noop if the node already exists.
TPt< TStrIntNEDNet > PStrIntNEDNet
THash< TInt, TNode >::TIter THashIter
TNodeData & GetNDat(const int &NId)
Returns node data for the node of ID NId in the network.
int AddEdge(const TEdgeI &EdgeI)
void Del(const TSizeTy &ValN)
Removes the element at position ValN.
Edge iterator. Only forward iteration (operator++) is supported.
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the network.
TInt CheckDenseOrSparseN(const TStr &attr) const
Return 1 if in Dense, 0 if in Sparse, -1 if neither.
void AttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of attr names for edge EId.
static const T & Mx(const T &LVal, const T &RVal)
TVec< THash< TInt, TIntV > > VecOfIntHashVecsE
int GetSAttrVE(const TEdgeI &EdgeI, const TAttrType AttrType, TAttrPrV &AttrV) const
Gets a list of all sparse attributes of type AttrType for EdgeI.
int GetOutNId(const int &NodeN) const
void SortNIdByDat(const bool &Asc=true)
Sorts nodes by node data.
TNodeData & GetOutNDat(const int &NodeN)
int GetNbrNId(const int &NodeN) const
Returns ID of NodeN-th neighboring node.
void GetNIdV(TIntV &NIdV) const
Returns a vector of all node IDs in the network.
const TNodeData & GetDat() const
int GetId() const
Returns ID of the current node.
void Save(TSOut &SOut) const
static PNEANet Load(TSIn &SIn)
Static constructor that loads the graph from a stream SIn and returns a pointer to it...
TEdgeData & GetInEDat(const int &EdgeN)
int GetSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId, TStr &ValX) const
Gets Str sparse attribute with id AttrId from EdgeI.
TNode & GetNode(const int &NId)
TNodeI BegNI() const
Returns an iterator referring to the first node in the network.
int AddNode(const TNodeI &NodeI)
void StrAttrNameNI(const TInt &NId, TStrV &Names) const
Returns a vector of str attr names for node NId.
TNodeI(const TNodeI &NodeI)
int AddSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to EdgeI.
void DelNode(const TNode &NodeI)
Deletes node of ID NodeI.GetId() from the network.
void FltAttrNameNI(const TInt &NId, TStrV &Names) const
Returns a vector of int attr names for node NId.
bool IsInEId(const int &EId) const
Tests whether the edge with ID EId is an in-edge of current node.
TNodeI(const THashIter &NodeHIter, const TNodeEdgeNet *NetPt)
void IntVAttrValueEI(const TInt &EId, TVec< TIntV > &Values) const
Returns a vector of attr values for edge EId.
bool operator<(const TNodeI &NodeI) const
void SortNodeAdjV()
Sorts the adjacency lists of each node.
void ReserveNIdInDeg(const int &NId, const int &InDeg)
Reserves memory for node ID NId having InDeg in-edges.
int AddNode(int NId=-1)
Adds a node of ID NId to the network.
void Save(TSOut &SOut) const
Saves the network to a (binary) stream SOut. Expects data structures for sparse attributes.
bool IsOutNId(const int &NId) const
const TNodeData & GetOutNDat(const int &EdgeN) const
TInt GetIntAttrDefaultE(const TStr &attribute) const
Gets Int edge attribute val. If not a proper attr, return default.
bool IsNbrNId(const int &NId) const
Tests whether node with ID NId is a neighbor of the current node.
TInt CheckDenseOrSparseE(const TStr &attr) const
TNodeI(const TNodeI &NodeI)
TNodeEdgeNet< TFlt, TFlt > TFltNENet
bool IsEdge(const int &SrcNId, const int &DstNId, const bool &IsDir=true) const
Tests whether an edge between node IDs SrcNId and DstNId exists in the graph.
TFlt GetFltAttrDatE(const TEdgeI &EdgeI, const TStr &attr)
Gets the value of flt attr from the edge attr value vector.
bool operator<(const TEdgeI &EdgeI) const
TEdgeI(const TEdgeI &EdgeI)
TNodeEDatNet(const int &Nodes, const int &Edges)
Constructor that reserves enough memory for a network of Nodes nodes and Edges edges.
bool IsInNId(const int &NId) const
THash< TInt, TNode >::TIter THashIter
TPt< TIntNENet > PIntNENet
void DelEdge(const int &SrcNId, const int &DstNId, const bool &IsDir=true)
Deletes an edge from node IDs SrcNId to DstNId from the network.
int GetSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId, TStr &ValX) const
Gets Str sparse attribute with id AttrId from EdgeI.
int AddSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId, const TInt &Val)
Adds Int sparse attribute with id AttrId to EdgeI.
Tests (at compile time) if the graph is directed.
int AddIntVAttrDatE(const TEdgeI &EdgeI, const TIntV &value, const TStr &attr)
Attribute based add function for attr to IntV value.
int GetInNId(const int &EdgeN) const
Returns ID of EdgeN-th in-node (the node pointing to the current node).
bool operator<(const TNodeI &NodeI) const
const TEdge & GetEdgeKId(const int &EdgeKeyId) const
const TNode & GetNode(const int &NId) const
static PUndirNet LoadShM(TShMIn &ShMIn)
Static constructor that loads the network from memory.
int AddSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId, const TFlt &Val)
Adds Flt sparse attribute with id AttrId to EdgeI.
bool IsNbrNId(const int &NId) const
Tests whether node with ID NId is a neighbor of the current node.
bool IsInNId(const int &NId) const
Tests whether node with ID NId points to the current node.
void LoadShM(TShMIn &MStream)
TSizeTy Len() const
Returns the number of elements in the vector.
int GetInDeg() const
Returns in-degree of the current node.
TNodeI GetRndNI(TRnd &Rnd=TInt::Rnd)
Returns an interator referring to a random node in the network.
void GetFltAttrVal(TFltV &Val) const
Gets vector of flt attribute values.
TEdgeI(const TEdgeI &EdgeI)
bool IsOutNId(const int &NId) const
Tests whether the current node points to node with ID NId.
void SetEDat(const int &SrcNId, const int &DstNId, const TEdgeData &EdgeDat)
Sets edge data for the edge between nodes SrcNId and DstNId in the network.
bool operator<(const TNode &Node) const
void Save(TSOut &SOut) const
int GetMxNId() const
Returns an ID that is larger than any node ID in the network.
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
TEdge(const int &EId, const int &SourceNId, const int &DestNId, const TEdgeData &EdgeData)
TNodeEdgeNet(const TNodeEdgeNet &Net)
void StrAttrValueNI(const TInt &NId, TStrV &Values) const
Returns a vector of attr values for node NId.
static PNet New()
Static constructor that returns a pointer to the network. Call: TPt > Net = TNod...
TIntV GetIntVAttrDatE(const TEdgeI &EdgeI, const TStr &attr)
Gets the value of the intv attr from the edge attr value vector.
const TNodeData & GetInNDat(const int &NodeN) const
int GetNodes() const
Returns the number of nodes in the network.
TNodeI & operator++(int)
Increment iterator.
TStrIntPrH KeyToIndexTypeE
const TNodeData & GetInNDat(const int &NodeN) const
TEdgeData & GetOutEDat(const int &EdgeN)
int GetSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId, TInt &ValX) const
Gets Int sparse attribute with id AttrId from EdgeI.
int GetSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from EdgeI.
TStr GetStrAttrDatE(const TEdgeI &EdgeI, const TStr &attr)
Gets the value of str attr from the edge attr value vector.
Edge iterator. Only forward iteration (operator++) is supported.
int GetNbrNId(const int &NodeN) const
void SetAllEDat(const TEdgeData &EdgeDat)
Sets edge data for all the edges in the network to EDat.
bool IsInNId(const int &NId) const
void Save(TSOut &SOut) const
Saves the network to a (binary) stream SOut. Expects data structures for sparse attributes.
TNodeI & operator=(const TNodeI &NodeI)
TEdgeI GetEI(const int &SrcNId, const int &DstNId) const
Returns an iterator referring to edge (SrcNId, DstNId) in the graph.
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
TNodeI(const TNodeI &NodeI)
int GetEdges() const
Returns the number of edges in the network.
int GetRndEId(TRnd &Rnd=TInt::Rnd)
Returns an ID of a random edge in the graph.
int GetSAttrDatN(const TNodeI &NodeI, const TInt &AttrId, TFlt &ValX) const
Gets Flt sparse attribute with id AttrId from NodeI.
bool IsOutEId(const int &EId) const
Tests whether the edge with ID EId is an out-edge of current node.
int GetOutEId(const int &EdgeN) const
Returns ID of EdgeN-th out-edge.
THash< TInt, TNode > NodeH
Node iterator. Only forward iteration (operator++) is supported.
TStr GetDat() const
Returns an attribute of the node.
int GetOutNId(const int &NodeN) const
TNodeData & GetNbrNDat(const int &NodeN)
TNodeI & operator++(int)
Increment iterator.
TInt GetDat() const
Returns an attribute of the node.
TVec< TIntV >::TIter TIntVVecIter
bool IsNbrNId(const int &NId) const
THash< TStr, TFlt > FltDefaultsN
void SortNIdById(const bool &Asc=true)
Sorts nodes by node IDs.
void Reserve(const int &Nodes, const int &Edges)
Reserves memory for a network of Nodes nodes and Edges edges.
TEdgeI GetRndEI(TRnd &Rnd=TInt::Rnd)
Returns an interator referring to a random edge in the graph.
const TEdge & GetEdge(const int &EId) const
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
static PNet LoadShM(TShMIn &ShMIn)
Static constructor that loads the network from shared memory.
const TNodeData & GetNbrNDat(const int &NodeN) const
int GetUniqEdges(const bool &IsDir=true) const
Returns the number of edges in the network with a unique pair of nodes.
TNodeEDatNet< TInt, TFlt > TIntFltNEDNet
int AddNode(int NId=-1)
Adds a node of ID NId to the network.
TNodeData & GetNbrNDat(const int &EdgeN)
TNodeData & GetInNDat(const int &NodeN)
void IntAttrValueEI(const TInt &EId, TIntV &Values) const
Returns a vector of attr values for edge EId.
TEdgeI GetEI(const int &EId) const
Not supported/implemented!
int AddIntAttrDatE(const TEdgeI &EdgeI, const TInt &value, const TStr &attr)
Attribute based add function for attr to Int value.
void ReserveNIdOutDeg(const int &NId, const int &OutDeg)
Reserves memory for node ID NId having OutDeg out-edges.
int GetNbrNId(const int &EdgeN) const
Returns ID of EdgeN-th neighboring node.
int AddSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId, const TStr &Val)
Adds Str sparse attribute with id AttrId to EdgeI.
int AddSAttrDatN(const TNodeI &NodeI, const TInt &AttrId, const TInt &Val)
Adds Int sparse attribute with id AttrId to NodeI.
TEdgeI(const TNodeI &NodeI, const TNodeI &EndNodeI, const int &EdgeN=0)
TNodeData & GetNDat(const int &NId)
Returns node data for the node of ID NId in the network.
TFlt GetDat() const
Returns an attribute of the node.
int GetDeg() const
Returns degree of the current node, the sum of in-degree and out-degree.
TNodeData & GetNDat(const int &NId)
Returns node data for the node of ID NId in the network.
bool IsOutEId(const int &EId) const
TAIntI BegNAIntI(const TStr &attr) const
Returns an iterator referring to the first node's int attribute.
const TDat & GetDat(const TKey &Key) const
int AddSAttrDatN(const TNodeI &NodeI, const TStr &AttrName, const TFlt &Val)
Adds Flt sparse attribute with name AttrName to NodeI.
TIntV GetIntVAttrDatN(const TNodeI &NodeI, const TStr &attr) const
Gets the value of the intv attr from the node attr value vector.
Node iterator. Only forward iteration (operator++) is supported.
Node/edge integer attribute iterator. Iterates through all nodes/edges for one integer attribute...
int GetInNId(const int &EdgeN) const
void AttrValueNI(const TInt &NId, TStrV &Values) const
Returns a vector of attr values for node NId.
int GetSrcNId() const
Gets the source node of an edge.
void GetStrAttrNames(TStrV &Names) const
Gets vector of str attribute names.
bool GetEDat(const int &SrcNId, const int &DstNId, TEdgeData &EdgeDat) const
Returns edge data in Data for the edge from node IDs SrcNId to DstNId.
TVec< TIntV > VecOfIntVecsE
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the network.
TNodeI & operator=(const TNodeI &NodeI)
const TEdgeData & GetInEDat(const int &EdgeN) const
int DelSAttrDatN(const TNodeI &NodeI, const TStr &AttrName)
Deletes sparse attribute with name AttrName from NodeI.
bool IsNbrEId(const int &EId) const
Tests whether the edge with ID EId is an in or out-edge of current node.
void IntAttrNameNI(const TInt &NId, TStrV &Names) const
Returns a vector of int attr names for node NId.
int GetSrcNId() const
Gets the source node of an edge.
TAIntVI EndNAIntVI(const TStr &attr) const
Returns an iterator referring to the past-the-end node's attribute.
TNodeI GetRndNI(TRnd &Rnd=TInt::Rnd)
Returns an interator referring to a random node in the network.
int GetNodes() const
Returns the number of nodes in the network.
bool IsNbrNId(const int &NId) const
static PUndirNet New(const int &Nodes, const int &Edges)
Static constructor that returns a pointer to the network and reserves enough memory for Nodes nodes a...
bool IsNbrNId(const int &NId) const
TEdgeI GetEI(const int &EId) const
Not supported/implemented!
void LoadNetworkShM(TShMIn &ShMIn)
TAFltI GetEAFltI(const TStr &attr, const int &EId) const
Returns an iterator referring to the edge of ID EId in the graph.
TNodeI BegNI() const
Returns an iterator referring to the first node in the network.
int GetNbrEId(const int &EdgeN) const
int AddSAttrDatN(const TNodeI &NodeI, const TInt &AttrId, const TInt &Val)
Adds Int sparse attribute with id AttrId to NodeI.
bool IsDeleted() const
Returns true if the attribute has been deleted.
int GetInDeg() const
Returns in-degree of the current node.
TAFltI BegEAFltI(const TStr &attr) const
Returns an iterator referring to the first edge's flt attribute.
void SetNDat(const int &NId, const TNodeData &NodeDat)
Sets node data for the node of ID NId in the network.
TAStrI GetEAStrI(const TStr &attr, const int &EId) const
Returns an iterator referring to the edge of ID EId in the graph.
Node/edge float attribute iterator. Iterates through all nodes/edges for one float attribute...
int AddNode(const TNodeI &NodeI)
Adds a node of ID NodeI.GetId() to the graph.
Node Edge Network (directed multigraph, TNEGraph with data on nodes and edges).
int GetSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId, TFlt &ValX) const
Gets Flt sparse attribute with id AttrId from EdgeI.
int GetId() const
Returns edge ID.
void LoadShM(TShMIn &ShMIn)
Load THash from shared memory file. Copying/Deleting Keys is illegal.
static PUndirNet Load(TSIn &SIn)
Static constructor that loads the network from a stream SIn and returns a pointer to it...
void Load(TSIn &InStream)
int GetOutNId(const int &EdgeN) const
TSizeTy AddSorted(const TVal &Val, const bool &Asc=true, const TSizeTy &_MxVals=-1)
Adds element Val to a sorted vector.
void ErrNotify(const char *NotifyCStr)
TNodeEDatNet< TInt, TInt > TIntNEDNet
bool IsOutEId(const int &EId) const
TAIntI BegEAIntI(const TStr &attr) const
Returns an iterator referring to the first edge's int attribute.
int GetNbrNId(const int &NodeN) const
virtual void Save(TSOut &SOut) const
Saves the network to a (binary) stream SOut.
const TNodeData & GetNDat(const int &NId) const
Returns node data for the node of ID NId in the network.
int DelSAttrDatN(const TNodeI &NodeI, const TStr &AttrName)
Deletes sparse attribute with name AttrName from NodeI.
bool operator==(const TEdgeI &EdgeI) const
TEdge(const int &EId, const int &SourceNId, const int &DestNId)
TVec< TStrV > VecOfStrVecsN
void GetStrAttrVal(TStrV &Val) const
Gets vector of str attribute values.
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
TNodeEDatNet(const TNodeEDatNet &NodeNet)
int GetNbrNId(const int &NodeN) const
Returns ID of NodeN-th neighboring node.
void Save(TSOut &SOut) const
TEdgeI & operator++(int)
Increment iterator.
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the network.
int AddEdge(const int &SrcNId, const int &DstNId, int EId=-1)
Adds an edge between node IDs SrcNId and DstNId to the graph.
int GetDeg() const
Returns degree of the current node, the sum of in-degree and out-degree.
int GetSAttrDatN(const TNodeI &NodeI, const TInt &AttrId, TStr &ValX) const
Gets Str sparse attribute with id AttrId from NodeI.
void DelNode(const TNode &NodeI)
Deletes node of ID NodeI.GetId() from the network.
int AddFltAttrDatN(const TNodeI &NodeI, const TFlt &value, const TStr &attr)
Attribute based add function for attr to Flt value.
int GetInEId(const int &EdgeN) const
Returns ID of EdgeN-th in-edge.
int DelSAttrDatN(const TNodeI &NodeI, const TInt &AttrId)
Deletes sparse attribute with id AttrId from NodeI.
void IntVAttrValueNI(const TInt &NId, TVec< TIntV > &Values) const
Returns a vector of attr values for node NId.
int GetInDeg() const
Returns in-degree of the current node.
bool IsOutNId(const int &NId) const
Tests whether the current node points to node with ID NId.
int AddSAttrDatN(const TNodeI &NodeI, const TInt &AttrId, const TStr &Val)
Adds Str sparse attribute with id AttrId to NodeI.
THash< TInt, TIntV >::TIter TIntHVecIter
THash< TInt, TEdge > EdgeH
static PNet New()
Static constructor that returns a pointer to the network. Call: TPt > Net = TNodeEDatNet::New().
int GetSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName, TStr &ValX) const
Gets Str sparse attribute with name AttrName from EdgeI.
TNodeI(const THashIter &NodeHIter)
TAIntI GetEAIntI(const TStr &attr, const int &EId) const
Returns an iterator referring to the edge of ID EId in the graph.
int DelFromIntVAttrDatN(const TNodeI &NodeI, const TInt &value, const TStr &attr)
Deletes value from the TIntV attribute for the given node.
int AddIntVAttrDatN(const TNodeI &NodeI, const TIntV &value, const TStr &attr)
Attribute based add function for attr to IntV value.
const TNodeData & GetSrcNDat() const
TAStrI EndEAStrI(const TStr &attr) const
Returns an iterator referring to the past-the-end edge's attribute.
int GetDstNId() const
Returns the destination of the edge.
TNode(const int &NId, const TNodeData &NodeData)
int GetSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId, TFlt &ValX) const
Gets Flt sparse attribute with id AttrId from EdgeI.
int AddSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName, const TFlt &Val)
Adds Flt sparse attribute with name AttrName to EdgeI.
const TEdgeData & GetOutEDat(const int &EdgeN) const
TNodeI BegNI() const
Returns an iterator referring to the first node in the network.
TStr GetStrAttrIndDatE(const TEdgeI &EdgeI, const int &index)
Gets the value of a string edge attr specified by edge iterator EdgeI and the attr index...
bool operator==(const TNodeI &NodeI) const
bool operator==(const TEdgeI &EdgeI) const
int AddSAttrDatN(const TNodeI &NodeI, const TStr &AttrName, const TFlt &Val)
Adds Flt sparse attribute with name AttrName to NodeI.
int GetMxNId() const
Returns an ID that is larger than any node ID in the network.
static PNEANet LoadShM(TShMIn &ShMIn)
Static constructor that loads the network from memory.
TEdgeI(const TEdgeI &EdgeI)
TAStrI BegEAStrI(const TStr &attr) const
Returns an iterator referring to the first edge's str attribute.
virtual void DelNode(const int &NId)
Deletes node of ID NId from the network.
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge from node SrcNId to node DstNId to the network.
const TNodeData & GetDat() const
TNodeData & GetInNDat(const int &EdgeN)
const TNode & GetNode(const int &NId) const
TAStrI EndNAStrI(const TStr &attr) const
Returns an iterator referring to the past-the-end node's attribute.
void Save(TSOut &SOut) const
TAIntVI(const TAIntVI &I)
TEdgeI(const TNodeI &NodeI, const TNodeI &EndNodeI, const int &EdgeN=0)
TNodeData & GetInNDat(const int &NodeN)
THash< TInt, TNode > NodeH
void Clr()
Deletes all nodes and edges from the network.
int AddEdge(const TEdgeI &EdgeI)
Adds an edge between EdgeI.GetSrcNId() and EdgeI.GetDstNId() to the network.
void DelKey(const TKey &Key)
Edge iterator. Only forward iteration (operator++) is supported.
TAIntI EndNAIntI(const TStr &attr) const
Returns an iterator referring to the past-the-end node's attribute.
void LoadShM(TShMIn &MStream)
Edge iterator. Only forward iteration (operator++) is supported.
int GetId() const
Returns ID of the current node.
void GetStrAttrVal(TStrV &Val) const
Gets vector of str attribute values.
bool IsOutEId(const int &EId) const
Tests whether the edge with ID EId is an out-edge of current node.
int GetSAttrVN(const TNodeI &NodeI, const TAttrType AttrType, TAttrPrV &AttrV) const
Gets a list of all sparse attributes of type AttrType for NodeI.
TAIntI EndEAIntI(const TStr &attr) const
Returns an iterator referring to the past-the-end edge's attribute.
int GetOutDeg() const
Returns out-degree of the current node.
int GetRndNId(TRnd &Rnd=TInt::Rnd)
Returns an ID of a random node in the network.
TAFltI BegNAFltI(const TStr &attr) const
Returns an iterator referring to the first node's flt attribute.
void Clr(const bool &DoDel=true, const bool &ResetDat=true)
Deletes all nodes and edges from the network.
int GetOutNId(const int &NodeN) const
const TNodeData & GetDat() const
int GetSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId, TStr &ValX) const
Gets Str sparse attribute with id AttrId from EdgeI.
TNEANet(const TNEANet &Graph, bool modeSubGraph)
int GetSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId, TInt &ValX) const
Gets Int sparse attribute with id AttrId from EdgeI.
Node Edge Network (directed graph, TNGraph with data on nodes and edges).
TVec< TFltV > VecOfFltVecsE
int GetInNId(const int &NodeN) const
Returns ID of NodeN-th in-node (the node pointing to the current node).
int DelSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId)
Deletes sparse attribute with id AttrId from EdgeI.
TNode & GetNode(const int &NId)
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
TAFltI EndNAFltI(const TStr &attr) const
Returns an iterator referring to the past-the-end node's attribute.
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the network.
TInt GetIntAttrDatE(const TEdgeI &EdgeI, const TStr &attr)
Gets the value of int attr from the edge attr value vector.
virtual void Save(TSOut &SOut) const
Saves the network to a (binary) stream SOut.
bool IsInNId(const int &NId) const
Tests whether node with ID NId points to the current node.
int AddStrAttrDatN(const TNodeI &NodeI, const TStr &value, const TStr &attr)
Attribute based add function for attr to Str value.
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the network.
int DelSAttrDatN(const TNodeI &NodeI, const TInt &AttrId)
Deletes sparse attribute with id AttrId from NodeI.
void Gen(const int &ExpectVals)
void StrAttrValueEI(const TInt &EId, TStrV &Values) const
Returns a vector of attr values for node NId.
#define HasGraphFlag(TGraph, Flag)
For quick testing of the properties of the graph/network object (see TGraphFlag). ...
TNode & GetNode(const int &NId)
TEdgeI BegEI() const
Returns an iterator referring to the first edge in the network.
Tests (at compile time) if the graph is a network with data on edges.
TAIntI(const TIntVecIter &HIter, TStr attribute, bool isEdgeIter, const TNEANet *GraphPt)
void LoadNetworkShM(TShMIn &ShMIn)
bool Empty() const
Tests whether the network is empty (has zero nodes).
int GetInNId(const int &NodeN) const
Returns ID of NodeN-th in-node (the node pointing to the current node).
void GetIntVAttrVal(TVec< TIntV > &Val) const
Gets vector of int attribute values.
void FltAttrValueEI(const TInt &EId, TFltV &Values) const
Returns a vector of attr values for node NId.
TNodeI GetRndNI(TRnd &Rnd=TInt::Rnd)
Returns an interator referring to a random node in the network.
TEdgeDat & GetNbrEDat(const int &EdgeN)
static PNet Load(TSIn &SIn)
Static constructor that loads the network from a stream SIn and returns a pointer to it...
TNodeI(const TNodeI &NodeI)
void SortNIdByDat(const bool &Asc=true)
Sorts nodes by node data.
int GetId() const
Gets edge ID. Always returns -1 since only edges in multigraphs have explicit IDs.
int GetNbrNId(const int &EdgeN) const
Returns ID of EdgeN-th neighboring node.
int GetSAttrDatN(const TNodeI &NodeI, const TStr &AttrName, TFlt &ValX) const
Gets Flt sparse attribute with name AttrName from NodeI.
bool IsOutNId(const int &NId) const
bool Empty() const
Tests whether the network is empty (has zero nodes).
int GetNbrNId(const int &NodeN) const
Returns ID of NodeN-th neighboring node.
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
void Reserve(const int &Nodes, const int &Edges)
Reserves memory for a graph of Nodes nodes and Edges edges.
int GetSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from EdgeI.
static PUndirNet Load_V1(TSIn &SIn)
Static constructor that loads the network from a stream SIn and returns a pointer to it...
void ReserveNIdDeg(const int &NId, const int &Deg)
Reserves memory for node ID NId having Deg edges.
TEdgeI & operator=(const TEdgeI &EdgeI)
TEdgeI & operator++(int)
Increment iterator.
TNode & GetNode(const int &NId)
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge from node SrcNId to node DstNId to the network.
TEdgeI GetRndEI(TRnd &Rnd=TInt::Rnd)
Returns an interator referring to a random edge in the network.
int GetSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName, TStr &ValX) const
Gets Str sparse attribute with name AttrName from EdgeI.
int GetDstNId() const
Gets the destination node of an edge.
static PDirNet LoadShM(TShMIn &ShMIn)
Static constructor that loads the network from memory.
const TVal & GetDat(const TVal &Val) const
Returns reference to the first occurrence of element Val.
int AddNode(const TNodeI &NodeId)
Adds a node of ID NodeI.GetId() to the network.
bool operator<(const TNode &Node) const
bool IsEdge(const int &SrcNId, const int &DstNId, const bool &IsDir=true) const
Tests whether an edge from node IDs SrcNId to DstNId exists in the network.
int GetSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName, TFlt &ValX) const
Gets Flt sparse attribute with name AttrName from EdgeI.
const TNodeData & GetDat() const
TStr GetStrAttrDefaultE(const TStr &attribute) const
Gets Str edge attribute val. If not a proper attr, return default.
const TNodeData & GetSrcNDat() const
void SortNIdById(const bool &Asc=true)
Sorts nodes by node IDs.
TNEANet(const int &Nodes, const int &Edges)
Constructor that reserves enough memory for a graph of nodes and edges.
bool IsOutNId(const int &NId) const
Tests whether the current node points to node with ID NId.
int DelSAttrDatN(const TNodeI &NodeI, const TInt &AttrId)
Deletes sparse attribute with id AttrId from NodeI.
int GetMxNId() const
Returns an ID that is larger than any node ID in the network.
bool FNextKeyId(int &KeyId) const
TNodeI(const THashIter &NodeHIter)
THash< TStr, TStr > StrDefaultsN
void AttrNameNI(const TInt &NId, TStrV &Names) const
Returns a vector of attr names for node NId.
void operator()(TNode *n, TShMIn &ShMIn)
const TEdgeData & GetDat() const
Tests (at compile time) if the graph is a multigraph with multiple edges between the same nodes...
THash< TInt, TNode > NodeH
TAIntVI EndEAIntVI(const TStr &attr) const
Returns an iterator referring to the past-the-end edge's attribute.
THash< TInt, TNode > NodeH
void DelNode(const TNode &NodeI)
Deletes node of ID NodeI.GetId() from the graph.
TNodeNet(TSIn &SIn)
Constructor that loads the network from a (binary) stream SIn.
bool Empty() const
Tests whether the network is empty (has zero nodes).
TFlt GetFltAttrDatN(const TNodeI &NodeI, const TStr &attr)
Gets the value of flt attr from the node attr value vector.
TEdgeI BegEI() const
Returns an iterator referring to the first edge in the graph.
TNodeEDatNet(TSIn &SIn)
Constructor that loads the network from a (binary) stream SIn.
int AddSAttrDatN(const TNodeI &NodeI, const TStr &AttrName, const TStr &Val)
Adds Str sparse attribute with name AttrName to NodeI.
void SortNIdByDat(const bool &Asc=true)
Sorts nodes by node data.
const TNodeData & operator()() const
bool IsNbrNId(const int &NId) const
Tests whether node with ID NId is a neighbor of the current node.
bool IsOk(const bool &ThrowExcept=true) const
Checks the network data structure for internal consistency.
TNodeEDatNet< TNodeData, TEdgeData > TNet
TNodeI(const TNodeI &NodeI)
TInt GetIntAttrIndDatN(const TNodeI &NodeI, const int &index)
Gets the value of an int node attr specified by node iterator NodeI and the attr index.
void IntVAttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of int attr names for edge EId.
bool IsInNId(const int &NId) const
bool IsInNId(const int &NId) const
Tests whether node with ID NId points to the current node.
TAIntVI GetNAIntVI(const TStr &attr, const int &NId) const
Returns an iterator referring to the node of ID NId in the graph.
int AddKey(const TKey &Key)
int AddSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId, const TFlt &Val)
Adds Flt sparse attribute with id AttrId to EdgeI.
void Save(TSOut &SOut) const
int GetId() const
Returns edge ID. Always returns -1 since only edges in multigraphs have explicit IDs.
int GetId() const
Gets edge ID. Always returns -1 since only edges in multigraphs have explicit IDs.
TAIntI GetNAIntI(const TStr &attr, const int &NId) const
Returns an iterator referring to the node of ID NId in the graph.
int GetOutEId(const int &EdgeN) const
Returns ID of EdgeN-th out-edge.
TPt< TUndirNet > PUndirNet
Pointer to an undirected network (TUndirNet)
int AddSAttrDatN(const TNodeI &NodeI, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to NodeI.
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the graph.
bool HasFlag(const TGraphFlag &Flag) const
Allows for run-time checking the type of the network (see the TGraphFlag for flags).
int GetInDeg() const
Returns in-degree of the current node.
TNodeI(const THashIter &NodeHIter, const TNodeEDatNet *NetPt)
THash< TInt, TNode >::TIter THashIter
TVec< TPair< TInt, TEdgeData > > TNIdDatPrV
int AddSAttrDatN(const TNodeI &NodeI, const TStr &AttrName, const TStr &Val)
Adds Str sparse attribute with name AttrName to NodeI.
TStr GetStrAttrDefaultN(const TStr &attribute) const
Gets Str node attribute val. If not a proper attr, return default.
int GetSrcNId() const
Returns the source of the edge.
int GetInNId(const int &NodeN) const
Returns ID of NodeN-th in-node (the node pointing to the current node).
const TNodeData & GetNDat(const int &NId) const
Returns node data for the node of ID NId in the network.
int GetRndNId(TRnd &Rnd=TInt::Rnd)
Returns an ID of a random node in the network.
Node iterator. Only forward iteration (operator++) is supported.
TVec< TVec< TIntV > > VecOfIntVecVecsE
TNodeEdgeNet & operator=(const TNodeEdgeNet &Net)
void LoadShM(TShMIn &MStream)
void GetAttrVal(TStrV &Val) const
Gets vector of attribute values.
int AddSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName, const TStr &Val)
Adds Str sparse attribute with name AttrName to EdgeI.
int GetOutNId(const int &NodeN) const
Returns ID of NodeN-th out-node (the node the current node points to).
int GetDstNId() const
Returns the destination of the edge. Since the network is undirected, this is the node with a greater...
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
int AddSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName, const TFlt &Val)
Adds Flt sparse attribute with name AttrName to EdgeI.
TEdgeI(const TEdgeI &EdgeI)
void Save_V2(TSOut &SOut) const
Saves the graph without any sparse data structures. Available for backwards compatibility.
int GetRndNId(TRnd &Rnd=TInt::Rnd)
Returns an ID of a random node in the network.
bool IsInNId(const int &NId) const
int AddSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId, const TStr &Val)
Adds Str sparse attribute with id AttrId to EdgeI.
THash< TInt, TEdge > EdgeH
TEdgeI BegEI() const
Returns an iterator referring to the first edge in the network.
void SetAllEDat(const TEdgeData &EdgeDat)
Sets edge data for all the edges in the network to EDat.
bool HasFlag(const TGraphFlag &Flag) const
Allows for run-time checking the type of the network (see the TGraphFlag for flags).
void AttrValueEI(const TInt &EId, TStrV &Values) const
Returns a vector of attr values for edge EId.
int GetOutDeg() const
Returns out-degree of the current node.
void FltAttrValueNI(const TInt &NId, TFltV &Values) const
Returns a vector of attr values for node NId.
int GetSAttrDatN(const TNodeI &NodeI, const TStr &AttrName, TStr &ValX) const
Gets Str sparse attribute with name AttrName from NodeI.
Directed multigraph with node edge attributes.
bool operator==(const TEdgeI &EdgeI) const
TEdgeData & GetOutEDat(const int &EdgeN)
void LoadNetworkShM(TShMIn &ShMIn)
load network from shared memory for this network
static PDirNet New(const int &Nodes, const int &Edges)
Static constructor that returns a pointer to the network and reserves enough memory for Nodes nodes a...
void GetAttrNames(TStrV &Names) const
Gets vector of attribute names.
int AddSAttrDatN(const TNodeI &NodeI, const TInt &AttrId, const TStr &Val)
Adds Str sparse attribute with id AttrId to NodeI.
void GetFltAttrVal(TFltV &Val) const
Gets vector of flt attribute values.
bool Empty() const
Tests whether the graph is empty (has zero nodes).
static PNet LoadShM(TShMIn &ShMIn)
Static constructor that loads the network from shared memory.
TSizeTy SearchBin(const TVal &Val) const
Returns the position of an element with value Val.
int DelSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName)
Deletes sparse attribute with name AttrName from EdgeI.
TAStrI BegNAStrI(const TStr &attr) const
Returns an iterator referring to the first node's str attribute.
void GetFltAttrNames(TStrV &Names) const
Gets vector of flt attribute names.
TNodeNet(const int &Nodes, const int &Edges)
Constructor that reserves enough memory for a network of Nodes nodes and Edges edges.
bool IsEdge(const int &EId) const
Tests whether an edge with ID EId exists in the network.
bool IsDeleted() const
Returns true if the attribute has been deleted.
const TNodeData & operator()() const
TEdgeData & GetEDat(const int &EId)
Returns edge data for the edge with ID EId.
int AddNode(const TNodeI &NodeI)
Adds a node NodeI and its node data to the network.
int GetSrcNId() const
Gets the source of an edge.
int GetMxNId() const
Returns an ID that is larger than any node ID in the network.
int GetSAttrDatN(const TNodeI &NodeI, const TInt &AttrId, TFlt &ValX) const
Gets Flt sparse attribute with id AttrId from NodeI.
bool IsInEId(const int &EId) const
int AddSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to EdgeI.
void SortByKey(const bool &Asc=true)
void SetEDat(const int &EId, const TEdgeData &EdgeDat)
Sets edge data for the edge of ID NId in the network.
bool IsEdge(const int &SrcNId, const int &DstNId, const bool &IsDir=true) const
Tests whether an edge from node IDs SrcNId to DstNId exists in the network.
void LoadShM(TShMIn &MStream)
TEdge & GetEdge(const int &EId)
TVal * TIter
Random access iterator to TVal.
int GetNbrNId(const int &NodeN) const
Returns ID of NodeN-th neighboring node.
const TNode & GetNode(const int &NId) const
TAIntVI BegEAIntVI(const TStr &attr) const
Returns an iterator referring to the first edge's int attribute.
int GetNbrNId(const int &EdgeN) const
void LoadShM(TShMIn &MStream)
void DelNode(const TNode &NodeI)
Deletes node of ID NodeI.GetId() from the network.
TNodeI GetRndNI(TRnd &Rnd=TInt::Rnd)
Returns an interator referring to a random node in the graph.
int GetEId(const int &SrcNId, const int &DstNId) const
int GetId() const
Returns ID of the current node.
int GetKeyId(const TKey &Key) const
THash< TInt, TEdge >::TIter THashIter
Edge iterator. Only forward iteration (operator++) is supported.
void IntAttrValueNI(const TInt &NId, TIntV &Values) const
Returns a vector of attr values for node NId.
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the graph.
int GetSAttrDatN(const TNodeI &NodeI, const TInt &AttrId, TStr &ValX) const
Gets Str sparse attribute with id AttrId from NodeI.
void LoadNetworkShM(TShMIn &ShMIn)
int GetRndNId(TRnd &Rnd=TInt::Rnd)
Returns an ID of a random node in the network.
TAIntVI GetEAIntVI(const TStr &attr, const int &EId) const
Returns an iterator referring to the edge of ID EId in the graph.
bool IsNbrNId(const int &NId) const
TUndirNet(const TUndirNet &Graph)
void GetIntAttrNames(TStrV &Names) const
Gets vector of int attribute names.
const TNodeData & GetOutNDat(const int &NodeN) const
const TEdgeData & operator()() const
int GetId() const
Gets edge ID.
const TEdgeDat & GetNbrEDat(const int &EdgeN) const
void LoadShM(TShMIn &ShMIn)
Constructs the vector from a shared memory input.
TUndirNet(const int &Nodes, const int &Edges)
Constructor that reserves enough memory for a network of Nodes nodes and Edges edges.
TNodeNet< TInt > TIntNNet
TNodeNet< TFlt > TFltNNet
int GetSAttrVN(const TNodeI &NodeI, const TAttrType AttrType, TAttrPrV &AttrV) const
Gets a list of all sparse attributes of type AttrType for NodeI.
int AddNode(int NId=-1)
Adds a node of ID NId to the network.
Edge iterator. Only forward iteration (operator++) is supported.
static PNEANet Load_V2(TSIn &SIn)
Static constructor that loads the graph from a stream SIn and returns a pointer to it...
int DelAttrDatE(const TEdgeI &EdgeI, const TStr &attr)
Deletes the edge attribute for NodeI.
void Reserve(const int &Nodes, const int &Edges)
Reserves memory for a network of Nodes nodes and Edges edges.
int GetNodes() const
Returns the number of nodes in the network.
void SortEIdById(const bool &Asc=true)
Sorts edges by edge IDs.
bool IsOutNId(const int &NId) const
Tests whether the current node points to node with ID NId.
THash< TInt, TEdge >::TIter THashIter
void FltAttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of int attr names for node NId.
int AddNode(const TNodeI &NodeI)
Adds a node of ID NodeI.GetId() to the network.
TNodeEdgeNet(TSIn &SIn)
Constructor that loads the network from a (binary) stream SIn.
TNodeI BegNI() const
Returns an iterator referring to the first node in the network.
void Clr()
Deletes all nodes and edges from the network.
TNodeEdgeNet< TNodeData, TEdgeData > TNet
bool operator<(const TEdgeI &EdgeI) const
THash< TStr, TStr > StrDefaultsE
const TEdgeData & GetDat() const
int GetInEId(const int &NodeN) const
void SetNDat(const int &NId, const TNodeData &NodeDat)
Sets node data for the node of ID NId in the network.
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the network.
const TNode & GetNodeKId(const int &NodeKeyId) const
const TNodeData & GetSrcNDat() const
void StrAttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of str attr names for node NId.
TFlt GetFltAttrDefaultE(const TStr &attribute) const
Gets Flt edge attribute val. If not a proper attr, return default.
void Load(TSIn &InStream)
int GetEdges() const
Returns the number of edges in the graph.
void Save(TSOut &SOut) const
TNodeI GetRndNI(TRnd &Rnd=TInt::Rnd)
Returns an interator referring to a random node in the network.
TNodeNet< TNodeData > TNet
static PDirNet Load_V1(TSIn &SIn)
Static constructor that loads the network from a stream SIn and returns a pointer to it...
TNodeNet< TStr > TStrNNet
int GetOutEId(const int &EdgeN) const
int GetInDeg() const
Returns in-degree of the current node.
void Save(TSOut &SOut) const
Saves the graph to a (binary) stream SOut. Expects data structures for sparse attributes.
void GetEIdV(TIntV &EIdV) const
Returns a vector of all edge IDs in the network.
bool IsInEId(const int &EId) const
TEdgeI(const TEdgeI &EdgeI)
int GetDstNId() const
Returns the destination node of the edge.
TAIntVI BegNAIntVI(const TStr &attr) const
Returns an iterator referring to the first node's int attribute.
int AddStrAttrDatE(const TEdgeI &EdgeI, const TStr &value, const TStr &attr)
Attribute based add function for attr to Str value.
void GetAttrVal(TStrV &Val) const
Gets vector of attribute values.
const TEdgeDat & GetInEDat(const int &EdgeN) const
const TNodeData & GetDstNDat() const
TNodeNet & operator=(const TNodeNet &NodeNet)
const TNodeData & GetNbrNDat(const int &NodeN) const
TNEANet(const TNEANet &Graph)
static PNEANet Load_V1(TSIn &SIn)
Static constructor that loads the graph from a stream SIn and returns a pointer to it...
TEdgeI(const TEdgeI &EdgeI)
TIter BegI() const
Returns an iterator pointing to the first element in the vector.
static TStr Fmt(const char *FmtStr,...)
bool IsSorted(const bool &Asc=true) const
Checks whether the vector is sorted in ascending (if Asc=true) or descending (if Asc=false) order...
void Pack()
Reduces vector capacity (frees memory) to match its size.
static PNet New()
Static constructor that returns a pointer to the network.
void DelEdge(const int &EId)
Deletes an edge with ID EId from the network.
enum TGraphFlag_ TGraphFlag
Graph Flags, used for quick testing of graph types.
int DelSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName)
Deletes sparse attribute with name AttrName from EdgeI.
void operator()(TNode *n, TShMIn &ShMIn)
int GetOutNId(const int &NodeN) const
Returns ID of NodeN-th out-node (the node the current node points to).
bool operator<(const TEdge &Edge) const
int GetOutDeg() const
Returns out-degree of the current node.
const TNode & GetNode(const int &NId) const
int GetOutNId(const int &NodeN) const
Returns ID of NodeN-th out-node (the node the current node points to).
int GetSAttrDatN(const TNodeI &NodeI, const TInt &AttrId, TStr &ValX) const
Gets Str sparse attribute with id AttrId from NodeI.
int GetMxEId() const
Returns an ID that is larger than any edge ID in the network.
int GetSAttrDatN(const TNodeI &NodeI, const TStr &AttrName, TStr &ValX) const
Gets Str sparse attribute with name AttrName from NodeI.
int GetEdges() const
Returns the number of edges in the network.
int GetNbrEId(const int &EdgeN) const
Returns ID of EdgeN-th in or out-edge.
int DelSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId)
Deletes sparse attribute with id AttrId from EdgeI.
const TEdgeData & GetDat() const
int AddSAttrDatN(const TNodeI &NodeI, const TInt &AttrId, const TFlt &Val)
Adds Flt sparse attribute with id AttrId to NodeI.
int AddSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId, const TFlt &Val)
Adds Flt sparse attribute with id AttrId to EdgeI.
TVec< TFltV > VecOfFltVecsN
int GetSAttrDatN(const TNodeI &NodeI, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from NodeI.
TAFltI EndEAFltI(const TStr &attr) const
Returns an iterator referring to the past-the-end edge's attribute.
TAFltI GetNAFltI(const TStr &attr, const int &NId) const
Returns an iterator referring to the node of ID NId in the graph.
#define EAssertR(Cond, MsgStr)
int AddSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName, const TFlt &Val)
Adds Flt sparse attribute with name AttrName to EdgeI.
bool HasFlag(const TGraphFlag &Flag) const
Allows for run-time checking the type of the network (see the TGraphFlag for flags).
void Clr()
Deletes all nodes and edges from the graph.
void Clr(const bool &DoDel=true, const bool &ResetDat=true)
Deletes all nodes and edges from the network.
TEdgeData & GetNbrEDat(const int &EdgeN)
void Save(TSOut &SOut) const
void operator()(TNode *n, TShMIn &ShMIn)
TVec< THash< TInt, TIntV > > VecOfIntHashVecsN
const TNodeData & GetNbrNDat(const int &EdgeN) const
int AddSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName, const TStr &Val)
Adds Str sparse attribute with name AttrName to EdgeI.
int GetEId(const int &SrcNId, const int &DstNId) const
Returns an edge ID between node IDs SrcNId and DstNId, if such an edge exists. Otherwise, return -1.
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the network.
bool Empty() const
Tests whether the network is empty (has zero nodes).
bool IsNbrNId(const int &NId) const
Tests whether node with ID NId is a neighbor of the current node.
int AddSAttrDatN(const TNodeI &NodeI, const TStr &AttrName, const TStr &Val)
Adds Str sparse attribute with name AttrName to NodeI.
void GetIntVAttrNames(TStrV &Names) const
Gets vector of int attribute names.
const TNodeData & GetOutNDat(const int &NodeN) const
void DelNode(const TNode &NodeI)
Deletes node of ID NodeI.GetId() from the network.
TEdgeI GetEI(const int &SrcNId, const int &DstNId) const
Returns an iterator referring to edge (SrcNId, DstNId) in the graph.
void Clr(const bool &DoDel=true, const int &NoDelLim=-1, const bool &ResetDat=true)
TIntPr OrderEdgeNodes(const int &SrcNId, const int &DstNId) const
bool IsInEId(const int &EId) const
Tests whether the edge with ID EId is an in-edge of current node.
bool operator<(const TNode &Node) const
int GetSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId, TFlt &ValX) const
Gets Flt sparse attribute with id AttrId from EdgeI.
int AddEdge(const TEdgeI &EdgeI)
Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() and its edge data to the network...
void GetNIdV(TIntV &NIdV) const
Gets a vector IDs of all nodes in the network.
THash< TStr, TInt > IntDefaultsN
TNodeI(const THashIter &NodeHIter, const TNEANet *GraphPt)
TAIntVI(const TIntVVecIter &HIter, const TIntHVecIter &HHIter, TStr attribute, bool isEdgeIter, const TNEANet *GraphPt, bool is_dense)
const TNode & GetNode(const int &NId) const
Returns node element for the node of ID NId in the network.
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
int GetNodes() const
Returns the number of nodes in the network.
int GetRndNId(TRnd &Rnd=TInt::Rnd)
Returns an ID of a random node in the network.
bool IsInNId(const int &NId) const
Tests whether node with ID NId points to the current node.
int GetOutNId(const int &NodeN) const
Returns ID of NodeN-th out-node (the node the current node points to).
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the network.
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the network.
void DelNode(const int &NId)
Deletes node of ID NId from the network.
int GetOutDeg() const
Returns out-degree of the current node.
THash< TInt, TNode > NodeH
int AppendIntVAttrDatE(const TEdgeI &EdgeI, const TInt &value, const TStr &attr)
Appends value onto the TIntV attribute for the given node.
int GetSAttrDatN(const TNodeI &NodeI, const TInt &AttrId, TInt &ValX) const
Gets Int sparse attribute with id AttrId from NodeI.
int GetRndKeyId(TRnd &Rnd) const
Get an index of a random element. If the hash table has many deleted keys, this may take a long time...
bool IsNbrNId(const int &NId) const
Tests whether node with ID NId is a neighbor of the current node.
static PDirNet New()
Static constructor that returns a pointer to the network. Call: PDirNet Graph = TDirNet::New().
TEdge & GetEdge(const int &EId)
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
int GetSAttrVN(const TNodeI &NodeI, const TAttrType AttrType, TAttrPrV &AttrV) const
Gets a list of all sparse attributes of type AttrType for NodeI.
int GetSrcNId() const
Returns the source of the edge. Since the network is undirected, this is the node with a smaller ID o...
TEdgeI & operator=(const TEdgeI &EdgeI)
TFlt GetFltAttrIndDatN(const TNodeI &NodeI, const int &index)
Gets the value of a float node attr specified by node iterator NodeI and the attr index...
int GetDstNId() const
Gets the destination node of an edge.
TDirNet(TSIn &SIn)
Constructor that loads the network from a (binary) stream SIn.
TEdgeI & operator=(const TEdgeI &EdgeI)
bool IsNbrEId(const int &EId) const
Tests whether the edge with ID EId is an in or out-edge of current node.
TNodeI BegNI() const
Returns an iterator referring to the first node in the graph.
void GetNIdV(TIntV &NIdV) const
Gets a vector IDs of all nodes in the network.
TVec< TVec< TIntV > > VecOfIntVecVecsN
TEdgeI BegEI() const
Returns an iterator referring to the first edge in the network.
int AddSAttrDatN(const TNodeI &NodeI, const TInt &AttrId, const TInt &Val)
Adds Int sparse attribute with id AttrId to NodeI.
int AddSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName, const TStr &Val)
Adds Str sparse attribute with name AttrName to EdgeI.
void Reserve(const TSizeTy &_MxVals)
Reserves enough memory for the vector to store _MxVals elements.
int GetSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from EdgeI.
TEdge(const int &EId, const int &SourceNId, const int &DestNId)
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the graph.
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
const TEdgeData & GetOutEDat(const int &EdgeN) const
TFlt GetFltAttrDefaultN(const TStr &attribute) const
Gets Flt node attribute val. If not a proper attr, return default.
bool IsInNId(const int &NId) const
Tests whether node with ID NId points to the current node.
int GetInEId(const int &EdgeN) const
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the network.
int AddSAttrDatN(const TNodeI &NodeI, const TInt &AttrId, const TFlt &Val)
Adds Flt sparse attribute with id AttrId to NodeI.
void IntAttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of int attr names for edge EId.
int GetSAttrDatE(const TEdgeI &EdgeI, const TStr &AttrName, TFlt &ValX) const
Gets Flt sparse attribute with name AttrName from EdgeI.
TNodeI BegNI() const
Returns an iterator referring to the first node in the network.
void GetIntAttrNames(TStrV &Names) const
Gets vector of int attribute names.
void Reserve(const int &Nodes, const int &Edges)
Reserves memory for a network of Nodes nodes and Edges edges.
TNodeI & operator=(const TNodeI &NodeI)
TInt GetIntAttrDefaultN(const TStr &attribute) const
Gets Int node attribute val. If not a proper attr, return default.
TAStrI(const TStrVecIter &HIter, TStr attribute, bool isEdgeIter, const TNEANet *GraphPt)
TNodeEdgeNet< TInt, TInt > TIntNENet
static PNet Load(TSIn &SIn)
Static constructor that loads the network from a stream SIn and returns a pointer to it...
bool IsOk(const bool &ThrowExcept=true) const
Checks the network data structure for internal consistency.
int GetInNId(const int &NodeN) const
void DelNode(const TNode &NodeI)
Deletes node of ID NodeI.GetId() from the network.
bool IsOutNId(const int &NId) const
TDirNet(const int &Nodes, const int &Edges)
Constructor that reserves enough memory for a network of Nodes nodes and Edges edges.
TNodeData & GetNbrNDat(const int &NodeN)
int GetInDeg() const
Returns in-degree of the current node (returns same as value GetDeg() since the network is undirected...
Node iterator. Only forward iteration (operator++) is supported.
int GetSAttrDatN(const TNodeI &NodeI, const TStr &AttrName, TStr &ValX) const
Gets Str sparse attribute with name AttrName from NodeI.
int DelSAttrDatN(const TNodeI &NodeI, const TStr &AttrName)
Deletes sparse attribute with name AttrName from NodeI.
int AddSAttrDatN(const TNodeI &NodeI, const TStr &AttrName, const TFlt &Val)
Adds Flt sparse attribute with name AttrName to NodeI.
TPt< TNEANet > PNEANet
Pointer to a directed attribute multigraph (TNEANet)
bool IsKey(const TKey &Key) const
TIntV GetDat() const
Returns an attribute of the node.
static PDirNet Load(TSIn &SIn)
Static constructor that loads the network from a stream SIn and returns a pointer to it...
int AddAttributes(const int NId)
const TEdge & GetEdge(const int &EId) const
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
int GetSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId, TInt &ValX) const
Gets Int sparse attribute with id AttrId from EdgeI.
static PNEANet New()
Static cons returns pointer to graph. Ex: PNEANet Graph=TNEANet::New().
void GetFltAttrNames(TStrV &Names) const
Gets vector of flt attribute names.
bool IsOk(const bool &ThrowExcept=true) const
Checks the network data structure for internal consistency.
static PNet LoadShM(TShMIn &ShMIn)
Static constructor that loads the network from memory.
int AddNodeUnchecked(int NId=-1)
Adds a node of ID NId to the network, noop if the node already exists.
TAIntVI & operator++(int)
TNodeI(const TNodeI &NodeI)
int GetSrcNId() const
Returns the source node of the edge.
TNodeData & GetOutNDat(const int &NodeN)
int DelAttrDatN(const TNodeI &NodeI, const TStr &attr)
Deletes the node attribute for NodeI.
int GetDeg() const
Returns degree of the current node, the sum of in-degree and out-degree.
TIter GetI(const TSizeTy &ValN) const
Returns an iterator an element at position ValN.
void GetStrAttrNames(TStrV &Names) const
Gets vector of str attribute names.
TNEANet(bool copyAll, const TNEANet &Graph)
bool IsEdge(const int &SrcNId, const int &DstNId, const bool &IsDir=true) const
Tests whether an edge from node IDs SrcNId to DstNId exists in the network.
TDat & AddDat(const TKey &Key)
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the network.
bool operator==(const TNodeI &NodeI) const
TEdgeDat & GetInEDat(const int &EdgeN)
int GetSAttrDatN(const TNodeI &NodeI, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from NodeI.
void Save(TSOut &SOut) const
int GetSAttrVE(const TEdgeI &EdgeI, const TAttrType AttrType, TAttrPrV &AttrV) const
Gets a list of all sparse attributes of type AttrType for EdgeI.
Node/edge string attribute iterator. Iterates through all nodes/edges for one string attribute...
bool operator<(const TNodeI &NodeI) const
void SortNodeAdjV()
Sorts the adjacency lists of each node.
void GetAttrNames(TStrV &Names) const
Gets vector of attribute names.
Node iterator. Only forward iteration (operator++) is supported.
int AddIntAttrDatN(const TNodeI &NodeI, const TInt &value, const TStr &attr)
Attribute based add function for attr to Int value.
void GetIntAttrVal(TIntV &Val) const
Gets vector of int attribute values.
int AddSAttrDatN(const TNodeI &NodeI, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to NodeI.
int AddSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId, const TStr &Val)
Adds Str sparse attribute with id AttrId to EdgeI.
void GetIntVAttrVal(TVec< TIntV > &Val) const
Gets vector of int attribute values.
TAFltI(const TFltVecIter &HIter, TStr attribute, bool isEdgeIter, const TNEANet *GraphPt)
void Save(TSOut &SOut) const
TStr GetStrAttrIndDatN(const TNodeI &NodeI, const int &index)
Gets the value of a string node attr specified by node iterator NodeI and the attr index...
THash< TInt, TNode >::TIter THashIter
TEdgeI(const TNodeI &NodeI, const TNodeI &EndNodeI, const int &EdgeN=0)
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
void GetIntAttrVal(TIntV &Val) const
Gets vector of int attribute values.
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
void SortNIdV()
Sorts the adjacency lists of the current node.
Node iterator. Only forward iteration (operator++) is supported.
int GetOutEId(const int &NodeN) const
THash< TStr, TBool > KeyToDenseN
KeyToDense[N|E]: Key->(True if Vec, False if Hash)
static PNEANet New(const int &Nodes, const int &Edges)
Static constructor that returns a pointer to the graph and reserves enough memory for Nodes nodes and...
int GetRndEId(TRnd &Rnd=TInt::Rnd)
Returns an ID of a random edge in the network.
const TKey & GetKey(const int &KeyId) const
int AddSAttrDatN(const TNodeI &NodeI, const TInt &AttrId, const TStr &Val)
Adds Str sparse attribute with id AttrId to NodeI.
int GetMxNId() const
Returns an ID that is larger than any node ID in the network.
THash< TInt, TNode >::TIter THashIter
Node Network (directed graph, TNGraph with data on nodes only).
int GetId() const
Returns ID of the current node.
int AddSAttrDatE(const TEdgeI &EdgeI, const TInt &AttrId, const TInt &Val)
Adds Int sparse attribute with id AttrId to EdgeI.
int GetDeg() const
Returns degree of the current node.
const TEdgeData & GetEDat(const int &EId) const
Returns edge data for the edge with ID EId.
TNodeEDatNet< TStr, TInt > TStrIntNEDNet
int GetId() const
Returns ID of the current node.
TEdgeI BegEI() const
Returns an iterator referring to the first edge in the network.
TUndirNet(TSIn &SIn)
Constructor that loads the network from a (binary) stream SIn.
const TEdgeData & GetNbrEDat(const int &EdgeN) const
int GetId() const
Returns ID of the current node.
const TNodeData & GetDstNDat() const
const TNodeData & GetDat() const
TNode(const int &NId, const TNodeData &NodeData)
int GetDstNId() const
Gets destination of an edge.
int AddSAttrDatN(const TNodeI &NodeI, const TInt &AttrId, const TFlt &Val)
Adds Flt sparse attribute with id AttrId to NodeI.
int GetNbrNId(const int &NodeN) const
void GetIntVAttrNames(TStrV &Names) const
Gets vector of int attribute names.
bool operator==(const TNodeI &NodeI) const
TPt< TDirNet > PDirNet
Pointer to a directed network (TDirNet)
static PNet Load(TSIn &SIn)
Static constructor that loads the network from a stream SIn and returns a pointer to it...
TFlt GetFltAttrIndDatE(const TEdgeI &EdgeI, const int &index)
Gets the value of a float edge attr specified by edge iterator EdgeI and the attr index...
TNodeEdgeNet(const int &Nodes, const int &Edges)
Constructor that reserves enough memory for a network of Nodes nodes and Edges edges.
int GetNodes() const
Returns the number of nodes in the network.
TInt GetIntAttrIndDatE(const TEdgeI &EdgeI, const int &index)
Gets the value of an int edge attr specified by edge iterator EdgeI and the attr index.
TNodeI GetRndNI(TRnd &Rnd=TInt::Rnd)
Returns an interator referring to a random node in the network.
TIter GetI(const TKey &Key) const
void SortByDat(const bool &Asc=true)
TPt< TFltNENet > PFltNENet
Implements a single CrossNet consisting of edges between two TModeNets (could be the same TModeNet) ...
int GetMxNId() const
Returns an ID that is larger than any node ID in the network.
void Save_V1(TSOut &SOut) const
Saves the network to a (binary) stream SOut. Available for backwards compatibility.
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the network.