Exemple #1
0
//to be called AFTER calling read(G, AG)
bool GmlParser::readAttributedCluster(Graph &G, ClusterGraph& CG,
									   ClusterGraphAttributes& ACG)
{
	OGDF_ASSERT(&CG.getGraph() == &G)


	//now we need the cluster object
	GmlObject *rootObject = m_objectTree;
	for(; rootObject; rootObject = rootObject->m_pBrother)
		if (id(rootObject) == rootClusterPredefKey) break;

	if(rootObject == 0)
		return true;

	if (id(rootObject) != rootClusterPredefKey) 
	{
		setError("missing rootcluster key");
		return false;
	}

	if (rootObject->m_valueType != gmlListBegin) return false;

	attributedClusterRead(rootObject, CG, ACG);

	return true;
}//readAttributedCluster
ClusterGraph::ClusterGraph(const ClusterGraph &C)
	: GraphObserver(&(C.getGraph())), m_clusterIdCount(0),m_postOrderStart(0),
	  m_rootCluster(0), m_nClusters(0),
	  m_lcaNumber(0), m_lcaSearch(0), m_vAncestor(0), m_wAncestor(0),
	  m_allowEmptyClusters(1), m_updateDepth(false), m_depthUpToDate(false)
{
	shallowCopy(C);
	m_clusterArrayTableSize = C.m_clusterArrayTableSize;
}
Exemple #3
0
void CPlanarSubClusteredST::initialize(const ClusterGraph& CG)
{
	//initialize "call-global" info arrays
	m_allocCluster.init(CG, nullptr);
	//edge status
#if 0
	m_edgeStatus.init(CG.getGraph(), 0);
#endif
	//edge to rep edge
	m_repEdge.init(CG, nullptr);
	//nodes and clusters to rep nodes
	m_cRepNode.init(CG, nullptr);
	m_vRepNode.init(CG, nullptr);
}
// true <=> C is C-connected
bool isCConnected(const ClusterGraph &C)
{
	if(C.getGraph().empty())
		return true;

	Graph G;
	ClusterGraph Cp(C,G);


	cluster root = Cp.rootCluster();
	SListPure<node>   compNodes;
	NodeArray<bool> mark(G,false);
	return cConnectTest(Cp,root,mark,G);
}
Exemple #5
0
//the clustergraph has to be initialized on G!!,
//no clusters other then root cluster may exist, which holds all nodes
bool GmlParser::readCluster(Graph &G, ClusterGraph& CG)
{
	OGDF_ASSERT(&CG.getGraph() == &G)

	//now we need the cluster object
	GmlObject *rootObject = m_objectTree;
	for(; rootObject; rootObject = rootObject->m_pBrother)
		if (id(rootObject) == rootClusterPredefKey) break;

	//we have to check if the file does really contain clusters
	//otherwise, rootcluster will suffice
	if (rootObject == 0) return true;
	if (id(rootObject) != rootClusterPredefKey) 
	{
		setError("missing rootcluster key");
		return false;
	}

	if (rootObject->m_valueType != gmlListBegin) return false;

	clusterRead(rootObject, CG);

	return true;
}//read clustergraph
Exemple #6
0
void CPlanarSubClusteredGraph::call(const ClusterGraph &CGO, 
									EdgeArray<bool>& inSub, //original edges in subgraph?
									List<edge>& leftOver,   //original edges not in subgraph
									EdgeArray<double>& edgeWeight) //prefer lightweight edges
{
	leftOver.clear();

	//we compute a c-planar subclustered graph by calling
	//CPlanarSubClusteredST and then perform reinsertion on
	//a copy of the computed subclustered graph
	//initialize "call-global" info arrays
	//edge status
	const Graph& origG = CGO.getGraph();
	m_edgeStatus.init(origG, 0);
	
	CPlanarSubClusteredST CPST;
	if (edgeWeight.valid())
		CPST.call(CGO, inSub, edgeWeight);
	else
		CPST.call(CGO, inSub);

	//now construct the copy
	//we should create a clusterGraph copy function that
	//builds a clustergraph upon a subgraph of the 
	//original graph, preliminarily use fullcopy and delete edges
	
	ClusterArray<cluster> clusterCopy(CGO);
	NodeArray<node> nodeCopy(origG);
	EdgeArray<edge> edgeCopy(origG);
	Graph testG;
	ClusterGraph CG(CGO, testG, clusterCopy, nodeCopy, edgeCopy);

	CconnectClusterPlanar CCCP;

	//-------------------------------------
	//perform reinsertion of leftover edges
	//fill list of uninserted edges

	EdgeArray<bool> visited(origG,false);

	//delete the non-ST edges
	edge e;
	forall_edges(e, origG)
	{
		if (!inSub[e])
		{
			leftOver.pushBack(e); //original edges
			testG.delEdge(edgeCopy[e]);
		}//if
	}//foralledges

	//todo: cope with preferred edges
	//simple reinsertion strategy: just iterate over list and test
	ListIterator<edge> itE = leftOver.begin();
	while (itE.valid())
	{
		//testG=CG.getGraph()
		edge newCopy = testG.newEdge(nodeCopy[(*itE)->source()],
											 nodeCopy[(*itE)->target()]);
		edgeCopy[*itE] = newCopy;

		bool cplanar = CCCP.call(CG);


		if (!cplanar) 
		{
			testG.delEdge(newCopy);
			itE++;
		}//if
		else
		{
			ListIterator<edge> itDel = itE;
			itE++;
			leftOver.del(itDel);
		}
	}//while

	/*
	ListConstIterator<edge> it;
	for(it = preferedEdges.begin(); it.valid(); ++it)
	{
		edge eG = *it;
		visited[eG] = true;

		edge eH = testG.newEdge(toTestG[eG->source()],toTestG[eG->target()]);

		if (preferedImplyPlanar == false && pm.planarityTest(H) == false) {
			testG.delEdge(eH);
			delEdges.pushBack(eG);
		}
	}
	*/

	
}//call