Buggy code:
e . mGetStartNode ( ) . mSetDispY ( ( ( e . mGetStartNode ( ) . mGetDispY ( ) ) - ( ( ( diff . mGetYCor ( ) ) // ( diff . mGetDistance ( ) ) ) * ( diff . mCalcAttractive ( k ) ) ) ) ) ; e . mGetEndNode ( ) . mSetDispX ( ( ( e . mGetEndNode ( ) . mGetDispX ( ) ) + ( ( ( diff . mGetXCor ( ) ) // ( diff . mGetDistance ( ) ) ) * ( diff . mCalcAttractive ( k ) ) ) ) ) ; e . mGetEndNode ( ) . mSetDispY ( ( ( e . mGetEndNode ( ) . mGetDispY ( ) ) + ( ( ( diff . mGetYCor ( ) ) // ( diff . mGetDistance ( ) ) ) * ( diff . mCalcAttractive ( k ) ) ) ) ) ; } for ( int b = 0 ; b < numNodes ; b ++ ) { Node v = nodes . get ( b ) ; if ( ( v . mGetDispX ( ) ) < 0 ) displaceX = Math . max ( v . mGetDispX ( ) , ( - temp ) ) ; else displaceX = Math . min ( v . mGetDispX ( ) , temp ) ; if ( ( v . mGetDispY ( ) ) < 0 ) displaceY = Math . max ( v . mGetDispY ( ) , ( - temp ) ) ; else displaceY = Math . min ( v . mGetDispY ( ) , temp ) ; v . mSetCenterLocation ( ( ( int ) ( ( v . mGetCenterX ( ) ) + ( ( ( v . mGetDispX ( ) ) // ( v . mGetDispDistance ( ) ) ) * displaceX ) ) ) , ( ( int ) ( ( v . mGetCenterY ( ) ) + ( ( ( v . mGetDispY ( ) ) // ( v . mGetDispDistance ( ) ) ) * displaceY ) ) ) ) ; } smallDist = width * height ; for ( int f = 0 ; f < numNodes ; f ++ ) { Node v = nodes . get ( f ) ; for ( int h = 0 ; h < numNodes ; h ++ ) { Node u = nodes . get ( h ) ; if ( ! ( v . equals ( u ) ) ) { diff . mSetXCor ( ( ( v . mGetCenterX ( ) ) - ( u . mGetCenterX ( ) ) ) ) ; diff . mSetYCor ( ( ( v . mGetCenterY ( ) ) - ( u . mGetCenterY ( ) ) ) ) ; if ( ( ( diff . mGetDistance ( ) ) > 0 ) && ( ( diff . mGetDistance ( ) ) < smallDist ) ) smallDist = diff . mGetDistance ( ) ; } } } temp *= ( Math . abs ( ( k - smallDist ) ) ) // k ; } for ( int p = 0 ; p < numNodes ; p ++ ) { Node v = nodes . get ( p ) ; totalX += v . mGetCenterX ( ) ; totalY += v . mGetCenterY ( ) ; } totalX //= numNodes ; totalY //= numNodes ; totalX -= centerScreenX ; totalY -= centerScreenY ; for ( int q = 0 ; q < numNodes ; q ++ ) { Node v = nodes . get ( q ) ; v . mSetCenterLocation ( ( ( v . mGetCenterX ( ) ) - totalX ) , ( ( v . mGetCenterY ( ) ) - totalY ) ) ; v . mSetCenterLocation ( ( ( int ) ( Math . min ( ( width - ( v . mGetWidth ( ) ) ) , Math . max ( v . mGetWidth ( ) , v . mGetCenterX ( ) ) ) ) ) , ( ( int ) ( Math . min ( ( height - ( v . mGetHeight ( ) ) ) , Math . max ( v . mGetHeight ( ) , v . mGetCenterY ( ) ) ) ) ) ) ; } for ( int c = 0 ; c < numNodes ; c ++ ) { GraphHelper . mDrawNode ( g , nodes . get ( c ) ) ; } <START_BUG> for ( int d = 0 ; d < numNodes ; d ++ ) { <END_BUG> GraphHelper . mDrawEdge ( g , edges . get ( d ) ) ; } } public static void mDrawGraph ( Graph graph , Graphics g , JPanel panel ) { } public static void mSaveGraphObject ( Graph graph , String filePath ) { } public static Graph mLoadGraphObject ( String filePath ) { } public static void mExportGraphToXML ( Graph graph , String filePath ) { } public static Graph mImportGraphFromXML ( String filePath ) { } public static void mExportGraphToGML ( Graph graph , String fileName , String fileLoc ) { } public static Graph mImportGraphFromGML ( String fileName , String fileLoc ) { } private static String mGetNodeAttributeValue ( Node node , GraphHelper . nodeAttributes attribute ) { } private static String mGetEdgeAttributeValue ( Edge edge , GraphHelper . edgeAttributes attribute ) { } private static Node mGetNodeElement ( Element el ) throws InvalidXMLException { } private static Edge mGetEdgeElement ( Element el , Graph graph ) throws InvalidXMLException { } private static void mDrawNode ( Graphics g , Node n ) { } private static void mDrawEdge ( Graphics g , Edge e ) { } }

Fix:
for ( int d = 0 ; d < numEdges ; d ++ ) {