SubgraphPlanarizer::SubgraphPlanarizer() { FastPlanarSubgraph* s= new FastPlanarSubgraph(); s->runs(100); m_subgraph.set(s); VariableEmbeddingInserter* i = new VariableEmbeddingInserter(); i->removeReinsert(VariableEmbeddingInserter::rrAll); m_inserter.set(i); m_permutations = 1; m_setTimeout = true; }
// default constructor SubgraphPlanarizer::SubgraphPlanarizer() { FastPlanarSubgraph* s = new FastPlanarSubgraph(); s->runs(64); m_subgraph.set(s); VariableEmbeddingInserter *pInserter = new VariableEmbeddingInserter(); pInserter->removeReinsert(rrAll); m_inserter.set(pInserter); m_permutations = 1; m_setTimeout = true; #ifdef OGDF_MEMORY_POOL_NTS m_maxThreads = 1; #else m_maxThreads = System::numberOfProcessors(); #endif }
int main() { Graph G; GraphAttributes GA(G, GraphAttributes::nodeGraphics | GraphAttributes::edgeGraphics | GraphAttributes::nodeLabel | GraphAttributes::edgeStyle | GraphAttributes::nodeStyle | GraphAttributes::nodeTemplate); GraphIO::readGML(GA, G, "ERDiagram.gml"); PlanarizationLayout pl; SubgraphPlanarizer *crossMin = new SubgraphPlanarizer; FastPlanarSubgraph *ps = new FastPlanarSubgraph; ps->runs(100); VariableEmbeddingInserter *ves = new VariableEmbeddingInserter; ves->removeReinsert(rrAll); crossMin->setSubgraph(ps); crossMin->setInserter(ves); EmbedderMinDepthMaxFaceLayers *emb = new EmbedderMinDepthMaxFaceLayers; pl.setEmbedder(emb); OrthoLayout *ol = new OrthoLayout; ol->separation(20.0); ol->cOverhang(0.4); pl.setPlanarLayouter(ol); pl.call(GA); GraphIO::writeGML(GA, "ERDiagram-layout.gml"); return 0; }
CRevisionGraphWnd::CRevisionGraphWnd() : CWnd() , m_SelectedEntry1(nullptr) , m_SelectedEntry2(nullptr) , m_HeadNode(nullptr) , m_pDlgTip(nullptr) , m_nFontSize(12) , m_bTweakTrunkColors(true) , m_bTweakTagsColors(true) , m_fZoomFactor(DEFAULT_ZOOM) , m_ptRubberEnd(0,0) , m_ptMoveCanvas(0,0) , m_bShowOverview(false) , m_parent(nullptr) , m_hoverIndex(nullptr) , m_hoverGlyphs (0) , m_tooltipIndex(nullptr) , m_showHoverGlyphs (false) , m_bIsCanvasMove(false) , m_previewWidth(0) , m_previewHeight(0) , m_previewZoom(1) , m_ullTicks(0) , m_logEntries(&m_LogCache) , m_bCurrentBranch(false) , m_bLocalBranches(FALSE) { memset(&m_lfBaseFont, 0, sizeof(LOGFONT)); std::fill_n(m_apFonts, MAXFONTS, nullptr); WNDCLASS wndcls; HINSTANCE hInst = AfxGetInstanceHandle(); #define REVGRAPH_CLASSNAME _T("Revgraph_windowclass") if (!(::GetClassInfo(hInst, REVGRAPH_CLASSNAME, &wndcls))) { // otherwise we need to register a new class wndcls.style = CS_DBLCLKS | CS_OWNDC; wndcls.lpfnWndProc = ::DefWindowProc; wndcls.cbClsExtra = wndcls.cbWndExtra = 0; wndcls.hInstance = hInst; wndcls.hIcon = nullptr; wndcls.hCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW); wndcls.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1); wndcls.lpszMenuName = nullptr; wndcls.lpszClassName = REVGRAPH_CLASSNAME; RegisterClass(&wndcls); } m_bTweakTrunkColors = CRegDWORD(_T("Software\\TortoiseGit\\RevisionGraph\\TweakTrunkColors"), TRUE) != FALSE; m_bTweakTagsColors = CRegDWORD(_T("Software\\TortoiseGit\\RevisionGraph\\TweakTagsColors"), TRUE) != FALSE; m_szTip[0] = 0; m_wszTip[0] = 0; m_GraphAttr.init(this->m_Graph, ogdf::GraphAttributes::nodeGraphics | ogdf::GraphAttributes::edgeGraphics | ogdf:: GraphAttributes::nodeLabel | ogdf::GraphAttributes::nodeColor | ogdf::GraphAttributes::edgeColor | ogdf::GraphAttributes::edgeStyle | ogdf::GraphAttributes::nodeStyle | ogdf::GraphAttributes::nodeTemplate); m_SugiyamLayout.setRanking(::new ogdf::OptimalRanking()); m_SugiyamLayout.setCrossMin(::new ogdf::MedianHeuristic()); double pi = 3.1415926; m_ArrowCos = cos(pi/8); m_ArrowSin = sin(pi/8); this->m_ArrowSize = 8; #if 0 ogdf::node one = this->m_Graph.newNode(); ogdf::node two = this->m_Graph.newNode(); ogdf::node three = this->m_Graph.newNode(); ogdf::node four = this->m_Graph.newNode(); m_GraphAttr.width(one)=100; m_GraphAttr.height(one)=200; m_GraphAttr.width(two)=100; m_GraphAttr.height(two)=100; m_GraphAttr.width(three)=100; m_GraphAttr.height(three)=20; m_GraphAttr.width(four)=100; m_GraphAttr.height(four)=20; m_GraphAttr.labelNode(one)="One"; m_GraphAttr.labelNode(two)="Two"; m_GraphAttr.labelNode(three)="three"; this->m_Graph.newEdge(one, two); this->m_Graph.newEdge(one, three); this->m_Graph.newEdge(two, four); this->m_Graph.newEdge(three, four); #endif FastHierarchyLayout *pOHL = ::new FastHierarchyLayout; //It will auto delte when m_SugiyamLayout destory pOHL->layerDistance(30.0); pOHL->nodeDistance(25.0); m_SugiyamLayout.setLayout(pOHL); #if 0 //this->m_OHL.layerDistance(30.0); //this->m_OHL.nodeDistance(25.0); //this->m_OHL.weightBalancing(0.8); m_SugiyamLayout.setLayout(&m_OHL); m_SugiyamLayout.call(m_GraphAttr); #endif #if 0 PlanarizationLayout pl; FastPlanarSubgraph *ps = ::new FastPlanarSubgraph; ps->runs(100); VariableEmbeddingInserter *ves = ::new VariableEmbeddingInserter; ves->removeReinsert(EdgeInsertionModule::rrAll); pl.setSubgraph(ps); pl.setInserter(ves); EmbedderMinDepthMaxFaceLayers *emb = ::new EmbedderMinDepthMaxFaceLayers; pl.setEmbedder(emb); OrthoLayout *ol =::new OrthoLayout; ol->separation(20.0); ol->cOverhang(0.4); ol->setOptions(2+4); ol->preferedDir(OrthoDir::odEast); pl.setPlanarLayouter(ol); pl.call(m_GraphAttr); node v; forall_nodes(v,m_Graph) { TRACE(_T("node x %f y %f %f %f\n"),/* m_GraphAttr.idNode(v), */ m_GraphAttr.x(v), m_GraphAttr.y(v), m_GraphAttr.width(v), m_GraphAttr.height(v) ); }
//************************************************************* // call for SubgraphPlanarizer // returns crossing number int SimDrawCaller::callSubgraphPlanarizer(int cc, int numberOfPermutations) { // transfer edge costs if existent EdgeArray<int> ec(*m_G, 1); if(m_GA->attributes() & GraphAttributes::edgeIntWeight) { edge e; forall_edges(e,*m_G) ec[e] = m_GA->intWeight(e); } // initialize updateESG(); int crossNum = 0; PlanRep PR(*m_G); // actual call for connected component cc SubgraphPlanarizer SP; VariableEmbeddingInserter* vei = new VariableEmbeddingInserter; vei->removeReinsert(rrIncremental); SP.setInserter(vei); SP.permutations(numberOfPermutations); SP.call(PR, cc, crossNum, &ec, 0, m_esg); // insert all dummy nodes into original graph *m_G NodeArray<node> newOrigNode(PR); node vPR; forall_nodes(vPR, PR) { if(PR.isDummy(vPR)) { node vOrig = m_G->newNode(); newOrigNode[vPR] = vOrig; m_SD->isDummy(vOrig) = true; } else newOrigNode[vPR] = PR.original(vPR); //original nodes are saved } // insert all edges incident to dummy nodes into *m_G EdgeArray<bool> toBeDeleted(*m_G, false); EdgeArray<bool> visited(PR, false); forall_nodes(vPR, PR) { if(PR.isDummy(vPR)) { node vNewOrig = newOrigNode[vPR]; //lebt in *m_G edge e; forall_adj_edges(e, vPR) //lebt in PR { if(!visited[e]) { node w = e->opposite(vPR); //lebt in PR node wNewOrig = newOrigNode[w]; //lebt in *m_G edge eNewOrig = m_G->newEdge(vNewOrig,wNewOrig); m_GA->subGraphBits(eNewOrig) = m_GA->subGraphBits(PR.original(e)); toBeDeleted[PR.original(e)] = true; visited[e] = true; } } } }