Exemplo n.º 1
0
//*************************************************************
//returns number of basic graphs
//
int SimDraw::numberOfBasicGraphs() const
{
    if(m_G.empty())
	return 0;
    return maxSubGraph()+1;

}//end numberOfBasicGraphs
Exemplo n.º 2
0
//*************************************************************
//adds new GraphAttributes to m_G if maxSubgraph() < 32
//
bool SimDraw::addGraphAttributes(const GraphAttributes & GA)
{
	if(maxSubGraph() >= 31)
		return false;

	//if(compareBy() == label)
	OGDF_ASSERT((compareBy() != label) || (m_GA.attributes() & GraphAttributes::edgeLabel));

	int max = numberOfBasicGraphs();
	bool foundEdge = false;
	//node v;
	//edge e, f;
	Graph G = GA.constGraph();

	for(edge e : G.edges) {
		for(edge f : m_G.edges) {
			if (compare(m_GA, f->source(), GA, e->source())
			 && compare(m_GA, f->target(), GA, e->target())) {
				foundEdge = true;
				m_GA.addSubGraph(f,max);
			}
		}

		if (!foundEdge) {
			node s, t;
			bool srcFound = false;
			bool tgtFound = false;
			for(node v : m_G.nodes) {
				if (compare(m_GA, v, GA, e->source())) {
					s = v;
					srcFound = true;
				}
				if (compare(m_GA, v, GA, e->target())) {
					t = v;
					tgtFound = true;
				}
			}

			if (!srcFound)
				s = m_G.newNode(e->source()->index());

			if (!tgtFound)
				t = m_G.newNode(e->target()->index());

			edge d = m_G.newEdge(s, t);
			if(compareBy() == label)
				m_GA.label(d) = GA.label(e);

			m_GA.addSubGraph(d, max);
		}
	}
	return true;

}// end addGraphAttributes