private void iterateOverOutboundEdges(Vertex vertex) throws GraphException { Iterator<Edge<Integer, Vertex>> iterator = graph.getOutbound(vertex); while (iterator.hasNext()) { Edge<Integer, Vertex> edge = iterator.next(); if (!exploredEdges.contains(edge)) if (!exploredVertices.contains(edge.getDestination())) { exploredEdges.add(edge); depthFirst(edge.getDestination()); } } }
public void verticeMousePressed(MouseEvent e) { if (e.getClickCount() == 2) { for (Edge edge : graph.getEdges()) { if (edge.contains(e.getPoint())) { String input = DialogHelpers.showInPutDialog("Input", "Enter cost: "); try { int number = Integer.parseInt(input); edge.setCost(number); repaint(); } catch (NumberFormatException e1) { // e1.printStackTrace(); } } } return; } if (SwingUtilities.isLeftMouseButton(e)) { for (Vertex vertex : graph.getVertices()) { if (vertex.contains(e.getPoint())) { currentVertex = vertex; previousPoint = e.getPoint(); return; } } for (Edge edge : graph.getEdges()) { if (edge.contains(e.getPoint())) {} } } else if (SwingUtilities.isRightMouseButton(e)) { for (Vertex vertex : graph.getVertices()) { if (vertex.contains(e.getPoint())) { currentVertex = vertex; tempLine = new Line(); tempLine.setPoint1(e.getPoint()); } } } }