private Graph < Module > buildGraph ( Map < Module , Set < Module > > edges ) { Graph . Builder < Module > builder = new Graph . Builder <> ( ) ; Set < Module > visited = new HashSet <> ( ) ; Deque < Module > deque = new LinkedList <> ( ) ; edges . entrySet ( ) . stream ( ) . forEach ( e -> { Module m = e . getKey ( ) ; deque . add ( m ) ; e . getValue ( ) . stream ( ) . forEach ( v -> { deque . add ( v ) ; builder . addEdge ( m , v ) ; } ) ; } ) ; // read requires transitive from ModuleDescriptor Module source ; while ( ( source = deque . poll ( ) ) != null ) { if ( visited . contains ( source ) ) continue ; visited . add ( source ) ; builder . addNode ( source ) ; Module from = source ; requiresTransitive ( from ) . forEach ( m -> { deque . add ( m ) ; builder . addEdge ( from , m ) ; } ) ; } return builder . build ( ) ; }
Build a graph of module from the given dependences .