lib/graph.js
function createGraph(modules, circular, config, options) {
	const g = graphviz.digraph('G');
	const nodes = {};
	const cyclicModules = circular.reduce((a, b) => a.concat(b), []);

	if (config.graphVizPath) {
		g.setGraphVizPath(config.graphVizPath);
	}

	Object.keys(modules).forEach((id) => {
		nodes[id] = nodes[id] || g.addNode(id);

		if (!modules[id].length) {
			setNodeColor(nodes[id], config.noDependencyColor);
		} else if (cyclicModules.indexOf(id) >= 0) {
			setNodeColor(nodes[id], config.cyclicNodeColor);
		}

		modules[id].forEach((depId) => {
			nodes[depId] = nodes[depId] || g.addNode(depId);

			if (!modules[depId]) {
				setNodeColor(nodes[depId], config.noDependencyColor);
			}

			g.addEdge(nodes[id], nodes[depId]);
		});
	});

	return new Promise((resolve, reject) => {
		g.output(options, resolve, (code, out, err) => {
			reject(new Error(err));
		});
	});
}
function createGraph(modules, circular, config, options) {
	const g = graphviz.digraph('G');
	const nodes = {};
	const cyclicModules = circular.reduce((a, b) => a.concat(b), []);

	if (config.graphVizPath) {
		g.setGraphVizPath(config.graphVizPath);
	}

	Object.keys(modules).forEach((id) => {
		nodes[id] = nodes[id] || g.addNode(id);

		if (!modules[id].length) {
			setNodeColor(nodes[id], config.noDependencyColor);
		} else if (cyclicModules.indexOf(id) >= 0) {
			setNodeColor(nodes[id], config.cyclicNodeColor);
		}

		modules[id].forEach((depId) => {
			nodes[depId] = nodes[depId] || g.addNode(depId);

			if (!modules[depId]) {
				setNodeColor(nodes[depId], config.noDependencyColor);
			}

			g.addEdge(nodes[id], nodes[depId]);
		});
	});

	return new Promise((resolve, reject) => {
		g.output(options, resolve, (code, out, err) => {
			reject(new Error(err));
		});
	});
}
function createGraph ( modules , circular , config , options ) { const g = graphviz . digraph ( 'G' ) ; const nodes = { } ; const cyclicModules = circular . reduce ( ( a , b ) => a . concat ( b ) , [ ] ) ; if ( config . graphVizPath ) { g . setGraphVizPath ( config . graphVizPath ) ; } Object . keys ( modules ) . forEach ( ( id ) => { nodes [ id ] = nodes [ id ] || g . addNode ( id ) ; if ( ! modules [ id ] . length ) { setNodeColor ( nodes [ id ] , config . noDependencyColor ) ; } else if ( cyclicModules . indexOf ( id ) >= 0 ) { setNodeColor ( nodes [ id ] , config . cyclicNodeColor ) ; } modules [ id ] . forEach ( ( depId ) => { nodes [ depId ] = nodes [ depId ] || g . addNode ( depId ) ; if ( ! modules [ depId ] ) { setNodeColor ( nodes [ depId ] , config . noDependencyColor ) ; } g . addEdge ( nodes [ id ] , nodes [ depId ] ) ; } ) ; } ) ; return new Promise ( ( resolve , reject ) => { g . output ( options , resolve , ( code , out , err ) => { reject ( new Error ( err ) ) ; } ) ; } ) ; }
Creates the graphviz graph.
@param  {Object} modules
@param  {Array} circular
@param  {Object} config
@param  {Object} options
@return {Promise}
Creates the graphviz graph .