public String createGraphFromSQL() {
		if (db == null) {
			System.out.println("[X] DB not configured!");
			return "";
		}
		ProjectController pc = Lookup.getDefault().lookup(
				ProjectController.class);
		pc.newProject();
		Workspace workspace = pc.getCurrentWorkspace();

		// get controllers and models
		ImportController importController = Lookup.getDefault().lookup(
				ImportController.class);
		GraphModel graphModel = Lookup.getDefault()
				.lookup(GraphController.class).getModel();

		ImporterEdgeList edgeListImporter = new ImporterEdgeList();
		Container container = importController.importDatabase(db,
				edgeListImporter);
		container.setAllowAutoNode(false); // don't create missing nodes

		// force UNDIRECTED
		container.getLoader().setEdgeDefault(EdgeDefault.UNDIRECTED);

		// append imported data to GraphAPI
		importController.process(container, new DefaultProcessor(), workspace);
		NodeIterator ni = graphModel.getGraph().getNodes().iterator();
		Integer male = 0;
		Integer female = 0;
		Integer neutral = 0;
		while (ni.hasNext()) {
			Node foo = ni.next();
			String sex = ((String) foo.getNodeData().getAttributes()
					.getValue("sex"));
			if (sex.compareTo("M") == 0) {
				foo.getNodeData().setColor(0, 0, 1);
				male++;
			}

			else if (sex.compareTo("W") == 0) {
				foo.getNodeData().setColor(1, 0, 1);
				female++;
			} else {
				neutral++;
			}
		}
		
		// Write stats to files.
		HashMap<String, String> mp = new HashMap<String, String>();
		mp.put("Name:", graphModel.getGraph().getNode(1).getNodeData().getLabel());
		mp.put("male:", male.toString());
		mp.put("female:", female.toString());
		mp.put("neutral:", neutral.toString());
		WriteToFile.writeStatsToFile(mp, path);
		
		// layout - 100 Yifan Hu passes
		layout = new YifanHuLayout(null, new StepDisplacement(1f));
		layout.setGraphModel(graphModel);
		layout.resetPropertiesValues();
		for (int i = 0; i < 100 && layout.canAlgo(); i++) {
			layout.goAlgo();
		}
		
		// export to gexf
		ExportController ec = Lookup.getDefault()
				.lookup(ExportController.class);
		Exporter exporter = ec.getExporter("gexf");
		CharacterExporter characterExporter = (CharacterExporter) exporter;
		StringWriter stringWriter = new StringWriter();
		ec.exportWriter(stringWriter, characterExporter);
		String result = stringWriter.toString();
		// The swf Explorer cannot use "for", so we need to use "id"
		result = result.replaceAll("for=\"url\"", "id=\"url\"");
		return result;
	}