This commit is contained in:
codeboss 2024-10-06 20:52:41 +08:00
parent 061fafd728
commit 0682930521
2 changed files with 16 additions and 10 deletions

View File

@ -228,7 +228,14 @@ QList<std::shared_ptr<DAGOrderHelper>> DAGGraph::tidy_graph_nodes() {
}
#include <QDebug>
void DAGGraph::graph_layer_nodes_sort_forward(int layer_index, const QList<std::shared_ptr<DAGOrderHelper>>& nodes) {
void dags::DAGGraph::graph_layout_nodes_forward(const QList<std::shared_ptr<DAGOrderHelper>>& nodes)
{
for (auto layer_index = 0; layer_index < maxLayerCount(); ++layer_index) {
this->nodes_sort_forward_within_layer(layer_index, nodes);
this->nodes_sort_with_above(layer_index, nodes);
}
}
void DAGGraph::nodes_sort_forward_within_layer(int layer_index, const QList<std::shared_ptr<DAGOrderHelper>>& nodes) {
QList<std::shared_ptr<DAGOrderHelper>> nodes_within_current_layer;
std::copy_if(nodes.begin(), nodes.end(), std::back_inserter(nodes_within_current_layer),
[=](std::shared_ptr<DAGOrderHelper> ins) { return ins->layerNumber() == layer_index; });
@ -278,9 +285,6 @@ void DAGGraph::graph_layer_nodes_sort_forward(int layer_index, const QList<std::
// 提取当前层次节点排序值
this->current_nodelist_filling_indi(nodes_within_current_layer);
}
this->nodes_sort_with_above(layer_index, nodes);
this->graph_layer_nodes_sort_forward(layer_index + 1, nodes);
}
}
@ -356,7 +360,7 @@ void dags::DAGGraph::nodes_sort_with_above(int layer_index, const QList<std::sha
}
}
void dags::DAGGraph::graph_adjust_after_layout(const QList<std::shared_ptr<DAGOrderHelper>>& total_nodes)
void dags::DAGGraph::graph_adjust_nodes_backward(const QList<std::shared_ptr<DAGOrderHelper>>& total_nodes)
{
auto layer_index = this->maxLayerCount() - 1;
while (layer_index > -1) {
@ -716,18 +720,18 @@ void dags::DAGGraph::primitiveGraphLayout() {
}
auto tidy_nodes = this->tidy_graph_nodes();
this->graph_layer_nodes_sort_forward(0, tidy_nodes);
this->graph_layout_nodes_forward(tidy_nodes);
this->node_with_layout = tidy_nodes;
}
void dags::DAGGraph::forwardsLayoutImpls()
{
this->graph_layer_nodes_sort_forward(0, this->node_with_layout);
this->graph_layout_nodes_forward(this->node_with_layout);
}
void dags::DAGGraph::backwardsLayoutImpls()
{
this->graph_adjust_after_layout(this->node_with_layout);
this->graph_adjust_nodes_backward(this->node_with_layout);
}
void dags::DAGGraph::adjustLayoutImpls()

View File

@ -90,9 +90,11 @@ namespace dags {
int node_layering(const std::shared_ptr<DAGLayerHelper> &inst, int layer_current);
int node_layering_adj(std::shared_ptr<DAGLayerHelper> inst);
QList<std::shared_ptr<DAGOrderHelper>> tidy_graph_nodes();
void graph_layer_nodes_sort_forward(int layer_index, const QList<std::shared_ptr<DAGOrderHelper>> &nodes);
void graph_adjust_after_layout(const QList<std::shared_ptr<DAGOrderHelper>>& total_nodes);
void graph_layout_nodes_forward(const QList<std::shared_ptr<DAGOrderHelper>>& total_nodes);
void nodes_sort_forward_within_layer(int layer_index, const QList<std::shared_ptr<DAGOrderHelper>> &nodes);
void graph_adjust_nodes_backward(const QList<std::shared_ptr<DAGOrderHelper>>& total_nodes);
QList<std::shared_ptr<DAGOrderHelper>> layer_adjust_via_next_sibling(int curr_layer, const QList<std::shared_ptr<DAGOrderHelper>>& total_nodes);
void node_adjust_via_next_sibling(std::shared_ptr<DAGOrderHelper> curr_node, const QList<std::shared_ptr<DAGOrderHelper>>& total_nodes);