/// <summary> /// /// </summary> /// <param name="file"></param> /// <returns></returns> public static Graph Deserialize(string file) { XmlDocument doc = new XmlDocument(); doc.Load(file); Graph result = new Graph(); result.Tag = doc.SelectSingleNode("/GraphXML/graph").Attributes["meta"].Value; foreach (XmlNode node in doc.SelectNodes("/GraphXML/graph/node")) { Node n = result.AddNode(node.SelectSingleNode("label").InnerText); n.Id = Convert.ToInt32(node.Attributes["name"].Value.Substring(1)); } foreach (XmlNode edge in doc.SelectNodes("/GraphXML/graph/edge")) { int id1 = Convert.ToInt32(edge.Attributes["source"].Value.Substring(1)); int id2 = Convert.ToInt32(edge.Attributes["target"].Value.Substring(1)); result.AddEdge(result.FindNode(id1), result.FindNode(id2)); } return result; }