8 Graph->AddModeNet(Name);
9 TModeNet& Net = Graph->GetModeNetByName(Name);
10 return LoadMode(Net, Table, NCol, NodeAttrV);
17 const TAttrType NodeType = Table->GetColType(NCol);
18 const TInt NColIdx = Table->GetColIdx(NCol);
20 for (
int CurrRowIdx = 0; CurrRowIdx < (Table->Next).Len(); CurrRowIdx++) {
21 if ((Table->Next)[CurrRowIdx] == Table->Invalid) {
27 if (NodeType ==
atFlt) {
29 }
else if (NodeType ==
atInt || NodeType ==
atStr) {
30 if (NodeType ==
atInt) {
31 NVal = (Table->IntCols)[NColIdx][CurrRowIdx];
33 NVal = (Table->StrColMaps)[NColIdx][CurrRowIdx];
34 if (strlen(Table->GetContextKey(NVal)) == 0) {
continue; }
40 for (
TInt i = 0; i < NodeAttrV.
Len(); i++) {
41 TStr ColName = NodeAttrV[i];
43 TInt Index = Table->GetColIdx(ColName);
46 Graph.
AddIntAttrDatN(NVal, Table->IntCols[Index][CurrRowIdx], ColName);
49 Graph.
AddFltAttrDatN(NVal, Table->FltCols[Index][CurrRowIdx], ColName);
52 Graph.
AddStrAttrDatN(NVal, Table->GetStrVal(Index, CurrRowIdx), ColName);
63 Graph->AddCrossNet(Mode1, Mode2, CrossName);
64 TCrossNet& Net = Graph->GetCrossNetByName(CrossName);
65 return LoadCrossNet(Net, Table, SrcCol, DstCol, EdgeAttrV);
73 const TAttrType NodeType = Table->GetColType(SrcCol);
74 Assert(NodeType == Table->GetColType(DstCol));
75 const TInt SrcColIdx = Table->GetColIdx(SrcCol);
76 const TInt DstColIdx = Table->GetColIdx(DstCol);
83 for (
int CurrRowIdx = 0; CurrRowIdx < (Table->Next).Len(); CurrRowIdx++) {
84 if ((Table->Next)[CurrRowIdx] == Table->Invalid) {
90 if (NodeType ==
atFlt) {
92 }
else if (NodeType ==
atInt || NodeType ==
atStr) {
93 if (NodeType ==
atInt) {
94 SVal = (Table->IntCols)[SrcColIdx][CurrRowIdx];
95 DVal = (Table->IntCols)[DstColIdx][CurrRowIdx];
97 SVal = (Table->StrColMaps)[SrcColIdx][CurrRowIdx];
98 if (strlen(Table->GetContextKey(SVal)) == 0) {
continue; }
99 DVal = (Table->StrColMaps)[DstColIdx][CurrRowIdx];
100 if (strlen(Table->GetContextKey(DVal)) == 0) {
continue; }
105 if (Graph.
AddEdge(SVal, DVal, CurrRowIdx) == -1) {
return -1; }
108 for (
TInt i = 0; i < EdgeAttrV.
Len(); i++) {
109 TStr ColName = EdgeAttrV[i];
110 TAttrType T = Table->GetColType(ColName);
111 TInt Index = Table->GetColIdx(ColName);
114 Graph.
AddIntAttrDatE(CurrRowIdx, Table->IntCols[Index][CurrRowIdx], ColName);
117 Graph.
AddFltAttrDatE(CurrRowIdx, Table->FltCols[Index][CurrRowIdx], ColName);
120 Graph.
AddStrAttrDatE(CurrRowIdx, Table->GetStrVal(Index, CurrRowIdx), ColName);
int AddFltAttrDatE(const TCrossEdgeI &EdgeI, const TFlt &value, const TStr &attr)
Attribute based add function for attr to Flt value.
int AddStrAttrDatE(const TCrossEdgeI &EdgeI, const TStr &value, const TStr &attr)
Attribute based add function for attr to Str value.
enum TAttrType_ TAttrType
Types for tables, sparse and dense attributes.
int LoadModeNetToNet(PMMNet Graph, const TStr &Name, PTable Table, const TStr &NCol, TStrV &NodeAttrV)
Loads a mode, with name Name, into the PMMNet from the TTable. NCol specifies the node id column and ...
TSizeTy Len() const
Returns the number of elements in the vector.
int AddNode(int NId=-1)
Adds a node of ID NId to the network.
int AddFltAttrDatN(const TNodeI &NodeI, const TFlt &value, const TStr &attr)
Attribute based add function for attr to Flt value.
int AddIntAttrDatE(const TCrossEdgeI &EdgeI, const TInt &value, const TStr &attr)
Attribute based add function for attr to Int value.
int LoadCrossNetToNet(PMMNet Graph, const TStr &Mode1, const TStr &Mode2, const TStr &CrossName, PTable Table, const TStr &SrcCol, const TStr &DstCol, TStrV &EdgeAttrV)
Loads a crossnet from Mode1 to Mode2, with name CrossName, from the provided TTable. EdgeAttrV specifies edge attributes.
int AddStrAttrDatN(const TNodeI &NodeI, const TStr &value, const TStr &attr)
Attribute based add function for attr to Str value.
int LoadCrossNet(TCrossNet &Graph, PTable Table, const TStr &SrcCol, const TStr &DstCol, TStrV &EdgeAttrV)
Loads the edges from the TTable and EdgeAttrV specifies columns containing edge attributes.
int LoadMode(TModeNet &Graph, PTable Table, const TStr &NCol, TStrV &NodeAttrV)
Loads the nodes specified in column NCol from the TTable with the attributes specified in NodeAttrV...
The nodes of one particular mode in a TMMNet, and their neighbor vectors as TIntV attributes...
int AddEdge(const int &sourceNId, const int &destNId, int EId=-1)
Adds an edge to the CrossNet; Mode1 NId should be the sourceNId always, regardless of whether edge is...
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
int AddIntAttrDatN(const TNodeI &NodeI, const TInt &value, const TStr &attr)
Attribute based add function for attr to Int value.
Implements a single CrossNet consisting of edges between two TModeNets (could be the same TModeNet) ...