void BarycenterPlacer::placeOneNode(MultilevelGraph &MLG) { node merged = MLG.undoLastMerge(); double x = 0.0; double y = 0.0; double i = 0.0; for(adjEntry adj : merged->adjEdges) { if(m_weightedPositions) { double weight = 1.0 / MLG.weight(adj->theEdge()); i = i + weight; x += MLG.x(adj->twinNode()) * weight; y += MLG.y(adj->twinNode()) * weight; } else { i = i + 1.f; x += MLG.x(adj->twinNode()); y += MLG.y(adj->twinNode()); } } OGDF_ASSERT(i > 0); x = x / i; y = y / i; MLG.x(merged, x + ((m_randomOffset)?(float)randomDouble(-1.0, 1.0):0.f)); MLG.y(merged, y + ((m_randomOffset)?(float)randomDouble(-1.0, 1.0):0.f)); }
void ModularMultilevelMixer::call(MultilevelGraph &MLG) { const Graph &G = MLG.getGraph(); m_errorCode = ercNone; clock_t time = clock(); if ((m_multilevelBuilder.valid() == false || m_initialPlacement.valid() == false) && m_oneLevelLayoutModule.valid() == false) { OGDF_THROW(AlgorithmFailureException); } if (m_fixedEdgeLength > 0.0) { edge e; forall_edges(e,G) { MLG.weight(e, m_fixedEdgeLength); }