Asegurar la correcta generación de matriz de adyacencia procesamiento JGraphX figura deriva modelo de red de ventilación que resolver la fig.

La figura JGraphX ​​red de ventilación genera, refleja la topología de la red del viento, pero el nodo de borde mxcell Jgraph aunque correcta, pero donde la etiqueta no es de los corresponde nodo,

La razón puede ser debido a problemas metodológicos al insertar lado,


Por lo tanto, cuando la red de la figura resolver figura deriva, debe manipularse como sigue:

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());



Publicado 34 artículos originales · ganado elogios 9 · Vistas a 90000 +

Supongo que te gusta

Origin blog.csdn.net/tianyatest/article/details/47083151
Recomendado
Clasificación