~ruther/guix-local

c782d0cc8c3f9eb8234b275cc33b19eb9732f882 — Yarl Baudig 4 months ago d1a9fb8
graph: graphml backend: emit label

* guix/graph.scm (emit-graphml-prologue): Declare label attribute.
(emit-graphml-node): Define label attribute.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
1 files changed, 6 insertions(+), 2 deletions(-)

M guix/graph.scm
M guix/graph.scm => guix/graph.scm +6 -2
@@ 341,6 341,7 @@ nodeArray.push(nodes[\"~a\"]);~%"
    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=\"d0\" for=\"node\" attr.name=\"label\" attr.type=\"string\"/>
  <graph id=\"G\" edgedefault=\"directed\">~%"))

(define (emit-graphml-epilogue port)


@@ 348,8 349,11 @@ nodeArray.push(nodes[\"~a\"]);~%"
</graphml>"))

(define (emit-graphml-node id label port)
  (format port "    <node id=\"~a\"/>~%"
          (string-replace-substring (object->string id) "\"" "\\\"")))
  (format port "    <node id=\"~a\">
      <data key=\"d0\">~a</data>
    </node>~%"
          (string-replace-substring (object->string id) "\"" "\\\"")
          label))

(define (emit-graphml-edge id1 id2 port)
  (format port "    <edge source=\"~a\" target=\"~a\"/>~%"