1

OGDF を使用して、PQTree を作成および初期化しました。初期化は、ノード a がルート、b、c、および d が a の葉である 3 つのエッジで行われました。ここで、計算後、リーフ e、d、および f をリーフとして b に追加する必要があります。しかし、問題は b がリーフであるため、子もリーフも受け入れないことです。コードはこちら。std::cout としては、追加されたのですが、writeGML を使用して GML ファイルに書き込むと、ノードを追加する前と追加した後で違いがなく、ツリーに含まれていません。私は、それは PQLeafKey のためだと思います。非リーフ エッジ/ノードの場合は PQNodeKey である必要があります。ドキュメントによると、ablk->nodePointer() は、PQNode から派生した PQLeaf を返す必要があり、PQNode から派生した PQInternelNode とは「互換性」がありません。しかし、別の方法で追加する方法がわかりません。コード:

G = new Graph();
GA = new GraphAttributes(*G, GraphAttributes::nodeGraphics |
                         GraphAttributes::edgeGraphics |
                         GraphAttributes::nodeStyle |
                         GraphAttributes::nodeId |
                         GraphAttributes::edgeType |
                         GraphAttributes::edgeArrow |
                         GraphAttributes::edgeStyle);
node a = G->newNode();
node b = G->newNode();
node c = G->newNode();
node d = G->newNode();
edge ab = G->newEdge(a, b);
edge ac = G->newEdge(a, c);
edge ad = G->newEdge(a, d);

PQLeafKey<edge, IndInfo *, bool> *ablk = new PQLeafKey<edge, IndInfo *, bool>(ab);
PQLeafKey<edge, IndInfo *, bool> *aclk = new PQLeafKey<edge, IndInfo *, bool>(ac);
PQLeafKey<edge, IndInfo *, bool> *adlk = new PQLeafKey<edge, IndInfo *, bool>(ad);

SListPure<PQLeafKey<edge, IndInfo *, bool> *> *lkl = new SListPure<PQLeafKey<edge, IndInfo *, bool> *>();
lkl->pushBack(ablk);
lkl->pushBack(aclk);
lkl->pushBack(adlk);

pqtree = new PQTree<edge, IndInfo *, bool>();
pqtree->Initialize(*lkl);
pqtree->writeGML("/home/LPT/graph_qtree_MOC_after_initialization.gml");

node e = G->newNode();
node f = G->newNode();
node g = G->newNode();
edge be = G->newEdge(b, e);
edge bf = G->newEdge(b, f);
edge bg = G->newEdge(b, g);
PQLeafKey<edge, IndInfo *, bool> *belk = new PQLeafKey<edge, IndInfo *, bool>(be);
PQLeafKey<edge, IndInfo *, bool> *bflk = new PQLeafKey<edge, IndInfo *, bool>(bf);
PQLeafKey<edge, IndInfo *, bool> *bglk = new PQLeafKey<edge, IndInfo *, bool>(bg);
SListPure<PQLeafKey<edge, IndInfo *, bool> *> *lkl4 = new SListPure<PQLeafKey<edge, IndInfo *, bool> *>();
lkl4->pushBack(belk);
lkl4->pushBack(bflk);
lkl4->pushBack(bglk);

PQInternalNode<edge, IndInfo *, bool> *father = (PQInternalNode<edge, IndInfo *, bool> *) (ablk->nodePointer());
father->type(PQNodeRoot::PNode);
bool r = pqtree->addNewLeavesToTree(father, *lkl4);
QString res = r ? "done." : "failed.";
std::cout << "Adding leaves to the tree for MOC has " << res.toStdString() << std::endl;
pqtree->writeGML("/home/LPT/graph_qtree_MOC_after_addition_be_bf_bg.gml");
4

1 に答える 1