Squashed commit of the following:

commit d7948acb
Author: Fabien Maniere <fabien.maniere@cnrs.fr>
Date:   Wed Jan 15 17:36:49 2025 +0100

    export to GEXF: adding the weight attribute to all nodes

commit d937e72e
Author: Fabien Manière <fmaniere.pro@gmail.com>
Date:   Wed Apr 24 17:09:27 2024 +0200

    adding weight attribute
parent 13457ca8
Pipeline #7266 canceled with stages
......@@ -51,19 +51,30 @@ graphToXML (G.Graph { .. }) = root _graph_nodes _graph_edges
desc = XML.tag "description" mempty $ XML.content "Gargantext gexf file"
graph :: (Monad m) => [G.Node] -> [G.Edge] -> ConduitT i XML.Event m ()
graph gn ge = XML.tag "graph" params $ (nodes gn) <> (edges ge)
graph gn ge = XML.tag "graph" params $ graphAttributes <> (nodes gn) <> (edges ge)
where
params = XML.attr "mode" "static"
<> XML.attr "defaultedgetype" "directed"
graphAttributes :: (Monad m) => ConduitT i XML.Event m ()
graphAttributes = XML.tag "attributes" graphAttributesParams $ graphAttributeWeight
where
graphAttributesParams = XML.attr "class" "node"
graphAttributeWeight = XML.tag "attribute" attrWeightParams $ XML.content ""
attrWeightParams = XML.attr "id" "0"
<> XML.attr "title" "weight"
<> XML.attr "type" "integer"
nodes :: (Monad m) => [G.Node] -> ConduitT i XML.Event m ()
nodes gn = XML.tag "nodes" mempty (yieldMany gn .| awaitForever node')
node' :: (Monad m) => G.Node -> ConduitT i XML.Event m ()
node' (G.Node { .. }) = XML.tag "node" params (XML.tag "viz:size" sizeParams $ XML.content "")
-- node' (G.Node { .. }) = XML.tag "node" params (XML.tag "viz:size" sizeParams $ XML.content "")
node' (G.Node { .. }) = XML.tag "node" params $ XML.tag "attvalues" mempty $ XML.tag "attvalue" sizeParams mempty
where
params = XML.attr "id" node_id
<> XML.attr "label" node_label
sizeParams = XML.attr "value" (show node_size)
sizeParams = XML.attr "for" "0"
<> XML.attr "value" (show node_size)
edges :: (Monad m) => [G.Edge] -> ConduitT i XML.Event m ()
edges ge = XML.tag "edges" mempty (yieldMany ge .| awaitForever edge')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment