コード例 #1
0
ファイル: MaxCPlanarMaster.cpp プロジェクト: ogdf/ogdf
double MaxCPlanarMaster::heuristicInitialLowerBound()
{
	double lbound = 0.0;
	//In case we only have a single (root) cluster, we can
	//use the result of a fast Max Planar Subgraph heuristic
	//to initialize the lower bound
	if ( (m_C->numberOfClusters() == 1) && (m_mpHeuristic) )
	{
		//we run both heuristics that currently exist in OGDF
		//MaxSimple
		MaximalPlanarSubgraphSimple<int> simpleHeur;
		List<edge> delEdgesList;
		PlanarSubgraphFast<int> fastHeur;
		fastHeur.runs(m_fastHeuristicRuns);
		List<edge> delEdgesListFast;
		List<edge> *delEdges;

		if(m_pCost == nullptr) {
			simpleHeur.call(*m_G, delEdgesList);
			fastHeur.call(*m_G, delEdgesListFast);

			delEdges = delEdgesList.size() < delEdgesListFast.size() ? &delEdgesList : &delEdgesListFast;
			lbound = m_G->numberOfEdges()-min(delEdgesList.size(), delEdgesListFast.size());
		} else {
			simpleHeur.call(*m_G, *m_pCost, delEdgesList);
			fastHeur.call(*m_G, *m_pCost, delEdgesListFast);

			int total = 0;
			for(edge e : m_G->edges) {
				total += (*m_pCost)[e];
			}

			int del = 0;
			for(edge e : delEdgesList) {
				del += (*m_pCost)[e];
			}

			int delFast = 0;
			for(edge e : delEdgesListFast) {
				delFast += (*m_pCost)[e];
			}

			delEdges = del < delFast ? &delEdgesList : &delEdgesListFast;
			lbound = total - min(del, delFast);
		}

		m_deletedOriginalEdges.clear();
		for(edge e : *delEdges) {
			m_deletedOriginalEdges.pushBack(e);
		}

		if (!isConnected(*m_G)) lbound = lbound-1.0; //#edges*epsilon
	}
	return lbound;
}
コード例 #2
0
ファイル: MaxCPlanar_Master.cpp プロジェクト: lncosie/ogdf
double MaxCPlanarMaster::heuristicInitialLowerBound()
{
	double lbound = 0.0;
	//In case we only have a single (root) cluster, we can
	//use the result of a fast Max Planar Subgraph heuristic
	//to initialize the lower bound
	if ( (m_C->numberOfClusters() == 1) && (m_mpHeuristic) )
	{
		//we run both heuristics that currently exist in OGDF
		//MaxSimple
		MaximalPlanarSubgraphSimple simpleHeur;
		List<edge> delEdgesList;
		simpleHeur.call(*m_G, delEdgesList);
		FastPlanarSubgraph fastHeur;
		fastHeur.runs(m_fastHeuristicRuns);
		List<edge> delEdgesListFast;
		fastHeur.call(*m_G, delEdgesListFast);
		lbound = m_G->numberOfEdges()-min(delEdgesList.size(), delEdgesListFast.size());

		if (!isConnected(*m_G)) lbound = lbound-1.0; //#edges*epsilon
	}//if heuristics used
	return lbound;
}//heuristicInitialLowerBound