本文主要是介绍JGraphX生成的通风网络图导出为解算图模型时确保邻接矩阵正确的处理,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
JGraphX生成的通风网络图,反映了风网的拓扑关系,但是Jgraph中的edge的节点mxcell虽然是正确的,但是其中的Node却不是与label对应的,
其原因可能是由于插入边时的方法问题,
所以在网络图导出为解算图时,应进行如下处理:
mxgraph.selectVertices();Object[] vcells = graphComponent.getGraph().getSelectionCells();NodeList nl = new NodeList();for (int i = 0; i < vcells.length; i++) {mxCell cell = (mxCell) vcells[i];Node n = (Node) cell.getValue();n.setNodeID(Integer.valueOf(cell.getId()));nl.add(n);}mxgraph.selectEdges();Object[] cells = graphComponent.getGraph().getSelectionCells();System.out.println("分支数:" + cells.length);mxAnalysisGraph aGraph = new mxAnalysisGraph();aGraph.setGraph(mxgraph);boolean isConnected = mxGraphStructure.isConnected(aGraph);if (!isConnected) {JOptionPane.showMessageDialog(null, "网络图不是连通图,请检查!", "错误",JOptionPane.ERROR_MESSAGE);}EdgeList el = new EdgeList();mxgraph.refresh();graphComponent.updateUI();for (int i = 0; i < cells.length; i++) {mxCell c = (mxCell) cells[i];VentEdge ve = (VentEdge) c.getValue();if (!ve.isGudingQ()) {ve.setAirH(0);ve.setAirQ(0);ve.setNT(0);}int outdegree = mxGraphStructure.outdegree(aGraph,c.getSource());// System.out.println(outdegree+".............");Node bn = (Node) c.getSource().getValue();Node nbn = nl.getNode(bn.getLabel());ve.setBnode(nbn);Node en = (Node) c.getTarget().getValue();Node nen = nl.getNode(en.getLabel());ve.setEnode(nen);// if (ve.getLabel() == null || ve.getLabel().equals(""))ve.setLabel(ve.getBnode() + "--->" + ve.getEnode());System.out.println(ve);System.out.println(ve.getBnode() + "--" + ve.getEnode()+ " " + ve.getR() + " " + ve.getAirH());
这篇关于JGraphX生成的通风网络图导出为解算图模型时确保邻接矩阵正确的处理的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!