public void OpenFile(string fileName) { //graph where the vertices and edges should be put in var graph = new CompoundGraph <object, IEdge <object> >(); try { //open the file of the graph var reader = XmlReader.Create(fileName); //create the serializer var serializer = new GraphMLDeserializer <object, IEdge <object>, CompoundGraph <object, IEdge <object> > >(); //deserialize the graph serializer.Deserialize(reader, graph, id => id, (source, target, id) => new Edge <object>(source, target) ); } catch (Exception ex) { Debug.WriteLine(ex); } layout.Graph = graph; layout.UpdateLayout(); }
public static PocGraph LoadGraph(string filename) { using (XmlReader reader = XmlReader.Create(filename)) { var serializer = new GraphMLDeserializer <PocVertex, PocEdge, PocGraph>(); var pocGraph = new PocGraph(); serializer.Deserialize(reader, pocGraph, id => new PocVertex(id), (source, target, id) => new PocEdge(id, source, target)); return(pocGraph); } }
public static PocGraph LoadGraph(string filename) { using (XmlReader reader = XmlReader.Create(filename)) { var serializer = new GraphMLDeserializer<PocVertex, PocEdge, PocGraph>(); var pocGraph = new PocGraph(); serializer.Deserialize(reader, pocGraph, id => new PocVertex(id), (source, target, id) => new PocEdge(id, source, target)); return pocGraph; } }
public TestDataAssemblyGraphAnalyzer(string testDataFile) { this.graph = new BidirectionalGraph <int, Edge <int> >(); this.deserializer = new GraphMLDeserializer <int, Edge <int>, BidirectionalGraph <int, Edge <int> > >(); using (var xmlReader = XmlReader.Create(testDataFile)) { this.deserializer.Deserialize(xmlReader, this.graph, id => int.Parse(id), (int src, int dst, string id) => new Edge <int>(src, dst)); } }
public static SoftMutableBidirectionalGraph <CFGNode, CFGEdge> Deserialize(string path) { var deser = new GraphMLDeserializer <CFGNode, CFGEdge, SoftMutableBidirectionalGraph <CFGNode, CFGEdge> >(); var graph = new SoftMutableBidirectionalGraph <CFGNode, CFGEdge>(); var ivf = new IdentifiableVertexFactory <CFGNode>(CFGNode.Factory); var ief = new IdentifiableEdgeFactory <CFGNode, CFGEdge>(CFGEdge.Factory); using (var reader = XmlReader.Create(path)) { deser.Deserialize(reader, graph, ivf, ief); } ReplaceLineBreaks(graph, false); return(graph); }
public static SEGraph Deserialize(string path) { var deser = new GraphMLDeserializer <SENode, SEEdge, SEGraph>(); var graph = new SEGraph(); var ivf = new IdentifiableVertexFactory <SENode>(SENode.Factory); var ief = new IdentifiableEdgeFactory <SENode, SEEdge>(SEEdge.Factory); using (var reader = XmlReader.Create(path)) { deser.Deserialize(reader, graph, ivf, ief); } ReplaceLineBreaks(graph, false); return(graph); }
/// <summary> /// Loads the graph. /// </summary> /// <param name="filename">The filename.</param> /// <returns></returns> public static CustomGraph LoadGraph(string filename) { ////open the file of the graph var reader = XmlReader.Create(filename); ////create the serializer var serializer = new GraphMLDeserializer <CustomVertex, CustomEdge, CustomGraph>(); ////graph where the vertices and edges should be put in var customGraph = new CustomGraph(); ////deserialize the graph serializer.Deserialize(reader, customGraph, id => new CustomVertex(id.Split(';').First(), (Color)ColorConverter.ConvertFromString(id.Split(';').ElementAt(1)), id.Split(';').ElementAt(4), double.Parse(id.Split(';').ElementAt(2)), double.Parse(id.Split(';').ElementAt(3))), (source, target, name) => new CustomEdge(name.Split(';').ElementAt(1), source, target, (Color)ColorConverter.ConvertFromString(name.Split(';').FirstOrDefault()))); return(customGraph); }
/// <summary> /// Loads the graph. /// </summary> /// <param name="filename">The filename.</param> /// <returns></returns> public static CustomGraph LoadGraph(string filename) { ////open the file of the graph var reader = XmlReader.Create(filename); ////create the serializer var serializer = new GraphMLDeserializer<CustomVertex, CustomEdge, CustomGraph>(); ////graph where the vertices and edges should be put in var customGraph = new CustomGraph(); ////deserialize the graph serializer.Deserialize(reader, customGraph, id => new CustomVertex(id.Split(';').First(), (Color)ColorConverter.ConvertFromString(id.Split(';').ElementAt(1)), id.Split(';').ElementAt(4), double.Parse(id.Split(';').ElementAt(2)), double.Parse(id.Split(';').ElementAt(3))), (source, target, name) => new CustomEdge(name.Split(';').ElementAt(1), source, target, (Color)ColorConverter.ConvertFromString(name.Split(';').FirstOrDefault()))); return customGraph; }
public static PocGraph LoadGraph(string filename) { //open the file of the graph var reader = XmlReader.Create(filename); //create the serializer var serializer = new GraphMLDeserializer <PocVertex, PocEdge, PocGraph>(); //graph where the vertices and edges should be put in var pocGraph = new PocGraph(); //deserialize the graph serializer.Deserialize(reader, pocGraph, id => new PocVertex(id), (source, target, id) => new PocEdge(id, source, target)); return(pocGraph); }
public static PocGraph LoadGraph( string filename ) { //open the file of the graph var reader = XmlReader.Create( filename ); //create the serializer var serializer = new GraphMLDeserializer<PocVertex, PocEdge, PocGraph>(); //graph where the vertices and edges should be put in var pocGraph = new PocGraph(); //deserialize the graph serializer.Deserialize( reader, pocGraph, id => new PocVertex( id ), ( source, target, id ) => new PocEdge( id, source, target ) ); return pocGraph; }
public static PocGraph LoadGraph(string filename) { using (XmlReader reader = XmlReader.Create(filename)) { //QuickGraph.Serialization.SerializationExtensions. var serializer = new GraphMLDeserializer <PocVertex, PocEdge, PocGraph>(); var pocGraph = new PocGraph(); serializer.Deserialize(reader, pocGraph, id => new PocVertex(id, 10), (source, target, id) => new PocEdge(id, source, target)); return(pocGraph); } // using (var stream = File.OpenRead(filename)) // { // return stream.DeserializeFromBinary<PocVertex, PocEdge, PocGraph>(); // } }
public static PocGraph LoadGraph([NotNull] string filePath) { // Open the file of the graph using (XmlReader reader = XmlReader.Create(filePath)) { // Create the serializer var serializer = new GraphMLDeserializer <PocVertex, PocEdge, PocGraph>(); // Graph where the vertices and edges should be put in var pocGraph = new PocGraph(); // Deserialize the graph serializer.Deserialize( reader, pocGraph, id => new PocVertex(id), (source, target, id) => new PocEdge(id, source, target)); return(pocGraph); } }
public void GraphMLSerialization_HeaderCheck(bool emitDeclarationOnSerialize, bool emitDeclarationOnDeserialize) { var graph = new EquatableTestGraph { String = "graph", Int = 42 }; var vertex1 = new EquatableTestVertex("v1") { StringDefault = "foo", String = "string", Int = 10, Long = 20, Float = 25.0F, Double = 30.0, Bool = true }; var vertex2 = new EquatableTestVertex("v2") { StringDefault = "bar", String = "string2", Int = 110, Long = 120, Float = 125.0F, Double = 130.0, Bool = true }; graph.AddVertex(vertex1); graph.AddVertex(vertex2); var edge1 = new EquatableTestEdge(vertex1, vertex2, "e_1") { String = "edge", Int = 90, Long = 100, Float = 25.0F, Double = 110.0, Bool = true }; graph.AddEdge(edge1); EquatableTestGraph serializedGraph = VerifySerialization( graph, g => { using (var writer = new StringWriter()) { var settings = new XmlWriterSettings { Indent = true }; using (XmlWriter xmlWriter = XmlWriter.Create(writer, settings)) { var serializer = new GraphMLSerializer <EquatableTestVertex, EquatableTestEdge, EquatableTestGraph> { EmitDocumentDeclaration = emitDeclarationOnDeserialize }; serializer.Serialize( xmlWriter, g, vertex => vertex.ID, edge => edge.ID); } return(writer.ToString()); } }, xml => { using (var reader = new StringReader(xml)) { var serializer = new GraphMLDeserializer <EquatableTestVertex, EquatableTestEdge, EquatableTestGraph> { EmitDocumentDeclaration = emitDeclarationOnDeserialize }; #if SUPPORTS_XML_DTD_PROCESSING var settings = new XmlReaderSettings { ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings, XmlResolver = new GraphMLXmlResolver(), DtdProcessing = DtdProcessing.Ignore }; using (XmlReader xmlReader = XmlReader.Create(reader, settings)) { #else var xmlReader = new XmlTextReader(reader); { xmlReader.ProhibitDtd = false; xmlReader.XmlResolver = null; #endif var g = new EquatableTestGraph(); serializer.Deserialize( xmlReader, g, id => new EquatableTestVertex(id), (source, target, id) => new EquatableTestEdge(source, target, id)); return(g); } } }); Assert.IsTrue( EquateGraphs.Equate( graph, serializedGraph)); }
public void OpenFile(string fileName) { //graph where the vertices and edges should be put in var graph = new CompoundGraph<object, IEdge<object>>(); try { //open the file of the graph var reader = XmlReader.Create(fileName); //create the serializer var serializer = new GraphMLDeserializer<object, IEdge<object>, CompoundGraph<object, IEdge<object>>>(); //deserialize the graph serializer.Deserialize(reader, graph, id => id, (source, target, id) => new Edge<object>(source, target) ); } catch (Exception ex) { Debug.WriteLine(ex); } layout.Graph = graph; layout.UpdateLayout(); }