private void addNext( DirectedMultigraph graph, Duct previous ) { if( previous instanceof Fork ) { for( Duct next : ( (Fork) previous ).getAllNext() ) { if( next == null || next instanceof Extent ) continue; graph.addVertex( next ); if( graph.containsEdge( previous, next ) ) continue; graph.addEdge( previous, next ); addNext( graph, next ); } } else { Duct next = previous.getNext(); if( next == null || next instanceof Extent ) return; graph.addVertex( next ); if( graph.containsEdge( previous, next ) ) return; graph.addEdge( previous, next ); addNext( graph, next ); } } }