private static void WriteXml(XmlWriter writer, HashSet <Link> matchingLinks) { var edgesCounter = 0; Gexf.WriteXml(writer, () => // nodes { foreach (var matchingLink in matchingLinks) { GexfNode.WriteXml(writer, matchingLink.ToInt(), matchingLink.ToString()); } }, () => // edges { foreach (var matchingLink in matchingLinks) { if (matchingLinks.Contains(matchingLink.Source)) { Edge.WriteXml(writer, edgesCounter++, matchingLink.ToInt(), matchingLink.Source.ToInt(), SourceLabel); } if (matchingLinks.Contains(matchingLink.Linker)) { Edge.WriteXml(writer, edgesCounter++, matchingLink.ToInt(), matchingLink.Linker.ToInt(), LinkerLabel); } if (matchingLinks.Contains(matchingLink.Target)) { Edge.WriteXml(writer, edgesCounter++, matchingLink.ToInt(), matchingLink.Target.ToInt(), TargetLabel); } } }); }
public void writeToStream(Gexf gexf, Stream outputStream, string encoding) { // TODO: Uncomment //try { // XMLOutputFactory xmlOutputFactory = WstxOutputFactory.newInstance(); // XmlWriter streamWriter = xmlOutputFactory.createXmlWriter(out); // PrettyPrintHandler handler = new PrettyPrintHandler(streamWriter); // streamWriter = (XmlWriter) Proxy.newProxyInstance( // XmlWriter.class.getClassLoader(), // new Class[]{XmlWriter.class}, // handler ); // streamWriter.writeStartDocument(encoding, "1.0"); // new GexfEntityWriter(streamWriter, gexf); // streamWriter.writeEndDocument(); // streamWriter.flush(); // streamWriter.close(); //} catch (XMLStreamException e) { // throw new Exception("XML Exception: " + e.getMessage(), e); //} }
static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.Green; Graph graph = new Graph(); for (int i = 0; i < 200; i++) { graph.AddStrandVertex(); } DriverZero D = new DriverZero(); D.FormRing(graph, graph.AllVertices, 1); //// FLOWER RUN // //StrandLib strand = new StrandLib(); //// instantiate graph //Graph graph = new Graph(); //// seed graph //var zero = graph.AddStrandVertex(); //// run seed //zero.K.Run(strand.Flower(), 0); Gexf gexf = new Gexf(); gexf.SaveGraph(graph, "undirected", "string"); graph.PrintMatrix(); graph.PrintEdges(); Console.WriteLine($"SIZE: {graph.size}"); graph.PrintVertices(); }