/// <summary> /// Stores the given IGEXF graph on disk /// </summary> /// <param name="myFileName">The filename for storing the graph</param> /// <param name="mySaveOptions">The SaveOptions</param> public static IGEXF Save(this IGEXF myIGEXF, String myFileName, SaveOptions mySaveOptions) { #region Initial checks if (myIGEXF == null) { throw new ArgumentNullException("myIGEXF must not be null!"); } if (myFileName.IsNullOrEmpty()) { throw new ArgumentNullException("myFileName must not be null!"); } #endregion if (!myFileName.Contains(".")) { myFileName += ".gexf"; } myIGEXF.ToXML().Save(myFileName, mySaveOptions); return(myIGEXF); }
public static Boolean HasVisualization(this IGEXF myIGEXF) { if (myIGEXF == null) { throw new ArgumentNullException("myIGEXF must not be null!"); } return(myIGEXF.Visualization); }
public static IGEXF ClearVariant(this IGEXF myIGEXF) { if (myIGEXF == null) { throw new ArgumentNullException("myIGEXF must not be null!"); } myIGEXF.Variant = null; return(myIGEXF); }
/// <summary> /// Translates the given IGEXF graph to its GEXF v1.1 XML representation /// </summary> /// <returns>A XDocument</returns> public static XDocument ToXML(this IGEXF myIGEXF) { #region Initial checks if (myIGEXF == null) { throw new ArgumentNullException("myIGEXF must not be null!"); } #endregion var _XDocument = new XDocument(new XDeclaration("1.0", "UTF-8", "yes")); var _gexf = new XElement(gephi_ns + "gexf", new XAttribute(XNamespace.Xmlns + "xsi", xsi.NamespaceName), new XAttribute(xsi + "schemaLocation", schemaLocation.NamespaceName), new XAttribute("version", myIGEXF.Version ?? "")); var _meta = new XElement(gephi_ns + "meta", new XAttribute("lastmodifieddate", myIGEXF.Metadata.LastModified.ToFormatedString("yyyy-MM-dd")), new XElement(gephi_ns + "creator", myIGEXF.Metadata.Creator ?? ""), new XElement(gephi_ns + "description", myIGEXF.Metadata.Description ?? "")); if (myIGEXF.Metadata.Keywords.IsNotNullOrEmpty()) { _meta.Add(new XElement(gephi_ns + "keywords", myIGEXF.Metadata.Keywords.ToCommaSeperatedList())); } var _graph = new XElement(gephi_ns + "graph", new XAttribute("mode", myIGEXF.Graph.Mode.ToString().ToLower()), new XAttribute("defaultedgetype", myIGEXF.Graph.DefaultEdgeType.ToString().ToLower()), //new XElement("attributes", new XAttribute("class", "node")), // optional! //new XElement("attributes", new XAttribute("class", "edge")), // optional! myIGEXF.Graph.Nodes.ToXML(_gexf), myIGEXF.Graph.Edges.ToXML(_gexf) ); _XDocument.Add(_gexf); _gexf.Add(_meta); _gexf.Add(_graph); return(_XDocument); }