Esempio n. 1
0
//gives each edge in m_G a random edgeSubGraphs value
//works with two graphs
void SimDrawCreator::randomESG2(int doubleESGProbability)
{
	OGDF_ASSERT( doubleESGProbability <= 100 );
	OGDF_ASSERT( doubleESGProbability >= 0 );

	clearESG();

	for(edge e : m_G->edges)
	{
		//all edges have a chance of doubleESGProbability (in percent)
		//to belong to both input graphs
		int doubleESGRandom = rand() % 100;
		if(doubleESGRandom < doubleESGProbability)
		{
			m_GA->addSubGraph(e, 0);
			m_GA->addSubGraph(e, 1);
		}
		else
		{
			// all edges, which do not belong to both input graphs
			// have a 50/50 chance to belong to graph 0 or to graph 1
			int singleESGRandom = rand() % 2;
			m_GA->addSubGraph(e, singleESGRandom);
		}
	}
}
Esempio n. 2
0
//*************************************************************
//gives each edge in m_G a random edgeSubGraphs value
//works with three graphs
void SimDrawCreator::randomESG3(int doubleESGProbability, int tripleESGProbability)
{
	OGDF_ASSERT( doubleESGProbability + tripleESGProbability <= 100 );
	OGDF_ASSERT( doubleESGProbability >= 0 );
	OGDF_ASSERT( tripleESGProbability >= 0 );

	clearESG();

	for(edge e : m_G->edges)
	{
		/*All edges have a chance of tripleESGProbability (in percent)
		to belong to all three graphs.*/
		int multipleESGRandom = rand() % 100;
		if(multipleESGRandom < doubleESGProbability + tripleESGProbability)
		{
			m_GA->addSubGraph(e,0);
			m_GA->addSubGraph(e,1);
			m_GA->addSubGraph(e,2);

			/*Furthermore, all edges have a chance of doubleESGProbability
			to belong to two of three graphs.*/
			if(multipleESGRandom >= tripleESGProbability)
			{
				int removeESGRandom = rand() % 3;
				m_GA->removeSubGraph(e, removeESGRandom);
			}
		}
		else
		{
			//all edges, which do not belong to two or three graphs
			//have a 33 percent chance to belong to one of the three graphs.
			int singleESGRandom = rand() % 3;
			m_GA->addSubGraph(e, singleESGRandom);
		}
	}

}//end randomESG3