public function renderGraph( $file )
    {
        $fp = fopen( $graphFile = '/tmp/arbit_class_graph.dot', 'w' );

        // Open Graph
        fwrite( $fp, "digraph G {\n\n\t
    node [
        fontname=Arial,
        fontcolor=\"#2e3436\",
        fontsize=10,

        style=filled,
        color=\"#2e3436\",
        fillcolor=\"#babdb6\"
    ];

    mindist = 0.4;
    rankdir=RL;
    splines  = true;
    overlap=false;\n\n" );

        // Group nodes by package
        $groups = array();
        foreach ( $this->nodes as $name => $data )
        {
            $package = ( $data['package'] === false ? 'Core' : $data['package'] );
            $groups[$package][] = $name;
        }

        // Add nodes to graph
        foreach ( $groups as $group => $classes )
        {
            fwrite( $fp, sprintf( "\tsubgraph cluster_%s {\n\t\tlabel=\"%s\";\n\n", $group, $group ) );
            foreach ( $classes as $name )
            {
                $data = $this->nodes[$name];

                // Skip exception classes
                if ( strpos( $name, 'Exception' ) !== false )
                {
                    continue;
                }

                fwrite( $fp, sprintf( "\t\tnode [\n\t\t\tlabel = \"%s\",\n\t\t\tshape = \"Mrecord\",\n\t\t\tfillcolor=\"%s\"\n\t\t] \"%s\";\n\n",
                    $name . ' | ' . implode( ' | ', $data['functions'] ),
                    ( $data['type'] === 'class' ? '#eeeeef' : '#729fcf' ),
                    $name
                ) );
            }
            fwrite( $fp, sprintf( "\t}\n\n" ) );
        }

        // Add node connections
        foreach ( $this->edges as $src => $dsts )
        {
            if ( !is_array( $dsts ) ||
                 ( strpos( $src, 'Exception' ) !== false ) )
            {
                // Skip edges without destinations and exception classes
                continue;
            }

            foreach ( $dsts as $dst )
            {
                fwrite( $fp, sprintf( "\t\"%s\" -> \"%s\"\n", $src, $dst ) );
            }
        }

        fwrite( $fp, "\n}\n\n" );
        fclose( $fp );

        // Render graph
        shell_exec( 'dot -Tpng -o ' . escapeshellarg( $file ) . ' ' . escapeshellarg( $graphFile ) );
        unlink( $graphFile );
    }