![]() |
graphml format - Erzeugen von Graphen-files mit Delphi
ich möchte unsere Graphen im graphml Format ausgeben
![]() aktuell bin ich jetzt auf der Suche nach Lösungen/Ansätzen Code Beispielen so etwas in Delphi zu realisieren, alle Inputs um nicht ganz bei 0 anzufangen -> gerne :-) !!! |
AW: graphml format - Erzeugen von Graphen-files mit Delphi
Tja, spontan hätte ich gesagt, nehme eine Graphml-Datei, benenne sie nach XML um und importiere per File->New->Other...->Delphi Projects->XML->XML Data Binding, damit der Wizard dir schon mal ein paar IXML...-Typen importiert, aber sowohl in XE5 als auch in Tokyo kommt bei mir "Zugriff verweigert".
Wenn man die XSDs von ![]() Leider gibt es keine praktischen Load*(), Get*() und New*() Funktionen, weil laut Wizard der Document type nicht definiert ist, aber mit ein bisschen experimentieren bekommst du das sicher hin. Vielleicht muss man auch alle XSD importieren - zumindest jene, die sich importieren lassen - und dann irgendwie mischen. |
AW: graphml format - Erzeugen von Graphen-files mit Delphi
ich habe mal eine von unseren graphml Dateien aufgewählt.
Delphi-Quellcode:
der XML Data binding Wizard liefert mir folgende Fehlermeldung mit unserer Datei, "no bindable datatypes found" or selected .....
<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"> <key id="key0" for="edge" attr.name="Edge Label" attr.type="string" /> was mache ich hier falsch ? |
AW: graphml format - Erzeugen von Graphen-files mit Delphi
Ja, das meinte ich in meinen ersten Absatz. Die GraphML/XML-Dateien zu importieren läuft nicht.
Importiere mal die XSD-Dateien, damit hat man zumindest das Gröbste erschlagen. |
AW: graphml format - Erzeugen von Graphen-files mit Delphi
Ansonsten kannste natürlich auch alles per Hand machen, siehe TfrmMain.ExportToGraphML in hier:
![]() |
AW: graphml format - Erzeugen von Graphen-files mit Delphi
ich habe einen neuen Thread zum Thema XML databinding Wizard gestartet :
![]() Weitere Fragen speziell für GraphXL files dann hier.... (in einem update) m |
AW: graphml format - Erzeugen von Graphen-files mit Delphi
ohne Verwendung des XML Databinding sieht meine aktuelle Lösung wie folgt aus:
Delphi-Quellcode:
var i: Integer; ColorstringList: TStringList; LDocument: IXMLDocument; LNodeElement, LGRAPHelement , ChildnodeElement, LSubNodeElement, NodeText, NodeCData: IXMLNode; begin /// /// /// ColorstringList := TStringList.Create; ColorstringList.Add('green'); ColorstringList.Add('blue'); ColorstringList.Add('red'); ColorstringList.Add('white'); ColorstringList.Add('purple'); ColorstringList.Add('green'); ColorstringList.Add('blue'); ColorstringList.Add('red'); ColorstringList.Add('white'); ColorstringList.Add('purple'); ColorstringList.Add('green'); ColorstringList.Add('blue'); ColorstringList.Add('red'); ColorstringList.Add('white'); ColorstringList.Add('purple'); LDocument := TXMLDocument.Create(nil); LDocument.Active := True; { Define document content. } LDocument.DocumentElement := LDocument.CreateNode('graphml', ntElement, ''); LDocument.DocumentElement.Attributes['xmlns'] := 'http://graphml.graphdrawing.org/xmlns'; LDocument.DocumentElement.Attributes['xmlns:xsi'] := 'http://www.w3.org/2001/XMLSchema-instance'; /// /// <key id="d0" for="node" attr.name="color" attr.type="string"> <default>yellow</default> /// </key> <key id="d1" for="edge" attr.name="weight" attr.type="double"/> /// LNodeElement := LDocument.DocumentElement.AddChild('key', -1); LNodeElement.Attributes['id'] := 'key' + IntToStr(1); LNodeElement.Attributes['for'] := 'node'; LNodeElement.Attributes['attr.name'] := 'color'; LNodeElement.Attributes['attr.type'] := 'string'; LNodeElement := LDocument.DocumentElement.AddChild('key', -1); LNodeElement.Attributes['id'] := 'key' + IntToStr(2); LNodeElement.Attributes['for'] := 'edge'; LNodeElement.Attributes['attr.name'] := 'weight'; LNodeElement.Attributes['attr.type'] := 'double'; LGRAPHelement := LDocument.DocumentElement.AddChild('graph', -1); LGRAPHelement.Attributes['id'] := 'GRAPH'; LGRAPHelement.Attributes['edgedefault'] := 'undirected'; for i := 1 to 10 do begin LSubNodeElement := LGRAPHelement.AddChild('node', -1); LSubNodeElement.Attributes['id'] := 'N' + IntToStr(i); /// <data key="d0">green</data> ChildnodeElement := LSubNodeElement.AddChild('data'); ChildnodeElement.Attributes['key']:='key1'; ChildnodeElement.Text := ColorstringList[i]; end; for i := 1 to 9 do begin LSubNodeElement := LGRAPHelement.AddChild('edge', -1); LSubNodeElement.Attributes['id'] := 'E' + IntToStr(i); LSubNodeElement.Attributes['source'] := 'N' + IntToStr(i); LSubNodeElement.Attributes['target'] := 'N' + IntToStr(i + 1); // <data key="d0">green</data> ChildnodeElement := LSubNodeElement.AddChild('data'); ChildnodeElement.Attributes['key']:='key2'; ChildnodeElement.Text := IntToStr(Random(5)+1); end; LSubNodeElement := LGRAPHelement.AddChild('edge', -1); LSubNodeElement.Attributes['id'] := 'E' + IntToStr(10); LSubNodeElement.Attributes['source'] := 'N' + IntToStr(10); LSubNodeElement.Attributes['target'] := 'N' + IntToStr(1); // <data key="d0">green</data> ChildnodeElement := LSubNodeElement.AddChild('data'); ChildnodeElement.Attributes['key']:='key2'; ChildnodeElement.Text := '1'; LDocument.SaveToFile('e:\testxmlgraph.graphml'); LDocument.SaveToFile('e:\testxmlgraph1.txt'); LDocument.SaveToFile('e:\testxmlgraph2.xml'); redt1.Lines.LoadFromFile('e:\testxmlgraph1.txt'); end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:04 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz