AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Algorithmen, Datenstrukturen und Klassendesign graphml format - Erzeugen von Graphen-files mit Delphi
Thema durchsuchen
Ansicht
Themen-Optionen

graphml format - Erzeugen von Graphen-files mit Delphi

Ein Thema von bernhard_LA · begonnen am 25. Feb 2020 · letzter Beitrag vom 28. Feb 2020
Antwort Antwort
bernhard_LA

Registriert seit: 8. Jun 2009
Ort: Bayern
1.123 Beiträge
 
Delphi 11 Alexandria
 
#1

graphml format - Erzeugen von Graphen-files mit Delphi

  Alt 25. Feb 2020, 12:08
ich möchte unsere Graphen im graphml Format ausgeben http://graphml.graphdrawing.org/prim...ml-primer.html
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 !!!
  Mit Zitat antworten Zitat
TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.060 Beiträge
 
Delphi 10.4 Sydney
 
#2

AW: graphml format - Erzeugen von Graphen-files mit Delphi

  Alt 25. Feb 2020, 13:39
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 https://github.com/adolfosbh/cs2as/t...graphml/schema runterlädt und dann per XML Data Binding Wizard die ygraphics.xsd importiert, dann fällt zumindest eine über zweitausend Zeilen lange Pascal-Unit bei raus.
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.
  Mit Zitat antworten Zitat
bernhard_LA

Registriert seit: 8. Jun 2009
Ort: Bayern
1.123 Beiträge
 
Delphi 11 Alexandria
 
#3

AW: graphml format - Erzeugen von Graphen-files mit Delphi

  Alt 25. Feb 2020, 15:52
ich habe mal eine von unseren graphml Dateien aufgewählt.

Delphi-Quellcode:
<?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" />
der XML Data binding Wizard liefert mir folgende Fehlermeldung mit unserer Datei, "no bindable datatypes found" or selected .....
was mache ich hier falsch ?
  Mit Zitat antworten Zitat
TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.060 Beiträge
 
Delphi 10.4 Sydney
 
#4

AW: graphml format - Erzeugen von Graphen-files mit Delphi

  Alt 26. Feb 2020, 12:12
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.
  Mit Zitat antworten Zitat
TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.060 Beiträge
 
Delphi 10.4 Sydney
 
#5

AW: graphml format - Erzeugen von Graphen-files mit Delphi

  Alt 26. Feb 2020, 12:37
Ansonsten kannste natürlich auch alles per Hand machen, siehe TfrmMain.ExportToGraphML in hier:
https://github.com/norgepaul/DUDS/bl....Form.Main.pas
  Mit Zitat antworten Zitat
bernhard_LA

Registriert seit: 8. Jun 2009
Ort: Bayern
1.123 Beiträge
 
Delphi 11 Alexandria
 
#6

AW: graphml format - Erzeugen von Graphen-files mit Delphi

  Alt 27. Feb 2020, 07:37
ich habe einen neuen Thread zum Thema XML databinding Wizard gestartet : https://www.delphipraxis.net/203538-...ml#post1458485
Weitere Fragen speziell für GraphXL files dann hier.... (in einem update)

m

Geändert von bernhard_LA (27. Feb 2020 um 08:00 Uhr)
  Mit Zitat antworten Zitat
bernhard_LA

Registriert seit: 8. Jun 2009
Ort: Bayern
1.123 Beiträge
 
Delphi 11 Alexandria
 
#7

AW: graphml format - Erzeugen von Graphen-files mit Delphi

  Alt 28. Feb 2020, 13:37
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;

Geändert von bernhard_LA (28. Feb 2020 um 15:28 Uhr)
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:12 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz