6 LoadTNodeFunctor NodeFn;
23 LoadVecFunctor vec_fn;
32 LoadVecOfVecFunctor vec_of_vec_fn;
38 LoadHashOfVecFunctor hash_of_vec_fn;
64 const TNode& Node = NodeHI.GetDat();
74 while (!NodeHI.
IsEnd()) {
84 while (!NodeHI.
IsEnd()) {
94 while (!NodeHI.
IsEnd()) {
104 while (!NodeHI.
IsEnd()) {
115 while (!NodeHI.
IsEnd()) {
125 while (!NodeHI.
IsEnd()) {
132 if (val.
Len() != 0) Values.
Add(val);
146 while (!NodeHI.
IsEnd()) {
156 while (!NodeHI.
IsEnd()) {
163 if (val.
Len() != 0) Values.
Add(val);
177 while (!NodeHI.
IsEnd()) {
187 while (!NodeHI.
IsEnd()) {
198 while (!NodeHI.
IsEnd()) {
208 while (!NodeHI.
IsEnd()) {
223 return IntDel || StrDel || FltDel || IntVDel || FltVDel;
251 return IntDel || StrDel || FltDel || IntVDel;
310 while (!EdgeHI.
IsEnd()) {
320 while (!EdgeHI.
IsEnd()) {
330 while (!EdgeHI.
IsEnd()) {
340 while (!EdgeHI.
IsEnd()) {
351 while (!EdgeHI.
IsEnd()) {
361 while (!EdgeHI.
IsEnd()) {
368 if (val.
Len() != 0) Values.
Add(val);
382 while (!EdgeHI.
IsEnd()) {
392 while (!EdgeHI.
IsEnd()) {
399 if (val.
Len() != 0) Values.
Add(val);
413 while (!EdgeHI.
IsEnd()) {
423 while (!EdgeHI.
IsEnd()) {
434 while (!EdgeHI.
IsEnd()) {
444 while (!EdgeHI.
IsEnd()) {
459 return IntDel || StrDel || FltDel || IntVDel || FltVDel;
488 return IntDel || StrDel || FltDel || IntVDel || FltVDel;
551 if (
IsNode(NId)) {
return -1;}
565 if (IntVec.
Len() > KeyId) {
573 for (i = 0; i < DefIntVec.
Len(); i++) {
574 TStr attr = DefIntVec[i];
581 if (StrVec.
Len() > KeyId) {
589 for (i = 0; i < DefStrVec.
Len(); i++) {
590 TStr attr = DefStrVec[i];
597 if (FltVec.
Len() > KeyId) {
605 for (i = 0; i < DefFltVec.
Len(); i++) {
606 TStr attr = DefFltVec[i];
613 if (IntVecV.
Len() > KeyId) {
614 IntVecV[KeyId] =
TIntV();
622 if (FltVecV.
Len() > KeyId) {
623 FltVecV[KeyId] =
TFltV();
636 for (
int out = 0; out < Node.
GetOutDeg(); out++) {
677 for (
int in = 0; in < Node.
GetInDeg(); in++) {
768 if (IntVec.
Len() > KeyId) {
776 for (i = 0; i < DefIntVec.
Len(); i++) {
777 TStr attr = DefIntVec[i];
795 if (StrVec.
Len() > KeyId) {
803 for (i = 0; i < DefStrVec.
Len(); i++) {
804 TStr attr = DefStrVec[i];
812 if (FltVec.
Len() > KeyId) {
820 for (i = 0; i < DefFltVec.
Len(); i++) {
821 TStr attr = DefFltVec[i];
858 bool Edge =
IsEdge(SrcNId, DstNId, EId, IsDir);
862 Edge =
IsEdge(SrcNId, DstNId, EId, IsDir);
866 bool TNEANet::IsEdge(
const int& SrcNId,
const int& DstNId,
int& EId,
const bool& IsDir)
const {
924 for (
int e = 0; e < Node.
GetOutDeg(); e++) {
929 if (e > 0 && prevEId == Node.
GetOutEId(e)) {
937 for (
int e = 0; e < Node.
GetInDeg(); e++) {
942 if (e > 0 && prevEId == Node.
GetInEId(e)) {
964 const int NodePlaces = (int) ceil(log10((
double)
GetNodes()));
965 const int EdgePlaces = (int) ceil(log10((
double)
GetEdges()));
966 fprintf(OutF,
"-------------------------------------------------\nDirected Node-Edge Network with Attributes: nodes: %d, edges: %d\n",
GetNodes(),
GetEdges());
968 fprintf(OutF,
" %*d:", NodePlaces, NodeI.GetId());
969 fprintf(OutF,
" in[%d]", NodeI.GetInDeg());
971 fprintf(OutF,
" %*d", EdgePlaces, NodeI.GetInEId(
edge)); }
973 fprintf(OutF,
" out[%d]", NodeI.GetOutDeg());
975 fprintf(OutF,
" %*d", EdgePlaces, NodeI.GetOutEId(
edge)); }
981 fprintf(OutF,
" nai[%d]", IntAttrN.
Len());
982 for (
int i = 0; i < IntAttrN.
Len(); i++) {
983 fprintf(OutF,
" %*i", NodePlaces, IntAttrN[i]()); }
988 fprintf(OutF,
" nas[%d]", StrAttrN.
Len());
989 for (
int i = 0; i < StrAttrN.
Len(); i++) {
990 fprintf(OutF,
" %*s", NodePlaces, StrAttrN[i]()); }
995 fprintf(OutF,
" naf[%d]", FltAttrN.
Len());
996 for (
int i = 0; i < FltAttrN.
Len(); i++) {
997 fprintf(OutF,
" %*f", NodePlaces, FltAttrN[i]()); }
1002 fprintf(OutF,
" %*d: %*d -> %*d", EdgePlaces, EdgeI.GetId(), NodePlaces, EdgeI.GetSrcNId(), NodePlaces, EdgeI.GetDstNId());
1007 fprintf(OutF,
" eai[%d]", IntAttrE.Len());
1008 for (
int i = 0; i < IntAttrE.Len(); i++) {
1009 fprintf(OutF,
" %*i", EdgePlaces, IntAttrE[i]());
1014 fprintf(OutF,
" eas[%d]", StrAttrE.
Len());
1015 for (
int i = 0; i < StrAttrE.
Len(); i++) {
1016 fprintf(OutF,
" %*s", EdgePlaces, StrAttrE[i]());
1020 fprintf(OutF,
" eaf[%d]", FltAttrE.
Len());
1021 for (
int i = 0; i < FltAttrE.
Len(); i++) {
1022 fprintf(OutF,
" %*f", EdgePlaces, FltAttrE[i]());
1024 fprintf(OutF,
"\n");
1045 for (i = 0; i <
MxNId; i++) {
1065 IAssertR(location != 0,
TStr::Fmt(
"NodeId %d exists for %s in sparse representation", NId, attr.
CStr()));
1069 IAssertR(location != 1,
TStr::Fmt(
"NodeId %d exists for %s in dense representation", NId, attr.
CStr()));
1090 IAssertR(location != 0,
TStr::Fmt(
"NodeId %d exists for %s in sparse representation", NId, attr.
CStr()));
1094 IAssertR(location != 1,
TStr::Fmt(
"NodeId %d exists for %s in dense representation", NId, attr.
CStr()));
1113 IAssertR(location != 0,
TStr::Fmt(
"NodeId %d exists for %s in sparse representation", NId, attr.
CStr()));
1117 IAssertR(location != 1,
TStr::Fmt(
"NodeId %d exists for %s in dense representation", NId, attr.
CStr()));
1139 IAssertR(location != 0,
TStr::Fmt(
"NodeId %d exists for %s in sparse representation", NId, attr.
CStr()));
1143 IAssertR(location != 1,
TStr::Fmt(
"NodeId %d exists for %s in dense representation", NId, attr.
CStr()));
1157 if (location != -1) {
1158 if (location == 1) {
1183 if (location != -1) {
1184 if (location == 1) {
1215 for (i = 0; i <
MxNId; i++) {
1239 for (i = 0; i <
MxNId; i++) {
1262 for (i = 0; i <
MxEId; i++) {
1282 IAssertR(location != 0,
TStr::Fmt(
"EdgeID %d exists for %s in sparse representation", EId, attr.
CStr()));
1286 IAssertR(location != 1,
TStr::Fmt(
"NodeId %d exists for %s in dense representation", EId, attr.
CStr()));
1306 IAssertR(location != 0,
TStr::Fmt(
"EdgeID %d exists for %s in sparse representation", EId, attr.
CStr()));
1310 IAssertR(location != 1,
TStr::Fmt(
"NodeId %d exists for %s in dense representation", EId, attr.
CStr()));
1323 if (location==-1)
return -1;
1325 IAssertR(location != 0,
TStr::Fmt(
"Edge %d exists for %s in sparse representation", EId, attr.
CStr()));
1329 IAssertR(location != 1,
TStr::Fmt(
"Edge %d exists for %s in dense representation", EId, attr.
CStr()));
1343 if (location==-1)
return -1;
1345 IAssertR(location != 0,
TStr::Fmt(
"Edge %d exists for %s in sparse representation", EId, attr.
CStr()));
1349 IAssertR(location != 1,
TStr::Fmt(
"Edge %d exists for %s in dense representation", EId, attr.
CStr()));
1370 for (i = 0; i <
MxEId; i++) {
1394 for (i = 0; i <
MxEId; i++) {
1506 }
else if (vecType ==
StrType) {
1508 }
else if (vecType ==
FltType) {
1529 }
else if (vecType ==
StrType) {
1531 }
else if (vecType ==
FltType) {
1554 for (i = 0; i <
MxNId; i++) {
1555 NewVec.
Ins(i, defaultValue);
1609 for (i = 0; i <
MxNId; i++) {
1610 NewVec.
Ins(i, defaultValue);
1629 for (i = 0; i <
MxNId; i++) {
1630 NewVec.
Ins(i, defaultValue);
1649 for (i = 0; i <
MxEId; i++) {
1650 NewVec.
Ins(i, defaultValue);
1704 for (i = 0; i <
MxEId; i++) {
1705 NewVec.
Ins(i, defaultValue);
1723 for (i = 0; i <
MxEId; i++) {
1724 NewVec.
Ins(i, defaultValue);
1742 }
else if (vecType ==
StrType) {
1747 }
else if (vecType ==
FltType) {
1776 }
else if (vecType ==
StrType) {
1781 }
else if (vecType ==
FltType) {
1796 for (
int i = 0; i < 5; i++) { Net->AddNode(i); }
1797 Net->AddEdge(0,1); Net->AddEdge(0,2);
1798 Net->AddEdge(0,3); Net->AddEdge(0,4);
1799 Net->AddEdge(1,2); Net->AddEdge(1,2);
1805 if (it.GetDat().GetVal1() ==
IntType) {
1806 IntAttrNames.
Add(it.GetKey());
1808 if (it.GetDat().GetVal1() ==
FltType) {
1809 FltAttrNames.
Add(it.GetKey());
1811 if (it.GetDat().GetVal1() ==
StrType) {
1812 StrAttrNames.
Add(it.GetKey());
1819 if (it.GetDat().GetVal1() ==
IntType) {
1820 IntAttrNames.
Add(it.GetKey());
1822 if (it.GetDat().GetVal1() ==
FltType) {
1823 FltAttrNames.
Add(it.GetKey());
1825 if (it.GetDat().GetVal1() ==
StrType) {
1826 StrAttrNames.
Add(it.GetKey());
1836 for (
int i = 0; i < len; i++) {
1844 int EId = it.GetId();
1845 int SrcId = it.GetSrcNId();
2139 if (
IsNode(NId)) {
return -1;}
2158 Node.
NIdV = NbrNIdV;
2161 for (
int i = 0; i < NbrNIdV.
Len(); i++) {
2162 GetNode(NbrNIdV[i]).NIdV.AddSorted(NewNId);
2192 for (
int e = 0; e < Node.
GetDeg(); e++) {
2194 if (nbr == NId) {
continue; }
2198 if (n!= -1) { N.
NIdV.
Del(n); }
2215 if (
IsEdge(SrcNId, DstNId)) {
return -2; }
2216 GetNode(SrcNId).NIdV.AddSorted(DstNId);
2217 if (SrcNId!=DstNId) {
2218 GetNode(DstNId).NIdV.AddSorted(SrcNId); }
2225 GetNode(SrcNId).NIdV.Add(DstNId);
2226 if (SrcNId!=DstNId) {
2227 GetNode(DstNId).NIdV.Add(SrcNId); }
2237 TIntPr Id(SrcNId, DstNId);
2239 if (n!= -1) { N.
NIdV.
Del(n); NEdges--; } }
2240 if (SrcNId != DstNId) {
2243 if (n!= -1) { N.
NIdV.
Del(n); }
2249 if (!
IsNode(SrcNId) || !
IsNode(DstNId))
return false;
2250 return GetNode(SrcNId).IsNbrNId(DstNId);
2255 const int MnNId =
TMath::Mn(SrcNId, DstNId);
2258 const int NodeN = SrcNI.
NodeHI.GetDat().NIdV.SearchBin(MxNId);
2292 for (
int e = 0; e < Node.
GetDeg(); e++) {
2294 const TStr Msg =
TStr::Fmt(
"Edge %d --> %d: node %d does not exist.",
2299 if (e > 0 && prevNId == Node.
GetNbrNId(e)) {
2300 const TStr Msg =
TStr::Fmt(
"Node %d has duplicate edge %d --> %d.",
2311 const TStr Msg =
TStr::Fmt(
"Number of edges counter is corrupted: GetEdges():%d, EdgeCount:%d.",
GetEdges(), EdgeCnt);
2320 const int NodePlaces = (int) ceil(log10((
double)
GetNodes()));
2321 fprintf(OutF,
"-------------------------------------------------\nUndirected Node Graph: nodes: %d, edges: %d\n",
GetNodes(),
GetEdges());
2324 fprintf(OutF,
" %*d [%d] ", NodePlaces, Node.
GetId(), Node.
GetDeg());
2327 fprintf(OutF,
"\n");
2329 fprintf(OutF,
"\n");
2335 for (
int i = 0; i < 5; i++) { Graph->AddNode(i); }
2336 Graph->AddEdge(0,1); Graph->AddEdge(0,2);
2337 Graph->AddEdge(0,3); Graph->AddEdge(0,4);
2338 Graph->AddEdge(1,2);
2469 if (SrcNId < DstNId) {
2470 return TIntPr(SrcNId, DstNId);
2472 return TIntPr(DstNId, SrcNId);
2476 if (!
IsEdge(SrcNId, DstNId)) {
2479 TIntPr EId = OrderEdgeNodes(SrcNId, DstNId);
2484 if (!
IsEdge(SrcNId, DstNId)) {
2487 TIntPr EId = OrderEdgeNodes(SrcNId, DstNId);
2492 if (!
IsEdge(SrcNId, DstNId)) {
2495 TIntPr EId = OrderEdgeNodes(SrcNId, DstNId);
2500 if (!
IsEdge(SrcNId, DstNId)) {
2503 TIntPr EId = OrderEdgeNodes(SrcNId, DstNId);
2508 if (!
IsEdge(SrcNId, DstNId)) {
2511 TIntPr EId = OrderEdgeNodes(SrcNId, DstNId);
2516 if (!
IsEdge(SrcNId, DstNId)) {
2519 TIntPr EId = OrderEdgeNodes(SrcNId, DstNId);
2524 if (!
IsEdge(SrcNId, DstNId)) {
2527 TIntPr EId = OrderEdgeNodes(SrcNId, DstNId);
2532 if (!
IsEdge(SrcNId, DstNId)) {
2535 TIntPr EId = OrderEdgeNodes(SrcNId, DstNId);
2540 if (!
IsEdge(SrcNId, DstNId)) {
2543 TIntPr EId = OrderEdgeNodes(SrcNId, DstNId);
2548 if (!
IsEdge(SrcNId, DstNId)) {
2551 TIntPr EId = OrderEdgeNodes(SrcNId, DstNId);
2556 if (!
IsEdge(SrcNId, DstNId)) {
2559 TIntPr EId = OrderEdgeNodes(SrcNId, DstNId);
2564 if (!
IsEdge(SrcNId, DstNId)) {
2567 TIntPr EId = OrderEdgeNodes(SrcNId, DstNId);
2572 if (!
IsEdge(SrcNId, DstNId)) {
2575 TIntPr EId = OrderEdgeNodes(SrcNId, DstNId);
2580 if (!
IsEdge(SrcNId, DstNId)) {
2583 TIntPr EId = OrderEdgeNodes(SrcNId, DstNId);
2588 if (!
IsEdge(SrcNId, DstNId)) {
2591 TIntPr EId = OrderEdgeNodes(SrcNId, DstNId);
2637 if (
IsNode(NId)) {
return -1;}
2688 for (
int e = 0; e < Node.
GetOutDeg(); e++) {
2690 if (nbr == NId) {
continue; }
2695 for (
int e = 0; e < Node.
GetInDeg(); e++) {
2697 if (nbr == NId) {
continue; }
2708 edges+=
NodeH[N].GetOutDeg();
2716 if (
IsEdge(SrcNId, DstNId)) {
return -2; }
2717 GetNode(SrcNId).OutNIdV.AddSorted(DstNId);
2718 GetNode(DstNId).InNIdV.AddSorted(SrcNId);
2723 GetNode(SrcNId).OutNIdV.Add(DstNId);
2724 GetNode(DstNId).InNIdV.Add(SrcNId);
2731 TIntPr Id(SrcNId, DstNId);
2749 if (!
IsNode(SrcNId) || !
IsNode(DstNId)) {
return false; }
2750 if (IsDir) {
return GetNode(SrcNId).IsOutNId(DstNId); }
2751 else {
return GetNode(SrcNId).IsOutNId(DstNId) ||
GetNode(DstNId).IsOutNId(SrcNId); }
2756 const int NodeN = SrcNI.
NodeHI.GetDat().OutNIdV.SearchBin(DstNId);
2781 const TStr Msg =
TStr::Fmt(
"Out-neighbor list of node %d is not sorted.", Node.
GetId());
2785 const TStr Msg =
TStr::Fmt(
"In-neighbor list of node %d is not sorted.", Node.
GetId());
2790 for (
int e = 0; e < Node.
GetOutDeg(); e++) {
2792 const TStr Msg =
TStr::Fmt(
"Out-edge %d --> %d: node %d does not exist.",
2796 if (e > 0 && prevNId == Node.
GetOutNId(e)) {
2797 const TStr Msg =
TStr::Fmt(
"Node %d has duplidate out-edge %d --> %d.",
2805 for (
int e = 0; e < Node.
GetInDeg(); e++) {
2807 const TStr Msg =
TStr::Fmt(
"In-edge %d <-- %d: node %d does not exist.",
2811 if (e > 0 && prevNId == Node.
GetInNId(e)) {
2812 const TStr Msg =
TStr::Fmt(
"Node %d has duplidate in-edge %d <-- %d.",
2823 const int NodePlaces = (int) ceil(log10((
double)
GetNodes()));
2824 fprintf(OutF,
"-------------------------------------------------\nDirected Node Graph: nodes: %d, edges: %d\n",
GetNodes(),
GetEdges());
2827 fprintf(OutF,
" %*d]\n", NodePlaces, Node.
GetId());
2828 fprintf(OutF,
" in [%d]", Node.
GetInDeg());
2830 fprintf(OutF,
" %*d", NodePlaces, Node.
GetInNId(
edge)); }
2831 fprintf(OutF,
"\n out[%d]", Node.
GetOutDeg());
2834 fprintf(OutF,
"\n");
2836 fprintf(OutF,
"\n");
2841 for (
int i = 0; i < 5; i++) { G->AddNode(i); }
2842 G->AddEdge(0,1); G->AddEdge(1,2); G->AddEdge(0,2);
2843 G->AddEdge(1,3); G->AddEdge(3,4); G->AddEdge(2,3);
2974 if (!
IsEdge(SrcNId, DstNId)) {
2977 TIntPr EId(SrcNId, DstNId);
2982 if (!
IsEdge(SrcNId, DstNId)) {
2985 TIntPr EId(SrcNId, DstNId);
2990 if (!
IsEdge(SrcNId, DstNId)) {
2993 TIntPr EId(SrcNId, DstNId);
2998 if (!
IsEdge(SrcNId, DstNId)) {
3001 TIntPr EId(SrcNId, DstNId);
3006 if (!
IsEdge(SrcNId, DstNId)) {
3009 TIntPr EId(SrcNId, DstNId);
3014 if (!
IsEdge(SrcNId, DstNId)) {
3017 TIntPr EId(SrcNId, DstNId);
3022 if (!
IsEdge(SrcNId, DstNId)) {
3025 TIntPr EId(SrcNId, DstNId);
3030 if (!
IsEdge(SrcNId, DstNId)) {
3033 TIntPr EId(SrcNId, DstNId);
3038 if (!
IsEdge(SrcNId, DstNId)) {
3041 TIntPr EId(SrcNId, DstNId);
3046 if (!
IsEdge(SrcNId, DstNId)) {
3049 TIntPr EId(SrcNId, DstNId);
3054 if (!
IsEdge(SrcNId, DstNId)) {
3057 TIntPr EId(SrcNId, DstNId);
3062 if (!
IsEdge(SrcNId, DstNId)) {
3065 TIntPr EId(SrcNId, DstNId);
3070 if (!
IsEdge(SrcNId, DstNId)) {
3073 TIntPr EId(SrcNId, DstNId);
3078 if (!
IsEdge(SrcNId, DstNId)) {
3081 TIntPr EId(SrcNId, DstNId);
3086 if (!
IsEdge(SrcNId, DstNId)) {
3089 TIntPr EId(SrcNId, DstNId);
bool IsOk(const bool &ThrowExcept=true) const
Checks the network data structure for internal consistency.
void GetNIdV(TIntV &NIdV) const
Gets a vector IDs of all nodes in the graph.
TVec< TIntV > VecOfIntVecsN
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.
bool HasFlag(const TGraphFlag &Flag) const
Allows for run-time checking the type of the network (see the TGraphFlag for flags).
static const T & Mn(const T &LVal, const T &RVal)
THash< TStr, TBool > KeyToDenseE
void GetNIdV(TIntV &NIdV) const
Gets a vector IDs of all nodes in the network.
TPair< TInt, TInt > TIntPr
void IntVAttrNameNI(const TInt &NId, TStrV &Names) const
Returns a vector of int attr names for node NId.
TInt GetIntAttrDatN(const TNodeI &NodeI, const TStr &attr)
Gets the value of int attr from the node attr value vector.
int GetAttrIndE(const TStr &attr)
Gets the index of the edge attr value vector specified by attr.
bool DelIfIn(const TVal &Val)
Removes the first occurrence of element Val.
int GetEdges() const
Returns the number of edges in the network.
bool IsInNId(const int &NId) const
Tests whether node with ID NId points to the current node.
int DelSAttrDat(const TInt &Id, const TStr &AttrName)
Delete attribute with name AttrName for the given id Id.
int GetSAttrIdE(const TStr &Name, TInt &AttrIdX, TAttrType &AttrTypeX) const
Gets id and type for attribute with name Name.
static PUndirNet New()
Static constructor that returns a pointer to the network. Call: PUndirNet Graph = TUndirNet::New()...
void GetAttrENames(TStrV &IntAttrNames, TStrV &FltAttrNames, TStrV &StrAttrNames) const
Fills each of the vectors with the names of edge attributes of the given type.
int GetNodes() const
Returns the number of nodes in the network.
bool IsKeyIdEqKeyN() const
int GetSAttrIdN(const TStr &Name, TInt &AttrIdX, TAttrType &AttrTypeX) const
Gets id and type for attribute with name Name.
int GetSAttrVN(const TInt &NId, const TAttrType AttrType, TAttrPrV &AttrV) const
Gets a list of all sparse attributes of type AttrType for node with id NId.
int GetSAttrIdE(const TStr &Name, TInt &AttrIdX, TAttrType &AttrTypeX) const
Gets id and type for attribute with name Name.
#define IAssertR(Cond, Reason)
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 AddIntVAttrN(const TStr &attr, TBool UseDense=true)
Adds a new IntV node attribute to the hashmap.
int AppendIntVAttrDatN(const TNodeI &NodeI, const TInt &value, const TStr &attr)
Appends value onto the TIntV attribute for the given node.
int AddFltAttrDatE(const TEdgeI &EdgeI, const TFlt &value, const TStr &attr)
Attribute based add function for attr to Flt value.
TStr GetEdgeAttrValue(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Returns edge attribute value, converted to Str type.
int AddFltVAttrDatE(const TEdgeI &EdgeI, const TFltV &value, const TStr &attr)
Attribute based add function for attr to TFltV value.
enum TAttrType_ TAttrType
Types for tables, sparse and dense attributes.
int GetSAttrIdN(const TStr &Name, TInt &AttrIdX, TAttrType &AttrTypeX) const
Gets id and type for attribute with name Name.
TVec< TStrV > VecOfStrVecsE
THash< TStr, TInt > IntDefaultsE
int GetIntAttrIndN(const TStr &attr)
Gets the index of the node attr value vector specified by attr (same as GetAttrIndN for compatibility...
bool NodeAttrIsStrDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Returns true if NId attr deleted value for current node str attr iterator.
TFlt GetWeightOutEdges(const TNodeI &NI, const TStr &attr)
Gets the sum of the weights of all the outgoing edges of the node.
int DelAttrN(const TStr &attr)
Removes all the values for node attr.
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the network.
bool NodeAttrIsDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Returns true if NId attr deleted for current node attr iterator.
bool IsStrAttrDeletedN(const int &NId, const TStr &attr) const
Returns true if Str attr exists for node NId and has default value.
void Del(const TSizeTy &ValN)
Removes the element at position ValN.
Edge iterator. Only forward iteration (operator++) is supported.
int GetIdVSAttrN(const TStr &AttrName, TIntV &IdV) const
Gets a list of all nodes that have a sparse attribute with name AttrName.
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 GetOutNId(const int &NodeN) const
int GetSAttrNameE(const TInt &AttrId, TStr &NameX, TAttrType &AttrTypeX) const
Gets name and type for attribute with id AttrId.
int GetSAttrVE(const TInt &EId, const TAttrType AttrType, TAttrPrV &AttrV) const
Gets a list of all sparse attributes of type AttrType for edge with id EId.
int GetSAttrNameE(const TInt &AttrId, TStr &NameX, TAttrType &AttrTypeX) const
Gets name and type for attribute with id AttrId.
TNode & GetNode(const int &NId)
void StrAttrNameNI(const TInt &NId, TStrV &Names) const
Returns a vector of str attr names for node NId.
bool IsFltVAttrDeletedN(const int &NId, const TStr &attr) const
Returns true if FltV attr exists for node NId and is an empty vector.
int AddSAttrDatE(const TInt &EId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given edge with id EId.
void FltAttrNameNI(const TInt &NId, TStrV &Names) const
Returns a vector of int attr names for node NId.
void DelNode(const int &NId)
Deletes node of ID NId from the network.
void IntVAttrValueEI(const TInt &EId, TVec< TIntV > &Values) const
Returns a vector of attr values for edge EId.
TVec< THash< TInt, TFltV > > VecOfFltHashVecsN
bool EdgeAttrIsFltDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Returns true if EId attr deleted for current edge flt attr iterator.
bool IsFltVAttrDeletedE(const int &EId, const TStr &attr) const
Returns true if FltV attr exists for edge EId and is an empty vector.
int AddSAttrDat(const TInt &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
TInt GetIntAttrDefaultE(const TStr &attribute) const
Gets Int edge attribute val. If not a proper attr, return default.
int AddNodeUnchecked(int NId=-1)
Adds a node of ID NId to the network, noop if the node already exists.
TInt CheckDenseOrSparseE(const TStr &attr) const
bool EdgeAttrIsDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Returns true if EId attr deleted for current edge attr iterator.
TFlt GetFltAttrDatE(const TEdgeI &EdgeI, const TStr &attr)
Gets the value of flt attr from the edge attr value vector.
int AddIntVAttrDatE(const TEdgeI &EdgeI, const TIntV &value, const TStr &attr)
Attribute based add function for attr to IntV value.
bool IsAttrDeletedE(const int &EId, const TStr &attr) const
Returns true if attr exists for edge EId and has default value.
bool IsFltAttrDeletedE(const int &EId, const TStr &attr) const
Returns true if Flt attr exists for edge NId and has default value.
TSizeTy Len() const
Returns the number of elements in the vector.
bool EdgeAttrIsIntDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Returns true if EId attr deleted for current edge int attr iterator.
int AddSAttrDatN(const TInt &NId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given node with id NId.
int GetSAttrName(const TInt &AttrId, TStr &NameX, TAttrType &AttrTypeX) const
Given the attribute id AttrId, get the attribute name.
int AppendFltVAttrDatN(const TNodeI &NodeI, const TFlt &value, const TStr &attr)
Appends value onto the TFltV attribute for the given node.
void FltVAttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of flt attr names for edge EId.
int DelAttrE(const TStr &attr)
Removes all the values for edge attr.
void StrAttrValueNI(const TInt &NId, TStrV &Values) const
Returns a vector of attr values for node NId.
int GetSAttrNameN(const TInt &AttrId, TStr &NameX, TAttrType &AttrTypeX) const
Gets name and type for attribute with id AttrId.
TIntV GetIntVAttrDatE(const TEdgeI &EdgeI, const TStr &attr)
Gets the value of the intv attr from the edge attr value vector.
void GenExt(TVal *_ValT, const TSizeTy &_Vals)
Constructs a vector of _Vals elements of memory array _ValT.
TStrIntPrH KeyToIndexTypeE
TStr GetStrAttrDatE(const TEdgeI &EdgeI, const TStr &attr)
Gets the value of str attr from the edge attr value vector.
int GetNbrNId(const int &NodeN) const
int AddNodeUnchecked(int NId=-1)
Adds a node of ID NId to the network, noop if the node already exists.
int GetSAttrDatN(const TInt &NId, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from node with id NId.
Node iterator. Only forward iteration (operator++) is supported.
void DelEdge(const int &EId)
Deletes an edge with edge ID EId from the graph.
THash< TStr, TFlt > FltDefaultsN
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
int AppendFltVAttrDatE(const TEdgeI &EdgeI, const TFlt &value, const TStr &attr)
Appends value onto the TFltV attribute for the given node.
void IntAttrValueEI(const TInt &EId, TIntV &Values) const
Returns a vector of attr values for edge EId.
static PUndirNet GetSmallGraph()
Returns a small network on 5 nodes and 5 edges.
int AddIntAttrDatE(const TEdgeI &EdgeI, const TInt &value, const TStr &attr)
Attribute based add function for attr to Int value.
const TDat & GetDat(const TKey &Key) const
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.
void AttrValueNI(const TInt &NId, TStrV &Values) const
Returns a vector of attr values for node NId.
TVec< TIntV > VecOfIntVecsE
void IntAttrNameNI(const TInt &NId, TStrV &Names) const
Returns a vector of int attr names for node NId.
int AddNode(int NId=-1)
Adds a node of ID NId to the network.
int GetSAttrDatN(const TInt &NId, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from node with id NId.
bool NodeAttrIsIntVDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Returns true if NId attr deleted value for current node int vector attr iterator. ...
TVec< TVec< TFltV > > VecOfFltVecVecsN
virtual void DelNode(const int &NId)
Deletes node of ID NId from the graph.
int GetSAttrNameN(const TInt &AttrId, TStr &NameX, TAttrType &AttrTypeX) const
Gets name and type for attribute with id AttrId.
void DelSAttrId(const TInt &Id)
Delete all attributes for the given id Id.
void LoadShM(TShMIn &ShMIn)
Load THash from shared memory file. Copying/Deleting Keys is illegal.
const TKey & GetKey() 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)
bool IsEdge(const int &SrcNId, const int &DstNId) const
Tests whether an edge between node IDs SrcNId and DstNId exists in the network.
TVec< TStrV > VecOfStrVecsN
bool IsIntAttrDeletedE(const int &EId, const TStr &attr) const
Returns true if Int attr exists for edge EId and has default value.
void GetEIdV(TIntV &EIdV) const
Gets a vector IDs of all edges in the graph.
void Dump(FILE *OutF=stdout) const
Print the graph in a human readable form to an output stream OutF.
bool IsFltAttrDeletedN(const int &NId, const TStr &attr) const
Returns true if Flt attr exists for node NId and has default value.
int AddFltAttrDatN(const TNodeI &NodeI, const TFlt &value, const TStr &attr)
Attribute based add function for attr to Flt value.
bool NodeAttrIsFltDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Returns true if NId attr deleted value for current node flt attr iterator.
void IntVAttrValueNI(const TInt &NId, TVec< TIntV > &Values) const
Returns a vector of attr values for node NId.
THash< TInt, TEdge > EdgeH
void GetAttrNNames(TStrV &IntAttrNames, TStrV &FltAttrNames, TStrV &StrAttrNames) const
Fills each of the vectors with the names of node attributes of the given type.
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.
bool IsOutNId(const int &NId) const
Tests whether the current node points to node with ID NId.
int GetAttrIndN(const TStr &attr)
Gets the index of the node attr value vector specified by attr.
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...
void DelEdge(const int &SrcNId, const int &DstNId)
Deletes an edge between node IDs SrcNId and DstNId from the network.
bool IsStrAttrDeletedE(const int &EId, const TStr &attr) const
Returns true if Str attr exists for edge NId and has default value.
void DelKey(const TKey &Key)
int GetId() const
Returns ID of the current node.
int GetSAttrVN(const TInt &NId, const TAttrType AttrType, TAttrPrV &AttrV) const
Gets a list of all sparse attributes of type AttrType for node with id NId.
const TVal & GetVal(const TSizeTy &ValN) const
Returns a reference to the element at position ValN in the vector.
int AddSAttrE(const TStr &Name, const TAttrType &AttrType, TInt &AttrId)
Adds mapping for sparse attribute with name Name and type AttrType.
int DelSAttrDatN(const TInt &NId, const TStr &AttrName)
Deletes sparse attribute with name AttrName from node with id NId.
TVec< TFltV > VecOfFltVecsE
int GetFltKeyIdE(const int &EId)
Gets keyid for edge with id EId.
int AddNodeUnchecked(int NId=-1)
Adds a node of ID NId to the network, noop if the node already exists.
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
const TDat & GetDat() const
TInt GetIntAttrDatE(const TEdgeI &EdgeI, const TStr &attr)
Gets the value of int attr from the edge attr value vector.
int AddStrAttrDatN(const TNodeI &NodeI, const TStr &value, const TStr &attr)
Attribute based add function for attr to Str value.
TVal * GetValVPt(const int &VId) const
Returns pointer to the first element of the vector with id VId.
int AddSAttrDatN(const TInt &NId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given node with id NId.
void Sort(const bool &Asc=true)
Sorts the elements of the vector.
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). ...
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
void FltAttrValueEI(const TInt &EId, TFltV &Values) const
Returns a vector of attr values for node NId.
int GetSAttrDatE(const TInt &EId, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from edge with id EId.
TVec< TVec< TFltV > > VecOfFltVecVecsE
int GetSAttrIdE(const TStr &Name, TInt &AttrIdX, TAttrType &AttrTypeX) const
Gets id and type for attribute with name Name.
int GetVLen(const int &VId) const
Returns the number of elements in the vector with id VId.
int AddSAttrDatE(const int &SrcNId, const int &DstNId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given edge with ids SrcId and DstId...
bool HasFlag(const TGraphFlag &Flag) const
Allows for run-time checking the type of the graph (see the TGraphFlag for flags).
int AddIntAttrN(const TStr &attr, TInt defaultValue=TInt::Mn)
Adds a new Int node attribute to the hashmap.
TStr GetStrAttrDefaultE(const TStr &attribute) const
Gets Str edge attribute val. If not a proper attr, return default.
int AddEdge(const int &SrcNId, const int &DstNId, int EId=-1)
Adds an edge with ID EId between node IDs SrcNId and DstNId to the graph.
int AddSAttrDatN(const TInt &NId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given node with id NId.
bool FNextKeyId(int &KeyId) const
int GetSAttrDatE(const int &SrcNId, const int &DstNId, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from edge with ids SrcId and DstId.
THash< TStr, TStr > StrDefaultsN
void AttrNameNI(const TInt &NId, TStrV &Names) const
Returns a vector of attr names for node NId.
int GetIdVSAttrE(const TStr &AttrName, TIntPrV &IdV) const
Gets a list of all edges that have a sparse attribute with name AttrName.
int AddStrAttrE(const TStr &attr, TStr defaultValue=TStr::GetNullStr())
Adds a new Str edge attribute to the hashmap.
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.
bool IsOk(const bool &ThrowExcept=true) const
Checks the graph data structure for internal consistency.
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.
void FltVAttrNameNI(const TInt &NId, TStrV &Names) const
Returns a vector of flt attr names for node NId.
bool IsOk(const bool &ThrowExcept=true) const
Checks the network data structure for internal consistency.
int GetIdVSAttr(const TInt &AttrId, const TAttrType Type, TIntV &IdV) const
int GetSAttrNameN(const TInt &AttrId, TStr &NameX, TAttrType &AttrTypeX) const
Gets name and type for attribute with id AttrId.
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the graph.
TFltV GetFltVAttrDatE(const TEdgeI &EdgeI, const TStr &attr)
Gets the value of the fltv attr from the edge attr value vector.
void DelEdge(const int &SrcNId, const int &DstNId, const bool &IsDir=true)
Deletes an edge from node IDs SrcNId to DstNId from the network.
bool HasFlag(const TGraphFlag &Flag) const
Allows for run-time checking the type of the network (see the TGraphFlag for flags).
TStr GetStrAttrDefaultN(const TStr &attribute) const
Gets Str node attribute val. If not a proper attr, return default.
bool EdgeAttrIsFltVDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Returns true if EId attr deleted for current edge flt vector attr iterator.
void DelNode(const int &NId)
Deletes node of ID NId from the network.
TStr GetNodeAttrValue(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Returns node attribute value, converted to Str type.
TVec< TVec< TIntV > > VecOfIntVecVecsE
int GetSAttrDatE(const int &SrcNId, const int &DstNId, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from edge with ids SrcId and DstId.
void AttrValueEI(const TInt &EId, TStrV &Values) const
Returns a vector of attr values for edge EId.
void FltAttrValueNI(const TInt &NId, TFltV &Values) const
Returns a vector of attr values for node NId.
void GetNIdV(TIntV &NIdV) const
Gets a vector IDs of all nodes in the network.
Directed multigraph with node edge attributes.
void LoadNetworkShM(TShMIn &ShMIn)
load network from shared memory for this network
TSizeTy SearchBin(const TVal &Val) const
Returns the position of an element with value Val.
int AddSAttrDatE(const int &SrcNId, const int &DstNId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given edge with ids SrcId and DstId...
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge between node IDs SrcNId and DstNId to the network.
void GetSAttrV(const TInt &Id, const TAttrType AttrType, TAttrPrV &AttrV) const
Get a list of all attributes of type AttrType for the given id Id.
bool IsIntAttrE(const TStr &attr)
Checks if there is an edge attribute with name attr.
static PNEANet GetSmallGraph()
Returns a small multigraph on 5 nodes and 6 edges.
bool IsIntVAttrDeletedE(const int &EId, const TStr &attr) const
Returns true if IntV attr exists for edge EId and is an empty vector.
int AddSAttrN(const TStr &Name, const TAttrType &AttrType, TInt &AttrId)
Adds mapping for sparse attribute with name Name and type AttrType.
int AddSAttrE(const TStr &Name, const TAttrType &AttrType, TInt &AttrId)
Adds mapping for sparse attribute with name Name and type AttrType.
TEdge & GetEdge(const int &EId)
void FltVAttrValueEI(const TInt &EId, TVec< TFltV > &Values) const
Returns a vector of attr values for edge EId.
void Dump(FILE *OutF=stdout) const
Print the network in a human readable form to an output stream OutF.
bool IsFltAttrE(const TStr &attr)
Checks if there is an edge attribute with name attr.
int GetKeyId(const TKey &Key) const
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.
bool EdgeAttrIsIntVDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Returns true if EId attr deleted for current edge int vector attr iterator.
int AddStrAttrN(const TStr &attr, TStr defaultValue=TStr::GetNullStr())
Adds a new Str node attribute to the hashmap.
int GetSAttrDat(const TInt &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
void LoadShM(TShMIn &ShMIn)
Constructs the vector from a shared memory input.
bool IsIntAttrDeletedN(const int &NId, const TStr &attr) const
Returns true if Int attr exists for node NId and has default value.
Edge iterator. Only forward iteration (operator++) is supported.
int DelAttrDatE(const TEdgeI &EdgeI, const TStr &attr)
Deletes the edge attribute for NodeI.
int AddIntVAttrE(const TStr &attr, TBool UseDense=true)
Adds a new IntV edge attribute to the hashmap.
TVec< THash< TInt, TFltV > > VecOfFltHashVecsE
void FltAttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of int attr names for node NId.
int DelSAttrDatE(const int &SrcNId, const int &DstNId, const TStr &AttrName)
Deletes sparse attribute with name AttrName from edge with ids SrcId and DstId.
void FltVAttrValueNI(const TInt &NId, TVec< TFltV > &Values) const
Returns a vector of flt values for node NId.
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge from node SrcNId to node DstNId to the network.
bool NodeAttrIsFltVDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Returns true if NId attr deleted value for current node int vector attr iterator. ...
THash< TStr, TStr > StrDefaultsE
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.
int GetEdges() const
Returns the number of edges in the graph.
void GetKeyV(TVec< TKey > &KeyV) const
int GetSAttrIdN(const TStr &Name, TInt &AttrIdX, TAttrType &AttrTypeX) const
Gets id and type for attribute with name Name.
int GetOutEId(const int &EdgeN) const
bool EdgeAttrIsStrDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Returns true if EId attr deleted for current edge str attr iterator.
int GetEdges() const
Returns the number of edges in the network.
int AddStrAttrDatE(const TEdgeI &EdgeI, const TStr &value, const TStr &attr)
Attribute based add function for attr to Str value.
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.
enum TGraphFlag_ TGraphFlag
Graph Flags, used for quick testing of graph types.
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the network.
void GetWeightOutEdgesV(TFltV &OutWeights, const TFltV &AttrVal)
Fills OutWeights with the outgoing weight from each node.
int AddFltVAttrDatN(const TNodeI &NodeI, const TFltV &value, const TStr &attr)
Attribute based add function for attr to FltV value.
int GetIdVSAttrN(const TStr &AttrName, TIntV &IdV) const
Gets a list of all nodes that have a sparse attribute with name AttrName.
bool IsAttrDeletedN(const int &NId, const TStr &attr) const
Returns true if attr exists for node NId and has default value.
TVec< TFltV > VecOfFltVecsN
int GetSAttrVE(const int &SrcNId, const int &DstNId, const TAttrType AttrType, TAttrPrV &AttrV) const
Gets a list of all sparse attributes of type AttrType for edge with ids SrcId and DstId...
#define EAssertR(Cond, MsgStr)
int AddSAttrE(const TStr &Name, const TAttrType &AttrType, TInt &AttrId)
Adds mapping for sparse attribute with name Name and type AttrType.
int GetSAttrDatN(const TInt &NId, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from node with id NId.
TVec< THash< TInt, TIntV > > VecOfIntHashVecsN
int GetSAttrNameE(const TInt &AttrId, TStr &NameX, TAttrType &AttrTypeX) const
Gets name and type for attribute with id AttrId.
TIntPr OrderEdgeNodes(const int &SrcNId, const int &DstNId) const
TVec< TFlt > & GetFltAttrVecE(const TStr &attr)
Gets Vector for the Flt Attribute attr.
int GetSAttrId(const TStr &Name, TInt &AttrIdX, TAttrType &AttrTypeX) const
Given the attribute name Name, get the attribute id.
THash< TStr, TInt > IntDefaultsN
#define AssertR(Cond, Reason)
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
bool NodeAttrIsIntDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Returns true if NId attr deleted value for current node int attr iterator.
bool IsIntVAttrDeletedN(const int &NId, const TStr &attr) const
Returns true if IntV attr exists for node NId and is an empty vector.
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.
static PDirNet New()
Static constructor that returns a pointer to the network. Call: PDirNet Graph = TDirNet::New().
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
int AddNode(int NId=-1)
Adds a node of ID NId to the network.
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...
TNodeI BegNI() const
Returns an iterator referring to the first node in the graph.
TVec< TVec< TIntV > > VecOfIntVecVecsN
int AddIntAttrE(const TStr &attr, TInt defaultValue=TInt::Mn)
Adds a new Int edge attribute to the hashmap.
void Dump(FILE *OutF=stdout) const
Print the network in a human readable form to an output stream OutF.
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the graph.
int DelFromFltVAttrDatN(const TNodeI &NodeI, const TFlt &value, const TStr &attr)
Deletes value from the TFltV attribute for the given node.
TFlt GetFltAttrDefaultN(const TStr &attribute) const
Gets Flt node attribute val. If not a proper attr, return default.
int GetInEId(const int &EdgeN) const
int GetIdVSAttrE(const TStr &AttrName, TIntPrV &IdV) const
Gets a list of all edges that have a sparse attribute with name AttrName.
void IntAttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of int attr names for edge EId.
int GetIdVSAttrE(const TStr &AttrName, TIntV &IdV) const
Gets a list of all edges that have a sparse attribute with name AttrName.
TInt GetIntAttrDefaultN(const TStr &attribute) const
Gets Int node attribute val. If not a proper attr, return default.
void Load(TSIn &SIn)
Load attribute from input stream.
int GetInNId(const int &NodeN) const
int AddFltVAttrN(const TStr &attr, TBool UseDense=true)
Adds a new FltV node attribute to the hashmap.
bool IsKey(const TKey &Key) const
int AddAttributes(const int NId)
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
int GetSAttrVN(const TInt &NId, const TAttrType AttrType, TAttrPrV &AttrV) const
Gets a list of all sparse attributes of type AttrType for node with id NId.
static PNEANet New()
Static cons returns pointer to graph. Ex: PNEANet Graph=TNEANet::New().
int DelSAttrDatE(const TInt &EId, const TStr &AttrName)
Deletes sparse attribute with name AttrName from edge with id EId.
int GetSAttrVE(const int &SrcNId, const int &DstNId, const TAttrType AttrType, TAttrPrV &AttrV) const
Gets a list of all sparse attributes of type AttrType for edge with ids SrcId and DstId...
int GetIdVSAttrN(const TStr &AttrName, TIntV &IdV) const
Gets a list of all nodes that have a sparse attribute with name AttrName.
TEdgeI GetEI(const int &EId) const
Not supported/implemented!
int DelSAttrDatE(const int &SrcNId, const int &DstNId, const TStr &AttrName)
Deletes sparse attribute with name AttrName from edge with ids SrcId and DstId.
bool IsStrAttrE(const TStr &attr)
Checks if there is an edge attribute with name attr.
int AddEdgeUnchecked(const int &SrcNId, const int &DstNId)
Adds an edge between node IDs SrcNId and DstNId to the network.
int DelAttrDatN(const TNodeI &NodeI, const TStr &attr)
Deletes the node attribute for NodeI.
int DelSAttrDatN(const TInt &NId, const TStr &AttrName)
Deletes sparse attribute with name AttrName from node with id NId.
TDat & AddDat(const TKey &Key)
static PDirNet GetSmallGraph()
Returns a small network on 5 nodes and 6 edges.
TFltV GetFltVAttrDatN(const TNodeI &NodeI, const TStr &attr) const
Gets the value of the fltv attr from the node attr value vector.
int AddIntAttrDatN(const TNodeI &NodeI, const TInt &value, const TStr &attr)
Attribute based add function for attr to Int value.
TEdgeI GetEI(const int &EId) const
Not supported/implemented!
int GetIntAttrIndE(const TStr &attr)
Gets the index of the edge attr value vector specified by attr (same as GetAttrIndE for compatibility...
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...
int DelSAttrDatN(const TInt &NId, const TStr &AttrName)
Deletes sparse attribute with name AttrName from node with id NId.
int AddFltVAttrE(const TStr &attr, TBool UseDense=true)
Adds a new FltV edge attribute to the hashmap.
int AddEdgeUnchecked(const int &SrcNId, const int &DstNId)
Adds an edge from node SrcNId to node DstNId to the network.
Node iterator. Only forward iteration (operator++) is supported.
THash< TStr, TBool > KeyToDenseN
KeyToDense[N|E]: Key->(True if Vec, False if Hash)
const TKey & GetKey(const int &KeyId) const
int AddNode(int NId=-1)
Adds a node of ID NId to the network.
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the graph.
int AddSAttr(const TStr &Name, const TAttrType &AttrType, TInt &AttrIdX)
Adds a mapping for an attribute with name Name and type AttrType.
int AddFltAttrE(const TStr &attr, TFlt defaultValue=TFlt::Mn)
Adds a new Flt edge attribute to the hashmap.
int AddSAttrN(const TStr &Name, const TAttrType &AttrType, TInt &AttrId)
Adds mapping for sparse attribute with name Name and type AttrType.
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...
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.
int AddSAttrN(const TStr &Name, const TAttrType &AttrType, TInt &AttrId)
Adds mapping for sparse attribute with name Name and type AttrType.
TIter GetI(const TKey &Key) const
int AddFltAttrN(const TStr &attr, TFlt defaultValue=TFlt::Mn)
Adds a new Flt node attribute to the hashmap.