public static void addConnectionToGraph(Connection connection, double connectionWeight, SimpleWeightedGraph<ConnectionPoint3D, DefaultWeightedEdge> graphToUpdate) { ConnectionPoint3D source = connection.getSourcePoint(); ConnectionPoint3D target = connection.getTargetPoint(); if (!source.epsilonEquals(target, 1.0e-3)) { graphToUpdate.addVertex(source); graphToUpdate.addVertex(target); DefaultWeightedEdge edge = new DefaultWeightedEdge(); graphToUpdate.addEdge(source, target, edge); graphToUpdate.setEdgeWeight(edge, connectionWeight); } }