16 template <
class TNodeData>
29 TNode() : Id(-1), NodeDat(), InNIdV(), OutNIdV() { }
30 TNode(
const int& NId) : Id(NId), NodeDat(), InNIdV(), OutNIdV() { }
31 TNode(
const int& NId,
const TNodeData& NodeData) : Id(NId), NodeDat(NodeData), InNIdV(), OutNIdV() { }
32 TNode(
const TNode& Node) : Id(Node.Id), NodeDat(Node.NodeDat), InNIdV(Node.InNIdV), OutNIdV(Node.OutNIdV) { }
33 TNode(
TSIn& SIn) : Id(SIn), NodeDat(SIn), InNIdV(SIn), OutNIdV(SIn) { }
41 int GetInNId(
const int& NodeN)
const {
return InNIdV[NodeN]; }
42 int GetOutNId(
const int& NodeN)
const {
return OutNIdV[NodeN]; }
49 NodeDat = TNodeData(MStream);
66 TNodeI(
const TNodeI& NodeI) : NodeHI(NodeI.NodeHI), Net(NodeI.Net) { }
74 int GetId()
const {
return NodeHI.GetDat().GetId(); }
76 int GetDeg()
const {
return NodeHI.GetDat().GetDeg(); }
78 int GetInDeg()
const {
return NodeHI.GetDat().GetInDeg(); }
80 int GetOutDeg()
const {
return NodeHI.GetDat().GetOutDeg(); }
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); }
99 const TNodeData&
operator () ()
const {
return NodeHI.GetDat().NodeDat; }
101 const TNodeData&
GetDat()
const {
return NodeHI.GetDat().GetDat(); }
102 TNodeData&
GetDat() {
return NodeHI.GetDat().GetDat(); }
118 TEdgeI() : CurNode(), EndNode(), CurEdge(0) { }
119 TEdgeI(
const TNodeI& NodeI,
const TNodeI& EndNodeI,
const int& EdgeN=0) : CurNode(NodeI), EndNode(EndNodeI), CurEdge(EdgeN) { }
120 TEdgeI(
const TEdgeI& EdgeI) : CurNode(EdgeI.CurNode), EndNode(EdgeI.EndNode), CurEdge(EdgeI.CurEdge) { }
124 while (CurNode < EndNode && CurNode.
GetOutDeg()==0) { CurNode++; } }
return *
this; }
162 explicit TNodeNet(
const int& Nodes,
const int& Edges) : MxNId(0) {
Reserve(Nodes, Edges); }
181 return PNet(Network);
186 if (
this!=&NodeNet) { NodeH=NodeNet.
NodeH; MxNId=NodeNet.
MxNId; }
return *
this; }
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);
219 TNodeI
BegNI()
const {
return TNodeI(NodeH.
BegI(),
this); }
221 TNodeI
EndNI()
const {
return TNodeI(NodeH.
EndI(),
this); }
223 TNodeI
GetNI(
const int& NId)
const {
return TNodeI(NodeH.
GetI(NId),
this); }
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) {
276 MxNId = 0; NodeH.
Clr(DoDel, -1, ResetDat); }
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>
506 TNode() : Id(-1), NodeDat(), InNIdV(), OutNIdV() { }
507 TNode(
const int& NId) : Id(NId), NodeDat(), InNIdV(), OutNIdV() { }
508 TNode(
const int& NId,
const TNodeData& NodeData) : Id(NId), NodeDat(NodeData), InNIdV(), OutNIdV() { }
509 TNode(
const TNode& Node) : Id(Node.Id), NodeDat(Node.NodeDat), InNIdV(Node.InNIdV), OutNIdV(Node.OutNIdV) { }
510 TNode(
TSIn& SIn) : Id(SIn), NodeDat(SIn), InNIdV(SIn), OutNIdV(SIn) { }
518 int GetInNId(
const int& EdgeN)
const {
return InNIdV[EdgeN]; }
519 int GetOutNId(
const int& EdgeN)
const {
return OutNIdV[EdgeN].Val1; }
521 TEdgeData&
GetOutEDat(
const int& EdgeN) {
return OutNIdV[EdgeN].Val2; }
522 const TEdgeData&
GetOutEDat(
const int& EdgeN)
const {
return OutNIdV[EdgeN].Val2; }
528 NodeDat = TNodeData(MStream);
553 int GetId()
const {
return NodeHI.GetDat().GetId(); }
555 int GetDeg()
const {
return NodeHI.GetDat().GetDeg(); }
557 int GetInDeg()
const {
return NodeHI.GetDat().GetInDeg(); }
559 int GetOutDeg()
const {
return NodeHI.GetDat().GetOutDeg(); }
563 int GetInNId(
const int& NodeN)
const {
return NodeHI.GetDat().GetInNId(NodeN); }
567 int GetOutNId(
const int& NodeN)
const {
return NodeHI.GetDat().GetOutNId(NodeN); }
571 int GetNbrNId(
const int& NodeN)
const {
return NodeHI.GetDat().GetNbrNId(NodeN); }
573 bool IsInNId(
const int& NId)
const {
return NodeHI.GetDat().IsInNId(NId); }
575 bool IsOutNId(
const int& NId)
const {
return NodeHI.GetDat().IsOutNId(NId); }
579 const TNodeData&
operator () ()
const {
return NodeHI.GetDat().NodeDat; }
581 const TNodeData&
GetDat()
const {
return NodeHI.GetDat().GetDat(); }
582 TNodeData&
GetDat() {
return NodeHI.GetDat().GetDat(); }
590 TEdgeData&
GetOutEDat(
const int& EdgeN) {
return NodeHI.GetDat().GetOutEDat(EdgeN); }
591 const TEdgeData&
GetOutEDat(
const int& EdgeN)
const {
return NodeHI.GetDat().GetOutEDat(EdgeN); }
605 TEdgeI() : CurNode(), EndNode(), CurEdge(0) { }
606 TEdgeI(
const TNodeI& NodeI,
const TNodeI& EndNodeI,
const int& EdgeN=0) : CurNode(NodeI), EndNode(EndNodeI), CurEdge(EdgeN) { }
607 TEdgeI(
const TEdgeI& EdgeI) : CurNode(EdgeI.CurNode), EndNode(EdgeI.EndNode), CurEdge(EdgeI.CurEdge) { }
611 while (CurNode < EndNode && CurNode.
GetOutDeg()==0) { CurNode++; } }
return *
this; }
670 TNet* Network =
new TNet();
672 return PNet(Network);
677 NodeH=NodeNet.
NodeH; MxNId=NodeNet.
MxNId; }
return *
this; }
698 int AddNode(
int NId,
const TNodeData& NodeDat);
700 int AddNode(
const TNodeI& NodeI) {
return AddNode(NodeI.GetId(), NodeI.GetDat()); }
710 TNodeI
BegNI()
const {
return TNodeI(NodeH.
BegI(),
this); }
712 TNodeI
EndNI()
const {
return TNodeI(NodeH.
EndI(),
this); }
714 TNodeI
GetNI(
const int& NId)
const {
return TNodeI(NodeH.
GetI(NId),
this); }
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) {
787 MxNId = 0; NodeH.
Clr(DoDel, -1, ResetDat); }
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>
1087 TNode() : Id(-1), InEIdV(), OutEIdV(), NodeDat() { }
1088 TNode(
const int& NId) : Id(NId), InEIdV(), OutEIdV(), NodeDat() { }
1089 TNode(
const int& NId,
const TNodeData& NodeData) : Id(NId), InEIdV(), OutEIdV(), NodeDat(NodeData) { }
1090 TNode(
const TNode& Node) : Id(Node.Id), InEIdV(Node.InEIdV), OutEIdV(Node.OutEIdV), NodeDat(Node.NodeDat) { }
1091 TNode(
TSIn& SIn) : Id(SIn), InEIdV(SIn), OutEIdV(SIn), NodeDat(SIn) { }
1100 int GetInEId(
const int& NodeN)
const {
return InEIdV[NodeN]; }
1101 int GetOutEId(
const int& NodeN)
const {
return OutEIdV[NodeN]; }
1110 NodeDat = TNodeData(MStream);
1120 TEdge() : Id(-1), SrcNId(-1), DstNId(-1), EdgeDat() { }
1121 TEdge(
const int& EId,
const int& SourceNId,
const int& DestNId) : Id(EId), SrcNId(SourceNId), DstNId(DestNId), EdgeDat() { }
1122 TEdge(
const int& EId,
const int& SourceNId,
const int& DestNId,
const TEdgeData& EdgeData) : Id(EId), SrcNId(SourceNId), DstNId(DestNId), EdgeDat(EdgeData) { }
1123 TEdge(
const TEdge& Edge) : Id(Edge.Id), SrcNId(Edge.SrcNId), DstNId(Edge.DstNId), EdgeDat(Edge.EdgeDat) { }
1124 TEdge(
TSIn& SIn) : Id(SIn), SrcNId(SIn), DstNId(SIn), EdgeDat(SIn) { }
1131 Id =
TInt(InStream);
1132 SrcNId =
TInt(InStream);
1133 DstNId =
TInt(InStream);
1134 EdgeDat = TEdgeData(InStream);
1158 int GetId()
const {
return NodeHI.GetDat().GetId(); }
1160 int GetDeg()
const {
return NodeHI.GetDat().GetDeg(); }
1162 int GetInDeg()
const {
return NodeHI.GetDat().GetInDeg(); }
1164 int GetOutDeg()
const {
return NodeHI.GetDat().GetOutDeg(); }
1168 int GetInNId(
const int& EdgeN)
const {
return Net->
GetEdge(NodeHI.GetDat().GetInEId(EdgeN)).GetSrcNId(); }
1172 int GetOutNId(
const int& EdgeN)
const {
return Net->
GetEdge(NodeHI.GetDat().GetOutEId(EdgeN)).GetDstNId(); }
1179 bool IsInNId(
const int& NId)
const;
1181 bool IsOutNId(
const int& NId)
const;
1185 const TNodeData&
operator () ()
const {
return NodeHI.GetDat().GetDat(); }
1187 const TNodeData&
GetDat()
const {
return NodeHI.GetDat().GetDat(); }
1188 TNodeData&
GetDat() {
return NodeHI.GetDat().GetDat(); }
1197 int GetInEId(
const int& EdgeN)
const {
return NodeHI.GetDat().GetInEId(EdgeN); }
1199 int GetOutEId(
const int& EdgeN)
const {
return NodeHI.GetDat().GetOutEId(EdgeN); }
1201 int GetNbrEId(
const int& EdgeN)
const {
return NodeHI.GetDat().GetNbrEId(EdgeN); }
1203 bool IsInEId(
const int& EId)
const {
return NodeHI.GetDat().IsInEId(EId); }
1205 bool IsOutEId(
const int& EId)
const {
return NodeHI.GetDat().IsOutEId(EId); }
1207 bool IsNbrEId(
const int& EId)
const {
return NodeHI.GetDat().IsNbrEId(EId); }
1233 int GetId()
const {
return EdgeHI.GetDat().GetId(); }
1235 int GetSrcNId()
const {
return EdgeHI.GetDat().GetSrcNId(); }
1237 int GetDstNId()
const {
return EdgeHI.GetDat().GetDstNId(); }
1238 const TEdgeData&
operator () ()
const {
return EdgeHI.GetDat().GetDat(); }
1240 const TEdgeData&
GetDat()
const {
return EdgeHI.GetDat().GetDat(); }
1241 TEdgeData&
GetDat() {
return EdgeHI.GetDat().GetDat(); }
1269 MxNId =
TInt(ShMIn);
1270 MxEId =
TInt(ShMIn);
1271 LoadTNodeFunctor fn;
1278 explicit TNodeEdgeNet(
const int& Nodes,
const int& Edges) : CRef(), MxNId(0), MxEId(0) {
Reserve(Nodes, Edges); }
1297 TNet* Network =
new TNet();
1299 return PNet(Network);
1304 if (
this!=&Net) { NodeH=Net.
NodeH; EdgeH=Net.
EdgeH; MxNId=Net.
MxNId; MxEId=Net.
MxEId; }
return *
this; }
1325 int AddNode(
int NId,
const TNodeData& NodeDat);
1342 TNodeI
GetNI(
const int& NId)
const {
return TNodeI(NodeH.
GetI(NId),
this); }
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; }
1393 TEdgeI
GetEI(
const int& EId)
const {
return TEdgeI(EdgeH.
GetI(EId),
this); }
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) { }
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()); }
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) { }
1785 Id =
TInt(InStream);
1786 SrcNId =
TInt(InStream);
1787 DstNId =
TInt(InStream);
1799 TNodeI(
const THashIter& NodeHIter,
const TNEANet* GraphPt) : NodeHI(NodeHIter), Graph(GraphPt) { }
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); }
1874 TEdgeI(
const THashIter& EdgeHIter,
const TNEANet *GraphPt) : EdgeHI(EdgeHIter), Graph(GraphPt) { }
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; }
1944 TAIntVI() : HI(), IsDense(), HHI(), attr(), Graph(NULL) { }
1945 TAIntVI(
const TIntVVecIter& HIter,
const TIntHVecIter& HHIter,
TStr attribute,
bool isEdgeIter,
const TNEANet* GraphPt,
bool is_dense) : HI(HIter), IsDense(is_dense), HHI(HHIter), attr(), Graph(GraphPt) {
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; }
1969 TAFltVI() : HI(), IsDense(), HHI(), attr(), Graph(NULL) { }
1970 TAFltVI(
const TFltVVecIter& HIter,
const TFltHVecIter& HHIter,
TStr attribute,
bool isEdgeIter,
const TNEANet* GraphPt,
bool is_dense) : HI(HIter), IsDense(is_dense), HHI(HHIter), attr(), Graph(GraphPt) {
1971 isNode = !isEdgeIter; attr = attribute;
1973 TAFltVI(
const TAFltVI& I) : HI(I.HI), IsDense(I.IsDense), HHI(I.HHI), attr(I.attr), Graph(I.Graph) { isNode = I.
isNode; }
1975 bool operator < (
const TAFltVI& I)
const {
return HI == I.
HI ? HHI < I.
HHI : HI < I.
HI; }
1976 bool operator == (
const TAFltVI& I)
const {
return HI == I.
HI && HHI == I.
HHI; }
1993 TAStrI(
const TStrVecIter& HIter,
TStr attribute,
bool isEdgeIter,
const TNEANet* GraphPt) : HI(HIter), attr(), Graph(GraphPt) { isNode = !isEdgeIter; attr = attribute; }
1996 bool operator < (
const TAStrI& I)
const {
return HI < I.
HI; }
1997 bool operator == (
const TAStrI& I)
const {
return HI == I.
HI; }
2016 TAFltI(
const TFltVecIter& HIter,
TStr attribute,
bool isEdgeIter,
const TNEANet* GraphPt) : HI(HIter), attr(), Graph(GraphPt) { isNode = !isEdgeIter; attr = attribute; }
2019 bool operator < (
const TAFltI& I)
const {
return HI < I.
HI; }
2020 bool operator == (
const TAFltI& I)
const {
return HI == I.
HI; }
2083 template<
typename TElem>
2091 template<
typename TElem>
2094 n->LoadShM(ShMIn, f);
2101 template<
typename TElem>
2104 n->LoadShM(ShMIn, f);
2111 if (!KeyToDenseN.
IsKey(attr))
return -1;
2112 if (KeyToDenseN.
GetDat(attr))
return 1;
2117 if (!KeyToDenseE.
IsKey(attr))
return -1;
2118 if (KeyToDenseE.
GetDat(attr))
return 1;
2124 TNEANet() : CRef(), MxNId(0), MxEId(0), NodeH(), EdgeH(),
2125 KeyToIndexTypeN(), KeyToIndexTypeE(), KeyToDenseN(), KeyToDenseE(), IntDefaultsN(), IntDefaultsE(),
2126 StrDefaultsN(), StrDefaultsE(), FltDefaultsN(), FltDefaultsE(),
2127 VecOfIntVecsN(), VecOfIntVecsE(), VecOfStrVecsN(), VecOfStrVecsE(),
2128 VecOfFltVecsN(), VecOfFltVecsE(), VecOfIntVecVecsN(), VecOfIntVecVecsE(),
2129 VecOfFltVecVecsN(), VecOfFltVecVecsE(),
2130 VecOfIntHashVecsN(), VecOfIntHashVecsE(),
2131 VecOfFltHashVecsN(), VecOfFltHashVecsE(),
2132 SAttrN(), SAttrE(){ }
2134 explicit TNEANet(
const int& Nodes,
const int& Edges) : CRef(),
2135 MxNId(0), MxEId(0), NodeH(), EdgeH(), KeyToIndexTypeN(), KeyToIndexTypeE(), KeyToDenseN(), KeyToDenseE(),
2136 IntDefaultsN(), IntDefaultsE(), StrDefaultsN(), StrDefaultsE(),
2137 FltDefaultsN(), FltDefaultsE(), VecOfIntVecsN(), VecOfIntVecsE(),
2138 VecOfStrVecsN(), VecOfStrVecsE(), VecOfFltVecsN(), VecOfFltVecsE(), VecOfIntVecVecsN(), VecOfIntVecVecsE(),
2139 VecOfFltVecVecsN(), VecOfFltVecVecsE(),
2140 VecOfIntHashVecsN(), VecOfIntHashVecsE(),
2141 VecOfFltHashVecsN(), VecOfFltHashVecsE(),
2145 NodeH(Graph.NodeH), EdgeH(Graph.EdgeH), KeyToIndexTypeN(), KeyToIndexTypeE(), KeyToDenseN(), KeyToDenseE(),
2146 IntDefaultsN(), IntDefaultsE(), StrDefaultsN(), StrDefaultsE(),
2147 FltDefaultsN(), FltDefaultsE(), VecOfIntVecsN(), VecOfIntVecsE(),
2148 VecOfStrVecsN(), VecOfStrVecsE(), VecOfFltVecsN(), VecOfFltVecsE(), VecOfIntVecVecsN(), VecOfIntVecVecsE(),
2149 VecOfFltVecVecsN(), VecOfFltVecVecsE(),
2150 VecOfIntHashVecsN(), VecOfIntHashVecsE(),
2151 VecOfFltHashVecsN(), VecOfFltHashVecsE(),
2152 SAttrN(), SAttrE() { }
2155 KeyToIndexTypeN(SIn), KeyToIndexTypeE(SIn), KeyToDenseN(SIn), KeyToDenseE(SIn), IntDefaultsN(SIn), IntDefaultsE(SIn),
2156 StrDefaultsN(SIn), StrDefaultsE(SIn), FltDefaultsN(SIn), FltDefaultsE(SIn),
2157 VecOfIntVecsN(SIn), VecOfIntVecsE(SIn), VecOfStrVecsN(SIn),VecOfStrVecsE(SIn),
2158 VecOfFltVecsN(SIn), VecOfFltVecsE(SIn), VecOfIntVecVecsN(SIn), VecOfIntVecVecsE(SIn),
2159 VecOfFltVecVecsN(SIn), VecOfFltVecVecsE(SIn),
2160 VecOfIntHashVecsN(SIn), VecOfIntHashVecsE(SIn),
2161 VecOfFltHashVecsN(SIn), VecOfFltHashVecsE(SIn),
2162 SAttrN(SIn), SAttrE(SIn) { }
2164 TNEANet(
const TNEANet& Graph,
bool modeSubGraph) : MxNId(Graph.MxNId), MxEId(Graph.MxEId),
2165 NodeH(Graph.NodeH), EdgeH(Graph.EdgeH), KeyToIndexTypeN(), KeyToIndexTypeE(Graph.KeyToIndexTypeE), KeyToDenseN(), KeyToDenseE(Graph.KeyToDenseE),
2166 IntDefaultsN(Graph.IntDefaultsN), IntDefaultsE(Graph.IntDefaultsE), StrDefaultsN(Graph.StrDefaultsN), StrDefaultsE(Graph.StrDefaultsE),
2167 FltDefaultsN(Graph.FltDefaultsN), FltDefaultsE(Graph.FltDefaultsE), VecOfIntVecsN(Graph.VecOfIntVecsN), VecOfIntVecsE(Graph.VecOfIntVecsE),
2168 VecOfStrVecsN(Graph.VecOfStrVecsN), VecOfStrVecsE(Graph.VecOfStrVecsE), VecOfFltVecsN(Graph.VecOfFltVecsN), VecOfFltVecsE(Graph.VecOfFltVecsE),
2169 VecOfIntVecVecsN(), VecOfIntVecVecsE(Graph.VecOfIntVecVecsE),
2170 VecOfFltVecVecsN(), VecOfFltVecVecsE(Graph.VecOfFltVecVecsE),
2171 VecOfIntHashVecsN(), VecOfIntHashVecsE(Graph.VecOfIntHashVecsE),
2172 VecOfFltHashVecsN(), VecOfFltHashVecsE(Graph.VecOfFltHashVecsE)
2174 TNEANet(
bool copyAll,
const TNEANet& Graph) : MxNId(Graph.MxNId), MxEId(Graph.MxEId),
2175 NodeH(Graph.NodeH), EdgeH(Graph.EdgeH), KeyToIndexTypeN(Graph.KeyToIndexTypeN), KeyToIndexTypeE(Graph.KeyToIndexTypeE), KeyToDenseN(Graph.KeyToDenseN), KeyToDenseE(Graph.KeyToDenseE),
2176 IntDefaultsN(Graph.IntDefaultsN), IntDefaultsE(Graph.IntDefaultsE), StrDefaultsN(Graph.StrDefaultsN), StrDefaultsE(Graph.StrDefaultsE),
2177 FltDefaultsN(Graph.FltDefaultsN), FltDefaultsE(Graph.FltDefaultsE), VecOfIntVecsN(Graph.VecOfIntVecsN), VecOfIntVecsE(Graph.VecOfIntVecsE),
2178 VecOfStrVecsN(Graph.VecOfStrVecsN), VecOfStrVecsE(Graph.VecOfStrVecsE), VecOfFltVecsN(Graph.VecOfFltVecsN), VecOfFltVecsE(Graph.VecOfFltVecsE),
2179 VecOfIntVecVecsN(Graph.VecOfIntVecVecsN), VecOfIntVecVecsE(Graph.VecOfIntVecVecsE),
2180 VecOfFltVecVecsN(Graph.VecOfFltVecVecsN), VecOfFltVecVecsE(Graph.VecOfFltVecVecsE),
2181 VecOfIntHashVecsN(Graph.VecOfIntHashVecsN), VecOfIntHashVecsE(Graph.VecOfIntHashVecsE),
2182 VecOfFltHashVecsN(Graph.VecOfFltHashVecsN), VecOfFltHashVecsE(Graph.VecOfFltHashVecsE),
2183 SAttrN(Graph.SAttrN), SAttrE(Graph.SAttrE) { }
2189 KeyToIndexTypeN.
Save(SOut); KeyToIndexTypeE.
Save(SOut);
2190 KeyToDenseN.
Save(SOut); KeyToDenseE.
Save(SOut);
2191 IntDefaultsN.
Save(SOut); IntDefaultsE.
Save(SOut);
2192 StrDefaultsN.
Save(SOut); StrDefaultsE.
Save(SOut);
2193 FltDefaultsN.
Save(SOut); FltDefaultsE.
Save(SOut);
2194 VecOfIntVecsN.
Save(SOut); VecOfIntVecsE.
Save(SOut);
2195 VecOfStrVecsN.
Save(SOut); VecOfStrVecsE.
Save(SOut);
2196 VecOfFltVecsN.
Save(SOut); VecOfFltVecsE.
Save(SOut);
2197 VecOfIntVecVecsN.
Save(SOut); VecOfIntVecVecsE.
Save(SOut);
2198 VecOfFltVecVecsN.
Save(SOut); VecOfFltVecVecsE.
Save(SOut);
2199 VecOfIntHashVecsN.
Save(SOut); VecOfIntHashVecsE.
Save(SOut);
2200 VecOfFltHashVecsN.
Save(SOut); VecOfFltHashVecsE.
Save(SOut);
2201 SAttrN.
Save(SOut); SAttrE.
Save(SOut); }
2205 KeyToIndexTypeN.
Save(SOut); KeyToIndexTypeE.
Save(SOut);
2206 IntDefaultsN.
Save(SOut); IntDefaultsE.
Save(SOut);
2207 StrDefaultsN.
Save(SOut); StrDefaultsE.
Save(SOut);
2208 FltDefaultsN.
Save(SOut); FltDefaultsE.
Save(SOut);
2209 VecOfIntVecsN.
Save(SOut); VecOfIntVecsE.
Save(SOut);
2210 VecOfStrVecsN.
Save(SOut); VecOfStrVecsE.
Save(SOut);
2211 VecOfFltVecsN.
Save(SOut); VecOfFltVecsE.
Save(SOut); }
2215 KeyToIndexTypeN.
Save(SOut); KeyToIndexTypeE.
Save(SOut);
2216 IntDefaultsN.
Save(SOut); IntDefaultsE.
Save(SOut);
2217 StrDefaultsN.
Save(SOut); StrDefaultsE.
Save(SOut);
2218 FltDefaultsN.
Save(SOut); FltDefaultsE.
Save(SOut);
2219 VecOfIntVecsN.
Save(SOut); VecOfIntVecsE.
Save(SOut);
2220 VecOfStrVecsN.
Save(SOut); VecOfStrVecsE.
Save(SOut);
2221 VecOfFltVecsN.
Save(SOut); VecOfFltVecsE.
Save(SOut);
2222 VecOfIntVecVecsN.
Save(SOut); VecOfIntVecVecsE.
Save(SOut);
2223 VecOfFltVecVecsN.
Save(SOut); VecOfFltVecVecsE.
Save(SOut);
2224 SAttrN.
Save(SOut); SAttrE.
Save(SOut); }
2236 Graph->MxNId.Load(SIn); Graph->MxEId.Load(SIn);
2237 Graph->NodeH.Load(SIn); Graph->EdgeH.Load(SIn);
2238 Graph->KeyToIndexTypeN.Load(SIn); Graph->KeyToIndexTypeE.Load(SIn);
2239 Graph->IntDefaultsN.Load(SIn); Graph->IntDefaultsE.Load(SIn);
2240 Graph->StrDefaultsN.Load(SIn); Graph->StrDefaultsE.Load(SIn);
2241 Graph->FltDefaultsN.Load(SIn); Graph->FltDefaultsE.Load(SIn);
2242 Graph->VecOfIntVecsN.Load(SIn); Graph->VecOfIntVecsE.Load(SIn);
2243 Graph->VecOfStrVecsN.Load(SIn); Graph->VecOfStrVecsE.Load(SIn);
2244 Graph->VecOfFltVecsN.Load(SIn); Graph->VecOfFltVecsE.Load(SIn);
2251 Graph->MxNId.Load(SIn); Graph->MxEId.Load(SIn);
2252 Graph->NodeH.Load(SIn); Graph->EdgeH.Load(SIn);
2253 Graph->KeyToIndexTypeN.Load(SIn); Graph->KeyToIndexTypeE.Load(SIn);
2254 Graph->IntDefaultsN.Load(SIn); Graph->IntDefaultsE.Load(SIn);
2255 Graph->StrDefaultsN.Load(SIn); Graph->StrDefaultsE.Load(SIn);
2256 Graph->FltDefaultsN.Load(SIn); Graph->FltDefaultsE.Load(SIn);
2257 Graph->VecOfIntVecsN.Load(SIn); Graph->VecOfIntVecsE.Load(SIn);
2258 Graph->VecOfStrVecsN.Load(SIn); Graph->VecOfStrVecsE.Load(SIn);
2259 Graph->VecOfFltVecsN.Load(SIn); Graph->VecOfFltVecsE.Load(SIn);
2260 Graph->VecOfIntVecVecsN.Load(SIn); Graph->VecOfIntVecVecsE.Load(SIn);
2261 Graph->VecOfFltVecVecsN.Load(SIn); Graph->VecOfFltVecVecsE.Load(SIn);
2262 Graph->SAttrN.Load(SIn); Graph->SAttrE.Load(SIn);
2280 TInt VecLength = VecOfIntVecVecsN.
Len();
2282 if (VecLength != 0) {
2284 for (iter = KeyToIndexTypeN.
BegI(); !iter.IsEnd(); iter=iter.Next()) {
2288 for (
int i=0; i<VecOfIntVecVecsN[index].
Len(); i++) {
2289 if(VecOfIntVecVecsN[index][i].Len() > 0) {
2290 VecOfIntHashVecsN[index].AddDat(
TInt(i), VecOfIntVecVecsN[index][i]);
2297 VecOfIntVecVecsN.
Clr();
2299 VecLength = VecOfIntVecVecsE.
Len();
2300 if (VecLength != 0) {
2302 for (iter = KeyToIndexTypeE.
BegI(); !iter.IsEnd(); iter=iter.Next()) {
2306 for (
int i=0; i<VecOfIntVecVecsE[index].
Len(); i++) {
2307 if(VecOfIntVecVecsE[index][i].Len() > 0) {
2308 VecOfIntHashVecsE[index].AddDat(
TInt(i), VecOfIntVecVecsE[index][i]);
2315 VecOfIntVecVecsE.
Clr();
2317 VecLength = VecOfFltVecVecsN.
Len();
2318 if (VecLength != 0) {
2320 for (iter = KeyToIndexTypeN.
BegI(); !iter.IsEnd(); iter=iter.Next()) {
2324 for (
int i=0; i<VecOfFltVecVecsN[index].
Len(); i++) {
2325 if(VecOfFltVecVecsN[index][i].Len() > 0) {
2326 VecOfFltHashVecsN[index].AddDat(
TInt(i), VecOfFltVecVecsN[index][i]);
2333 VecOfFltVecVecsN.
Clr();
2335 VecLength = VecOfFltVecVecsE.
Len();
2336 if (VecLength != 0) {
2338 for (iter = KeyToIndexTypeE.
BegI(); !iter.IsEnd(); iter=iter.Next()) {
2342 for (
int i=0; i<VecOfFltVecVecsE[index].
Len(); i++) {
2343 if(VecOfFltVecVecsE[index][i].Len() > 0) {
2344 VecOfFltHashVecsE[index].AddDat(
TInt(i), VecOfFltVecVecsE[index][i]);
2351 VecOfFltVecVecsE.
Clr();
2381 virtual void DelNode(
const int& NId);
2406 TInt location = CheckDenseOrSparseN(attr);
2407 TBool IsDense =
true;
2408 if (location != -1) {
2410 if (location == 1) {
2411 HI = VecOfIntVecVecsN[index].
BegI();
2414 HHI = VecOfIntHashVecsN[index].
BegI();
2417 return TAIntVI(HI, HHI, attr,
false,
this, IsDense);
2423 TInt location = CheckDenseOrSparseN(attr);
2424 TBool IsDense =
true;
2425 if (location != -1) {
2427 if (location == 1) {
2428 HI = VecOfIntVecVecsN[index].
EndI();
2431 HHI = VecOfIntHashVecsN[index].
EndI();
2434 return TAIntVI(HI, HHI, attr,
false,
this, IsDense);
2442 TInt location = CheckDenseOrSparseN(attr);
2443 TBool IsDense =
true;
2444 if (location != -1) {
2446 if (location == 1) {
2447 HI = VecOfIntVecVecsN[index].
GetI(NodeH.
GetKeyId(NId));
2450 HHI = VecOfIntHashVecsN[index].
GetI(NodeH.
GetKeyId(NId));
2453 return TAIntVI(HI, HHI, attr,
false,
this, IsDense);
2460 TInt location = CheckDenseOrSparseN(attr);
2461 TBool IsDense =
true;
2462 if (location != -1) {
2464 if (location == 1) {
2465 HI = VecOfFltVecVecsN[index].
BegI();
2468 HHI = VecOfFltHashVecsN[index].
BegI();
2471 return TAFltVI(HI, HHI, attr,
false,
this, IsDense);
2477 TInt location = CheckDenseOrSparseN(attr);
2478 TBool IsDense =
true;
2479 if (location != -1) {
2481 if (location == 1) {
2482 HI = VecOfFltVecVecsN[index].
EndI();
2485 HHI = VecOfFltHashVecsN[index].
EndI();
2488 return TAFltVI(HI, HHI, attr,
false,
this, IsDense);
2496 TInt location = CheckDenseOrSparseN(attr);
2497 TBool IsDense =
true;
2498 if (location != -1) {
2500 if (location == 1) {
2501 HI = VecOfFltVecVecsN[index].
GetI(NodeH.
GetKeyId(NId));
2504 HHI = VecOfFltHashVecsN[index].
GetI(NodeH.
GetKeyId(NId));
2507 return TAFltVI(HI, HHI, attr,
false,
this, IsDense);
2532 AttrNameNI(NId, KeyToIndexTypeN.
BegI(), Names);}
2536 AttrValueNI(NId, KeyToIndexTypeN.
BegI(), Values);}
2541 IntAttrNameNI(NId, KeyToIndexTypeN.
BegI(), Names);}
2545 IntAttrValueNI(NId, KeyToIndexTypeN.
BegI(), Values);}
2551 IntVAttrNameNI(NId, KeyToIndexTypeN.
BegI(), Names);}
2555 IntVAttrValueNI(NId, KeyToIndexTypeN.
BegI(), Values);}
2560 FltVAttrNameNI(NId, KeyToIndexTypeN.
BegI(), Names);}
2564 FltVAttrValueNI(NId, KeyToIndexTypeN.
BegI(), Values);}
2570 StrAttrNameNI(NId, KeyToIndexTypeN.
BegI(), Names);}
2574 StrAttrValueNI(NId, KeyToIndexTypeN.
BegI(), Values);}
2578 FltAttrNameNI(NId, KeyToIndexTypeN.
BegI(), Names);}
2582 FltAttrValueNI(NId, KeyToIndexTypeN.
BegI(), Values);}
2587 AttrNameEI(EId, KeyToIndexTypeE.
BegI(), Names);}
2591 AttrValueEI(EId, KeyToIndexTypeE.
BegI(), Values);}
2595 IntAttrNameEI(EId, KeyToIndexTypeE.
BegI(), Names);}
2599 IntAttrValueEI(EId, KeyToIndexTypeE.
BegI(), Values);}
2605 IntVAttrNameEI(EId, KeyToIndexTypeE.
BegI(), Names);}
2609 IntVAttrValueEI(EId, KeyToIndexTypeE.
BegI(), Values);}
2614 FltVAttrNameEI(EId, KeyToIndexTypeE.
BegI(), Names);}
2618 FltVAttrValueEI(EId, KeyToIndexTypeE.
BegI(), Values);}
2624 StrAttrNameEI(EId, KeyToIndexTypeE.
BegI(), Names);}
2628 StrAttrValueEI(EId, KeyToIndexTypeE.
BegI(), Values);}
2632 FltAttrNameEI(EId, KeyToIndexTypeE.
BegI(), Names);}
2636 FltAttrValueEI(EId, KeyToIndexTypeE.
BegI(), Values);}
2656 TInt location = CheckDenseOrSparseE(attr);
2657 TBool IsDense =
true;
2658 if (location != -1) {
2660 if (location == 1) {
2661 HI = VecOfIntVecVecsE[index].
BegI();
2664 HHI = VecOfIntHashVecsE[index].
BegI();
2667 return TAIntVI(HI, HHI, attr,
true,
this, IsDense);
2673 TInt location = CheckDenseOrSparseE(attr);
2674 TBool IsDense =
true;
2675 if (location != -1) {
2677 if (location == 1) {
2678 HI = VecOfIntVecVecsE[index].
EndI();
2681 HHI = VecOfIntHashVecsE[index].
EndI();
2684 return TAIntVI(HI, HHI, attr,
true,
this, IsDense);
2690 TInt location = CheckDenseOrSparseE(attr);
2691 TBool IsDense =
true;
2692 if (location != -1) {
2694 if (location == 1) {
2695 HI = VecOfIntVecVecsE[index].
GetI(EdgeH.
GetKeyId(EId));
2698 HHI = VecOfIntHashVecsE[index].
GetI(EdgeH.
GetKeyId(EId));
2701 return TAIntVI(HI, HHI, attr,
true,
this, IsDense);
2708 TInt location = CheckDenseOrSparseE(attr);
2709 TBool IsDense =
true;
2710 if (location != -1) {
2712 if (location == 1) {
2713 HI = VecOfFltVecVecsE[index].
BegI();
2716 HHI = VecOfFltHashVecsE[index].
BegI();
2719 return TAFltVI(HI, HHI, attr,
true,
this, IsDense);
2725 TInt location = CheckDenseOrSparseE(attr);
2726 TBool IsDense =
true;
2727 if (location != -1) {
2729 if (location == 1) {
2730 HI = VecOfFltVecVecsE[index].
EndI();
2733 HHI = VecOfFltHashVecsE[index].
EndI();
2736 return TAFltVI(HI, HHI, attr,
true,
this, IsDense);
2742 TInt location = CheckDenseOrSparseE(attr);
2743 TBool IsDense =
true;
2744 if (location != -1) {
2746 if (location == 1) {
2747 HI = VecOfFltVecVecsE[index].
GetI(EdgeH.
GetKeyId(EId));
2750 HHI = VecOfFltHashVecsE[index].
GetI(EdgeH.
GetKeyId(EId));
2753 return TAFltVI(HI, HHI, attr,
true,
this, IsDense);
2792 int AddEdge(
const int& SrcNId,
const int& DstNId,
int EId = -1);
2802 void DelEdge(
const int& SrcNId,
const int& DstNId,
const bool& IsDir =
true);
2806 bool IsEdge(
const int& SrcNId,
const int& DstNId,
const bool& IsDir =
true)
const {
int EId;
return IsEdge(SrcNId, DstNId, EId, IsDir); }
2808 bool IsEdge(
const int& SrcNId,
const int& DstNId,
int& EId,
const bool& IsDir =
true)
const;
2810 int GetEId(
const int& SrcNId,
const int& DstNId)
const {
int EId;
return IsEdge(SrcNId, DstNId, EId)?EId:-1; }
2837 KeyToIndexTypeN.
Clr(); KeyToIndexTypeE.
Clr(); IntDefaultsN.
Clr(); IntDefaultsE.
Clr();
2838 StrDefaultsN.
Clr(); StrDefaultsE.
Clr(); FltDefaultsN.
Clr(); FltDefaultsE.
Clr();
2839 VecOfIntVecsN.
Clr(); VecOfIntVecsE.
Clr(); VecOfStrVecsN.
Clr(); VecOfStrVecsE.
Clr();
2840 VecOfFltVecsN.
Clr(); VecOfFltVecsE.
Clr(); VecOfIntVecVecsN.
Clr(); VecOfIntVecVecsE.
Clr();
2841 VecOfFltVecVecsN.
Clr(); VecOfFltVecVecsE.
Clr();
2842 SAttrN.
Clr(); SAttrE.
Clr();}
2844 void Reserve(
const int& Nodes,
const int& Edges) {
2845 if (Nodes>0) { NodeH.
Gen(Nodes/2); }
if (Edges>0) { EdgeH.
Gen(Edges/2); } }
2852 void Defrag(
const bool& OnlyNodeLinks=
false);
2857 bool IsOk(
const bool& ThrowExcept=
true)
const;
2859 void Dump(FILE *OutF=stdout)
const;
2863 int AddIntAttrDatN(
const int& NId,
const TInt& value,
const TStr& attr);
2866 int AddStrAttrDatN(
const int& NId,
const TStr& value,
const TStr& attr);
2869 int AddFltAttrDatN(
const int& NId,
const TFlt& value,
const TStr& attr);
2872 int AddIntVAttrDatN(
const int& NId,
const TIntV& value,
const TStr& attr,
TBool UseDense=
true);
2875 int AddFltVAttrDatN(
const int& NId,
const TFltV& value,
const TStr& attr,
TBool UseDense=
true);
2881 int AppendIntVAttrDatN(
const int& NId,
const TInt& value,
const TStr& attr,
TBool UseDense=
true);
2884 int DelFromIntVAttrDatN(
const int& NId,
const TInt& value,
const TStr& attr);
2888 int AppendFltVAttrDatN(
const int& NId,
const TFlt& value,
const TStr& attr,
TBool UseDense=
true);
2891 int DelFromFltVAttrDatN(
const int& NId,
const TFlt& value,
const TStr& attr);
2899 int AddIntAttrDatE(
const int& EId,
const TInt& value,
const TStr& attr);
2904 int AddStrAttrDatE(
const int& EId,
const TStr& value,
const TStr& attr);
2909 int AddFltAttrDatE(
const int& EId,
const TFlt& value,
const TStr& attr);
2916 int AddIntVAttrDatE(
const int& EId,
const TIntV& value,
const TStr& attr,
TBool UseDense=
true);
2919 int AppendIntVAttrDatE(
const int& EId,
const TInt& value,
const TStr& attr,
TBool UseDense=
true);
2925 int AddFltVAttrDatE(
const int& EId,
const TFltV& value,
const TStr& attr,
TBool UseDense=
true);
2928 int AppendFltVAttrDatE(
const int& EId,
const TFlt& value,
const TStr& attr,
TBool UseDense=
true);
2932 TInt GetIntAttrDatN(
const int& NId,
const TStr& attr);
2936 TStr GetStrAttrDatN(
const int& NId,
const TStr& attr);
2939 TFlt GetFltAttrDatN(
const int& NId,
const TStr& attr);
2942 TIntV GetIntVAttrDatN(
const int& NId,
const TStr& attr)
const;
2946 TFltV GetFltVAttrDatN(
const int& NId,
const TStr& attr)
const;
2949 int GetIntAttrIndN(
const TStr& attr);
2951 int GetAttrIndN(
const TStr& attr);
2956 TInt GetIntAttrIndDatN(
const int& NId,
const int& index);
2961 TStr GetStrAttrIndDatN(
const int& NId,
const int& index);
2966 TFlt GetFltAttrIndDatN(
const int& NId,
const int& index);
2970 TInt GetIntAttrDatE(
const int& EId,
const TStr& attr);
2973 TStr GetStrAttrDatE(
const int& EId,
const TStr& attr);
2976 TFlt GetFltAttrDatE(
const int& EId,
const TStr& attr);
2979 TIntV GetIntVAttrDatE(
const int& EId,
const TStr& attr);
2983 TFltV GetFltVAttrDatE(
const int& EId,
const TStr& attr);
2986 int GetIntAttrIndE(
const TStr& attr);
2988 int GetAttrIndE(
const TStr& attr);
2993 TInt GetIntAttrIndDatE(
const int& EId,
const int& index);
2998 TFlt GetFltAttrIndDatE(
const int& EId,
const int& index);
3003 TStr GetStrAttrIndDatE(
const int& EId,
const int& index);
3007 int DelAttrDatN(
const int& NId,
const TStr& attr);
3010 int DelAttrDatE(
const int& EId,
const TStr& attr);
3019 int AddIntVAttrN(
const TStr& attr,
TBool UseDense=
true);
3022 int AddFltVAttrN(
const TStr& attr,
TBool UseDense=
true);
3031 int AddIntVAttrE(
const TStr& attr,
TBool UseDense=
true);
3034 int AddFltVAttrE(
const TStr& attr,
TBool UseDense=
true);
3037 int DelAttrN(
const TStr& attr);
3039 int DelAttrE(
const TStr& attr);
3042 bool IsAttrDeletedN(
const int& NId,
const TStr& attr)
const;
3044 bool IsIntAttrDeletedN(
const int& NId,
const TStr& attr)
const;
3046 bool IsIntVAttrDeletedN(
const int& NId,
const TStr& attr)
const;
3048 bool IsFltVAttrDeletedN(
const int& NId,
const TStr& attr)
const;
3050 bool IsStrAttrDeletedN(
const int& NId,
const TStr& attr)
const;
3052 bool IsFltAttrDeletedN(
const int& NId,
const TStr& attr)
const;
3057 bool NodeAttrIsIntDeleted(
const int& NId,
const TStrIntPrH::TIter& NodeHI)
const;
3059 bool NodeAttrIsIntVDeleted(
const int& NId,
const TStrIntPrH::TIter& NodeHI)
const;
3061 bool NodeAttrIsFltVDeleted(
const int& NId,
const TStrIntPrH::TIter& NodeHI)
const;
3063 bool NodeAttrIsStrDeleted(
const int& NId,
const TStrIntPrH::TIter& NodeHI)
const;
3065 bool NodeAttrIsFltDeleted(
const int& NId,
const TStrIntPrH::TIter& NodeHI)
const;
3068 bool IsAttrDeletedE(
const int& EId,
const TStr& attr)
const;
3070 bool IsIntAttrDeletedE(
const int& EId,
const TStr& attr)
const;
3072 bool IsIntVAttrDeletedE(
const int& EId,
const TStr& attr)
const;
3074 bool IsFltVAttrDeletedE(
const int& EId,
const TStr& attr)
const;
3076 bool IsStrAttrDeletedE(
const int& EId,
const TStr& attr)
const;
3078 bool IsFltAttrDeletedE(
const int& EId,
const TStr& attr)
const;
3083 bool EdgeAttrIsIntDeleted(
const int& EId,
const TStrIntPrH::TIter& EdgeHI)
const;
3085 bool EdgeAttrIsIntVDeleted(
const int& EId,
const TStrIntPrH::TIter& EdgeHI)
const;
3087 bool EdgeAttrIsFltVDeleted(
const int& EId,
const TStrIntPrH::TIter& EdgeHI)
const;
3089 bool EdgeAttrIsStrDeleted(
const int& EId,
const TStrIntPrH::TIter& EdgeHI)
const;
3091 bool EdgeAttrIsFltDeleted(
const int& EId,
const TStrIntPrH::TIter& EdgeHI)
const;
3099 TFlt GetWeightOutEdges(
const TNodeI& NI,
const TStr& attr);
3101 bool IsFltAttrE(
const TStr& attr);
3103 bool IsIntAttrE(
const TStr& attr);
3105 bool IsStrAttrE(
const TStr& attr);
3109 int GetFltKeyIdE(
const int& EId);
3112 void GetWeightOutEdgesV(
TFltV& OutWeights,
const TFltV& AttrVal) ;
3114 void GetAttrNNames(
TStrV& IntAttrNames,
TStrV& FltAttrNames,
TStrV& StrAttrNames)
const;
3116 void GetAttrENames(
TStrV& IntAttrNames,
TStrV& FltAttrNames,
TStrV& StrAttrNames)
const;
3120 int AddSAttrDatN(
const TInt& NId,
const TStr& AttrName,
const TInt& Val);
3122 int AddSAttrDatN(
const TInt& NId,
const TInt& AttrId,
const TInt& Val);
3126 return AddSAttrDatN(NodeI.
GetId(), AttrName, Val);
3130 return AddSAttrDatN(NodeI.
GetId(), AttrId, Val);
3134 int AddSAttrDatN(
const TInt& NId,
const TStr& AttrName,
const TFlt& Val);
3136 int AddSAttrDatN(
const TInt& NId,
const TInt& AttrId,
const TFlt& Val);
3140 return AddSAttrDatN(NodeI.
GetId(), AttrName, Val);
3144 return AddSAttrDatN(NodeI.
GetId(), AttrId, Val);
3148 int AddSAttrDatN(
const TInt& NId,
const TStr& AttrName,
const TStr& Val);
3150 int AddSAttrDatN(
const TInt& NId,
const TInt& AttrId,
const TStr& Val);
3154 return AddSAttrDatN(NodeI.
GetId(), AttrName, Val);
3158 return AddSAttrDatN(NodeI.
GetId(), AttrId, Val);
3162 int GetSAttrDatN(
const TInt& NId,
const TStr& AttrName,
TInt& ValX)
const;
3164 int GetSAttrDatN(
const TInt& NId,
const TInt& AttrId,
TInt& ValX)
const;
3168 return GetSAttrDatN(NodeI.
GetId(), AttrName, ValX);
3172 return GetSAttrDatN(NodeI.
GetId(), AttrId, ValX);
3176 int GetSAttrDatN(
const TInt& NId,
const TStr& AttrName,
TFlt& ValX)
const;
3178 int GetSAttrDatN(
const TInt& NId,
const TInt& AttrId,
TFlt& ValX)
const;
3182 return GetSAttrDatN(NodeI.
GetId(), AttrName, ValX);
3186 return GetSAttrDatN(NodeI.
GetId(), AttrId, ValX);
3190 int GetSAttrDatN(
const TInt& NId,
const TStr& AttrName,
TStr& ValX)
const;
3192 int GetSAttrDatN(
const TInt& NId,
const TInt& AttrId,
TStr& ValX)
const;
3196 return GetSAttrDatN(NodeI.
GetId(), AttrName, ValX);
3200 return GetSAttrDatN(NodeI.
GetId(), AttrId, ValX);
3204 int DelSAttrDatN(
const TInt& NId,
const TStr& AttrName);
3206 int DelSAttrDatN(
const TInt& NId,
const TInt& AttrId);
3210 return DelSAttrDatN(NodeI.
GetId(), AttrName);
3214 return DelSAttrDatN(NodeI.
GetId(), AttrId);
3221 return GetSAttrVN(NodeI.
GetId(), AttrType, AttrV);
3225 int GetIdVSAttrN(
const TStr& AttrName,
TIntV& IdV)
const;
3227 int GetIdVSAttrN(
const TInt& AttrId,
TIntV& IdV)
const;
3238 int AddSAttrDatE(
const TInt& EId,
const TStr& AttrName,
const TInt& Val);
3240 int AddSAttrDatE(
const TInt& EId,
const TInt& AttrId,
const TInt& Val);
3244 return AddSAttrDatE(EdgeI.
GetId(), AttrName, Val);
3248 return AddSAttrDatE(EdgeI.
GetId(), AttrId, Val);
3252 int AddSAttrDatE(
const TInt& EId,
const TStr& AttrName,
const TFlt& Val);
3254 int AddSAttrDatE(
const TInt& EId,
const TInt& AttrId,
const TFlt& Val);
3258 return AddSAttrDatE(EdgeI.
GetId(), AttrName, Val);
3262 return AddSAttrDatE(EdgeI.
GetId(), AttrId, Val);
3266 int AddSAttrDatE(
const TInt& EId,
const TStr& AttrName,
const TStr& Val);
3268 int AddSAttrDatE(
const TInt& EId,
const TInt& AttrId,
const TStr& Val);
3272 return AddSAttrDatE(EdgeI.
GetId(), AttrName, Val);
3276 return AddSAttrDatE(EdgeI.
GetId(), AttrId, Val);
3280 int GetSAttrDatE(
const TInt& EId,
const TStr& AttrName,
TInt& ValX)
const;
3282 int GetSAttrDatE(
const TInt& EId,
const TInt& AttrId,
TInt& ValX)
const;
3286 return GetSAttrDatE(EdgeI.
GetId(), AttrName, ValX);
3290 return GetSAttrDatE(EdgeI.
GetId(), AttrId, ValX);
3294 int GetSAttrDatE(
const TInt& EId,
const TStr& AttrName,
TFlt& ValX)
const;
3296 int GetSAttrDatE(
const TInt& EId,
const TInt& AttrId,
TFlt& ValX)
const;
3300 return GetSAttrDatE(EdgeI.
GetId(), AttrName, ValX);
3304 return GetSAttrDatE(EdgeI.
GetId(), AttrId, ValX);
3308 int GetSAttrDatE(
const TInt& EId,
const TStr& AttrName,
TStr& ValX)
const;
3310 int GetSAttrDatE(
const TInt& EId,
const TInt& AttrId,
TStr& ValX)
const;
3314 return GetSAttrDatE(EdgeI.
GetId(), AttrName, ValX);
3318 return GetSAttrDatE(EdgeI.
GetId(), AttrId, ValX);
3322 int DelSAttrDatE(
const TInt& EId,
const TStr& AttrName);
3324 int DelSAttrDatE(
const TInt& EId,
const TInt& AttrId);
3328 return DelSAttrDatE(EdgeI.
GetId(), AttrName);
3332 return DelSAttrDatE(EdgeI.
GetId(), AttrId);
3338 return GetSAttrVE(EdgeI.
GetId(), AttrType, AttrV);
3342 int GetIdVSAttrE(
const TStr& AttrName,
TIntV& IdV)
const;
3344 int GetIdVSAttrE(
const TInt& AttrId,
TIntV& IdV)
const;
3359 static PNEANet GetSmallGraph();
3408 TNode(
const int& NId) : Id(NId), NIdV() { }
3416 int GetInNId(
const int& NodeN)
const {
return GetNbrNId(NodeN); }
3417 int GetOutNId(
const int& NodeN)
const {
return GetNbrNId(NodeN); }
3418 int GetNbrNId(
const int& NodeN)
const {
return NIdV[NodeN]; }
3420 bool IsInNId(
const int& NId)
const {
return IsNbrNId(NId); }
3421 bool IsOutNId(
const int& NId)
const {
return IsNbrNId(NId); }
3430 friend class TUndirNetMtx;
3439 TNodeI(
const THashIter& NodeHIter) : NodeHI(NodeHIter) { }
3444 TNodeI& operator++ (
int) { NodeHI++;
return *
this; }
3446 TNodeI& operator-- (
int) { NodeHI--;
return *
this; }
3449 bool operator < (
const TNodeI& NodeI)
const {
return NodeHI < NodeI.
NodeHI; }
3450 bool operator == (
const TNodeI& NodeI)
const {
return NodeHI == NodeI.
NodeHI; }
3453 int GetId()
const {
return NodeHI.GetDat().GetId(); }
3455 int GetDeg()
const {
return NodeHI.GetDat().GetDeg(); }
3457 int GetInDeg()
const {
return NodeHI.GetDat().GetInDeg(); }
3459 int GetOutDeg()
const {
return NodeHI.GetDat().GetOutDeg(); }
3466 int GetInNId(
const int& NodeN)
const {
return NodeHI.GetDat().GetInNId(NodeN); }
3471 int GetOutNId(
const int& NodeN)
const {
return NodeHI.GetDat().GetOutNId(NodeN); }
3476 int GetNbrNId(
const int& NodeN)
const {
return NodeHI.GetDat().GetNbrNId(NodeN); }
3478 bool IsInNId(
const int& NId)
const {
return NodeHI.GetDat().IsInNId(NId); }
3480 bool IsOutNId(
const int& NId)
const {
return NodeHI.GetDat().IsOutNId(NId); }
3482 bool IsNbrNId(
const int& NId)
const {
return NodeHI.GetDat().IsNbrNId(NId); }
3491 TEdgeI() : CurNode(), EndNode(), CurEdge(0) { }
3492 TEdgeI(
const TNodeI& NodeI,
const TNodeI& EndNodeI,
const int& EdgeN=0) : CurNode(NodeI), EndNode(EndNodeI), CurEdge(EdgeN) { }
3493 TEdgeI(
const TEdgeI& EdgeI) : CurNode(EdgeI.CurNode), EndNode(EdgeI.EndNode), CurEdge(EdgeI.CurEdge) { }
3496 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; }
3526 MxNId =
TInt(ShMIn);
3527 NEdges =
TInt(ShMIn);
3534 TUndirNet() : CRef(), MxNId(0), NEdges(0), NodeH(), SAttrN(), SAttrE() { }
3536 explicit TUndirNet(
const int& Nodes,
const int& Edges) : MxNId(0), NEdges(0), SAttrN(), SAttrE() {
Reserve(Nodes, Edges); }
3538 SAttrN(), SAttrE() { }
3540 TUndirNet(
TSIn& SIn) : MxNId(SIn), NEdges(SIn), NodeH(SIn), SAttrN(SIn), SAttrE(SIn) { }
3543 SAttrN.
Save(SOut); SAttrE.
Save(SOut); }
3551 static PUndirNet
New(
const int& Nodes,
const int& Edges) {
return new TUndirNet(Nodes, Edges); }
3556 Graph->MxNId.Load(SIn); Graph->NEdges.Load(SIn); Graph->NodeH.Load(SIn);
return Graph;
3573 if (
this!=&Graph) { MxNId=Graph.
MxNId; NEdges=Graph.
NEdges; NodeH=Graph.
NodeH; }
return *
this; }
3639 int AddEdge(
const int& SrcNId,
const int& DstNId);
3648 int AddEdgeUnchecked(
const int& SrcNId,
const int& DstNId);
3656 void DelEdge(
const int& SrcNId,
const int& DstNId);
3658 bool IsEdge(
const int& SrcNId,
const int& DstNId)
const;
3664 TEdgeI
GetEI(
const int& EId)
const;
3669 TEdgeI
GetEI(
const int& SrcNId,
const int& DstNId)
const;
3683 void Reserve(
const int& Nodes,
const int& Edges) {
if (Nodes>0) NodeH.
Gen(Nodes/2); }
3694 void Defrag(
const bool& OnlyNodeLinks=
false);
3699 bool IsOk(
const bool& ThrowExcept=
true)
const;
3701 void Dump(FILE *OutF=stdout)
const;
3709 static PUndirNet GetSmallGraph();
3712 int AddSAttrDatN(
const TInt& NId,
const TStr& AttrName,
const TInt& Val);
3714 int AddSAttrDatN(
const TInt& NId,
const TInt& AttrId,
const TInt& Val);
3718 return AddSAttrDatN(NodeI.
GetId(), AttrName, Val);
3722 return AddSAttrDatN(NodeI.
GetId(), AttrId, Val);
3726 int AddSAttrDatN(
const TInt& NId,
const TStr& AttrName,
const TFlt& Val);
3728 int AddSAttrDatN(
const TInt& NId,
const TInt& AttrId,
const TFlt& Val);
3732 return AddSAttrDatN(NodeI.
GetId(), AttrName, Val);
3736 return AddSAttrDatN(NodeI.
GetId(), AttrId, Val);
3740 int AddSAttrDatN(
const TInt& NId,
const TStr& AttrName,
const TStr& Val);
3742 int AddSAttrDatN(
const TInt& NId,
const TInt& AttrId,
const TStr& Val);
3746 return AddSAttrDatN(NodeI.
GetId(), AttrName, Val);
3750 return AddSAttrDatN(NodeI.
GetId(), AttrId, Val);
3754 int GetSAttrDatN(
const TInt& NId,
const TStr& AttrName,
TInt& ValX)
const;
3756 int GetSAttrDatN(
const TInt& NId,
const TInt& AttrId,
TInt& ValX)
const;
3760 return GetSAttrDatN(NodeI.
GetId(), AttrName, ValX);
3764 return GetSAttrDatN(NodeI.
GetId(), AttrId, ValX);
3768 int GetSAttrDatN(
const TInt& NId,
const TStr& AttrName,
TFlt& ValX)
const;
3770 int GetSAttrDatN(
const TInt& NId,
const TInt& AttrId,
TFlt& ValX)
const;
3774 return GetSAttrDatN(NodeI.
GetId(), AttrName, ValX);
3778 return GetSAttrDatN(NodeI.
GetId(), AttrId, ValX);
3782 int GetSAttrDatN(
const TInt& NId,
const TStr& AttrName,
TStr& ValX)
const;
3784 int GetSAttrDatN(
const TInt& NId,
const TInt& AttrId,
TStr& ValX)
const;
3788 return GetSAttrDatN(NodeI.
GetId(), AttrName, ValX);
3792 return GetSAttrDatN(NodeI.
GetId(), AttrId, ValX);
3796 int DelSAttrDatN(
const TInt& NId,
const TStr& AttrName);
3798 int DelSAttrDatN(
const TInt& NId,
const TInt& AttrId);
3802 return DelSAttrDatN(NodeI.
GetId(), AttrName);
3806 return DelSAttrDatN(NodeI.
GetId(), AttrId);
3813 return GetSAttrVN(NodeI.
GetId(), AttrType, AttrV);
3817 int GetIdVSAttrN(
const TStr& AttrName,
TIntV& IdV)
const;
3819 int GetIdVSAttrN(
const TInt& AttrId,
TIntV& IdV)
const;
3830 int AddSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName,
const TInt& Val);
3832 int AddSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId,
const TInt& Val);
3844 int AddSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName,
const TFlt& Val);
3846 int AddSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId,
const TFlt& Val);
3858 int AddSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName,
const TStr& Val);
3860 int AddSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId,
const TStr& Val);
3872 int GetSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName,
TInt& ValX)
const;
3874 int GetSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId,
TInt& ValX)
const;
3886 int GetSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName,
TFlt& ValX)
const;
3888 int GetSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId,
TFlt& ValX)
const;
3900 int GetSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName,
TStr& ValX)
const;
3902 int GetSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId,
TStr& ValX)
const;
3914 int DelSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TStr& AttrName);
3916 int DelSAttrDatE(
const int& SrcNId,
const int& DstNId,
const TInt& AttrId);
3927 int GetSAttrVE(
const int& SrcNId,
const int& DstNId,
const TAttrType AttrType,
TAttrPrV& AttrV)
const;
3934 int GetIdVSAttrE(
const TStr& AttrName,
TIntPrV& IdV)
const;
3936 int GetIdVSAttrE(
const TInt& AttrId,
TIntPrV& IdV)
const;
3946 friend class TUndirNetMtx;
3976 TNode() : Id(-1), InNIdV(), OutNIdV() { }
3977 TNode(
const int& NId) : Id(NId), InNIdV(), OutNIdV() { }
3978 TNode(
const TNode& Node) : Id(Node.Id), InNIdV(Node.InNIdV), OutNIdV(Node.OutNIdV) { }
3982 int GetDeg()
const {
return GetInDeg() + GetOutDeg(); }
3985 int GetInNId(
const int& NodeN)
const {
return InNIdV[NodeN]; }
3986 int GetOutNId(
const int& NodeN)
const {
return OutNIdV[NodeN]; }
3987 int GetNbrNId(
const int& NodeN)
const {
return NodeN<GetOutDeg()?GetOutNId(NodeN):GetInNId(NodeN-GetOutDeg()); }
3990 bool IsNbrNId(
const int& NId)
const {
return IsOutNId(NId) || IsInNId(NId); }
4000 friend class TDirNetMtx;
4009 TNodeI(
const THashIter& NodeHIter) : NodeHI(NodeHIter) { }
4013 TNodeI& operator++ (
int) { NodeHI++;
return *
this; }
4015 TNodeI& operator-- (
int) { NodeHI--;
return *
this; }
4017 bool operator < (
const TNodeI& NodeI)
const {
return NodeHI < NodeI.
NodeHI; }
4018 bool operator == (
const TNodeI& NodeI)
const {
return NodeHI == NodeI.
NodeHI; }
4020 int GetId()
const {
return NodeHI.GetDat().GetId(); }
4022 int GetDeg()
const {
return NodeHI.GetDat().GetDeg(); }
4024 int GetInDeg()
const {
return NodeHI.GetDat().GetInDeg(); }
4026 int GetOutDeg()
const {
return NodeHI.GetDat().GetOutDeg(); }
4032 int GetInNId(
const int& NodeN)
const {
return NodeHI.GetDat().GetInNId(NodeN); }
4036 int GetOutNId(
const int& NodeN)
const {
return NodeHI.GetDat().GetOutNId(NodeN); }
4040 int GetNbrNId(
const int& NodeN)
const {
return NodeHI.GetDat().GetNbrNId(NodeN); }
4042 bool IsInNId(
const int& NId)
const {
return NodeHI.GetDat().IsInNId(NId); }
4044 bool IsOutNId(
const int& NId)
const {
return NodeHI.GetDat().IsOutNId(NId); }
4046 bool IsNbrNId(
const int& NId)
const {
return IsOutNId(NId) || IsInNId(NId); }
4055 TEdgeI() : CurNode(), EndNode(), CurEdge(0) { }
4056 TEdgeI(
const TNodeI& NodeI,
const TNodeI& EndNodeI,
const int& EdgeN=0) : CurNode(NodeI), EndNode(EndNodeI), CurEdge(EdgeN) { }
4057 TEdgeI(
const TEdgeI& EdgeI) : CurNode(EdgeI.CurNode), EndNode(EdgeI.EndNode), CurEdge(EdgeI.CurEdge) { }
4060 TEdgeI& operator++ (
int) { CurEdge++;
if (CurEdge >= CurNode.
GetOutDeg()) { CurEdge=0; CurNode++;
4061 while (CurNode < EndNode && CurNode.
GetOutDeg()==0) { CurNode++; } }
return *
this; }
4089 MxNId =
TInt(ShMIn);
4096 TDirNet() : CRef(), MxNId(0), NodeH(), SAttrN(), SAttrE() { }
4098 explicit TDirNet(
const int& Nodes,
const int& Edges) : MxNId(0), SAttrN(), SAttrE() {
Reserve(Nodes, Edges); }
4099 TDirNet(
const TDirNet& Graph) : MxNId(Graph.MxNId), NodeH(Graph.NodeH), SAttrN(), SAttrE() { }
4101 TDirNet(
TSIn& SIn) : MxNId(SIn), NodeH(SIn), SAttrN(SIn), SAttrE(SIn) { }