public void initAlgo() { graph = graphModel.getHierarchicalGraphVisible(); initedView = graph.getView().getViewId(); setConverged(false); level = 0; while (true) { int graphSize = graph.getTopNodes().toArray().length; coarseningStrategy.coarsen(graph); level++; int newGraphSize = graph.getTopNodes().toArray().length; if (newGraphSize < getMinSize() || newGraphSize > graphSize * getMinCoarseningRate()) { break; } } Layout random = new RandomLayout(1000); random.setGraphModel(graphModel); random.initAlgo(); random.goAlgo(); initYifanHu(); }
public void goAlgo() { HierarchicalGraph newGraph = graphModel.getHierarchicalGraphVisible(); if (newGraph.getView().getViewId() != initedView) { setConverged(true); layout.endAlgo(); endAlgo(); return; } this.graph = newGraph; if (layout.canAlgo()) { layout.goAlgo(); } else { layout.endAlgo(); if (level > 0) { coarseningStrategy.refine(graph); level--; initYifanHu(); } else { setConverged(true); layout = null; } } }
public void updateWorld() { // System.out.println("update world"); cacheMarker++; GraphModel graphModel = controller.getModel(); if (graphModel == null) { engine.worldUpdated(cacheMarker); return; } if (gm != null && gm != graphModel) { reset(); } gm = graphModel; HierarchicalGraph graph; if (graphModel.isDirected()) { undirected = false; graph = graphModel.getHierarchicalDirectedGraphVisible(); } else if (graphModel.isUndirected()) { undirected = true; graph = graphModel.getHierarchicalUndirectedGraphVisible(); } else if (graphModel.isMixed()) { undirected = false; graph = graphModel.getHierarchicalMixedGraphVisible(); } else { undirected = false; graph = graphModel.getHierarchicalDirectedGraphVisible(); } if (dynamicModel == null) { DynamicController dynamicController = Lookup.getDefault().lookup(DynamicController.class); dynamicModel = dynamicController.getModel(); } graphView = graph.getView().getViewId(); ModelClass[] object3dClasses = engine.getModelClasses(); graph.readLock(); ModelClass nodeClass = object3dClasses[AbstractEngine.CLASS_NODE]; if (nodeClass.isEnabled() && (graph.getNodeVersion() > nodeVersion || modeManager.requireModeChange())) { updateNodes(graph); nodeClass.setCacheMarker(cacheMarker); } ModelClass edgeClass = object3dClasses[AbstractEngine.CLASS_EDGE]; if (edgeClass.isEnabled() && (graph.getEdgeVersion() > edgeVersion || modeManager.requireModeChange())) { updateEdges(graph); updateMetaEdges(graph); edgeClass.setCacheMarker(cacheMarker); if (!undirected && vizConfig.isShowArrows()) { object3dClasses[AbstractEngine.CLASS_ARROW].setCacheMarker(cacheMarker); } } ModelClass potatoClass = object3dClasses[AbstractEngine.CLASS_POTATO]; if (potatoClass.isEnabled() && (graph.getNodeVersion() > nodeVersion || modeManager.requireModeChange())) { updatePotatoes(graph); potatoClass.setCacheMarker(cacheMarker); } nodeVersion = graph.getNodeVersion(); edgeVersion = graph.getEdgeVersion(); graph.readUnlock(); engine.worldUpdated(cacheMarker); }