356 TIntV CmtyVIn, CmtyVOut, CmtyVAll;
364 if (CmtyVIn.
Len() >= CmtyVOut.
Len()) {
373 if (CmtyVAll.
Len() == 0) {
return; }
374 double OXMin = 0.1, YMin = 0.1, OXMax = 2500.00, YMax = 1000.0, IXMin = 0.1, IXMax = 2500.00;
375 double OStep = (OXMax - OXMin) / (
double) CmtyVOut.
Len(), IStep = (IXMax - IXMin) / (
double) CmtyVIn.
Len();
377 FILE* F = fopen(OutFNm.
CStr(),
"wt");
378 fprintf(F,
"<?xml version='1.0' encoding='UTF-8'?>\n");
379 fprintf(F,
"<gexf xmlns='http://www.gexf.net/1.2draft' xmlns:viz='http://www.gexf.net/1.1draft/viz' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd' version='1.2'>\n");
380 fprintf(F,
"\t<graph mode='static' defaultedgetype='directed'>\n");
381 fprintf(F,
"\t\t<nodes>\n");
382 for (
int c = 0; c < CmtyVOut.
Len(); c++) {
383 int NID = CmtyVOut[c];
384 double XPos = c * OStep + OXMin;
391 fprintf(F,
"\t\t\t<node id='%d' label='%s'>\n", NID, Label.
CStr());
392 fprintf(F,
"\t\t\t\t<viz:color r='%d' g='%d' b='%d'/>\n", Color.
Val1.Val, Color.
Val2.Val, Color.
Val3.Val);
393 fprintf(F,
"\t\t\t\t<viz:size value='4.0'/>\n");
394 fprintf(F,
"\t\t\t\t<viz:shape value='square'/>\n");
395 fprintf(F,
"\t\t\t\t<viz:position x='%f' y='%f' z='0.0'/>\n", XPos, YMax);
396 fprintf(F,
"\t\t\t</node>\n");
399 for (
int u = 0; u < CmtyVIn.
Len(); u++) {
400 int NID = CmtyVIn[u];
406 double XPos = IXMin + u * IStep;
409 fprintf(F,
"\t\t\t<node id='%d' label='%s'>\n", NID, Label.
CStr());
410 fprintf(F,
"\t\t\t\t<viz:color r='%d' g='%d' b='%d' a='%.1f'/>\n", Color.
Val1.Val, Color.
Val2.Val, Color.
Val3.Val, Alpha);
411 fprintf(F,
"\t\t\t\t<viz:size value='4.0'/>\n");
412 fprintf(F,
"\t\t\t\t<viz:shape value='square'/>\n");
413 fprintf(F,
"\t\t\t\t<viz:position x='%f' y='%f' z='0.0'/>\n", XPos, YMin);
414 fprintf(F,
"\t\t\t</node>\n");
416 fprintf(F,
"\t\t</nodes>\n");
419 fprintf(F,
"\t\t<edges>\n");
421 if (NI.GetOutDeg() == 0 && NI.GetInDeg() == 0 ) {
continue; }
422 for (
int e = 0; e < NI.GetOutDeg(); e++) {
423 fprintf(F,
"\t\t\t<edge id='%d' source='%d' target='%d'/>\n", EID++, NI.GetId(), NI.GetOutNId(e));
426 fprintf(F,
"\t\t</edges>\n");
427 fprintf(F,
"\t</graph>\n");
428 fprintf(F,
"</gexf>\n");
bool DelIfIn(const TVal &Val)
Removes the first occurrence of element Val.
TNodeI BegNI() const
Returns an iterator referring to the first node in the graph.
TSizeTy Len() const
Returns the number of elements in the vector.
TVec< TIntFltH > OutCmtyValHV
const TDat & GetDat(const TKey &Key) const
TVec< TIntFltH > InCmtyValHV
int ChangeChAll(const char &SrcCh, const char &DstCh)
PUNGraph GetSubGraph(const PUNGraph &Graph, const TIntV &NIdV, const bool &RenumberNodes)
Returns an induced subgraph of an undirected graph Graph with NIdV nodes with an optional node renumb...
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the graph.
Node iterator. Only forward iteration (operator++) is supported.
TTriple< TInt, TInt, TInt > TIntTr
void GetCmtyVAll(TIntV &CmtyVAll, const int CID)
save bipartite community affiliation into gexf file
bool IsKey(const TKey &Key) const
TVec< TIntFltH > InOutCmtyValHV