public void write(String name) {
		try {
			DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
			DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
			Document doc = docBuilder.newDocument();
			Element rootElement = doc.createElement("graphml");
			rootElement.setAttribute("xmlns","http://graphml.graphdrawing.org/xmlns");
			rootElement.setAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance");
			rootElement.setAttribute("xsi:schemaLocation","http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd");
			doc.appendChild(rootElement);
			Element graphElement = doc.createElement("graph");
			graphElement.setAttribute("id", "G");
			graphElement.setAttribute("edgedefault", "undirected");
			rootElement.appendChild(graphElement);
			ArrayList<Element> nodes = new ArrayList<Element>();
			ArrayList<Element> edges = new ArrayList<Element>();
			int edgeCounter = 0;
			for (int i=0;i<N;i++) {
				Element node = doc.createElement("node");
				node.setAttribute("id", "nd" + i);
				nodes.add(node);
				for (int j=i+1;j<N;j++) {
					if (matrix[i][j] == 1) {
						Element edge = doc.createElement("edge");
						edge.setAttribute("id", "ed" + edgeCounter);
						edge.setAttribute("source", "nd" + i);
						edge.setAttribute("target", "nd" + j);
						edges.add(edge);
						edgeCounter += 1;
					}
				}
			}
			for (Element node: nodes) {
				graphElement.appendChild(node);
			}
			for (Element edge: edges) {
				graphElement.appendChild(edge);
			}
			
			TransformerFactory transformerFactory = TransformerFactory.newInstance();
			Transformer transformer = transformerFactory.newTransformer();
			DOMSource source = new DOMSource(doc);
			StreamResult result = new StreamResult(new File("./graphs/"+name+".graphml"));
	 
			// Output to console for testing
			// StreamResult result = new StreamResult(System.out);
	 
			transformer.transform(source, result);
		}
		catch (ParserConfigurationException pce) {
			pce.printStackTrace();
		}
		catch (TransformerException tfe) {
			tfe.printStackTrace();
		}
	}