}//end method #endregion public static void WriteToXMLFile(string url, BaseGraph graph) { StreamWriter filewriter = new StreamWriter(url); XmlTextWriter writer = new XmlTextWriter(filewriter); if (graph is NonDirectedGraph) { writer.WriteElementString("NonDirectedGraph", ""); } else if(graph is DirectedGraph) { writer.WriteElementString("DirectedGraph", ""); } writer.WriteElementString("Nodes", ""); foreach (Node node in graph.NodesList.Values) { writer.WriteElementString("Node", node.NodeNumber.ToString()); writer.WriteEndElement(); //</Node> } writer.WriteEndElement(); //</Nodes> writer.WriteName("Lines"); foreach (Line line in graph.LinesList.Values) { writer.WriteElementString("Name", line.LineName); writer.WriteEndElement(); writer.WriteElementString("FirstNode", line.FirstNode.NodeNumber.ToString()); writer.WriteEndElement(); writer.WriteElementString("SecondNode", line.SecondNode.NodeNumber.ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); // end </Lines> writer.WriteEndElement(); // end </NonDirectedGraph> or <DirectedGraph> }