Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pangraph.GraphML.Writer does not write VertexID etc. #41

Open
debug-ito opened this issue Jun 15, 2019 · 6 comments · May be fixed by #45
Open

Pangraph.GraphML.Writer does not write VertexID etc. #41

debug-ito opened this issue Jun 15, 2019 · 6 comments · May be fixed by #45
Labels

Comments

@debug-ito
Copy link

I don't think Pangraph.GraphML.Writer writes VertexID of a Vertex or edgeID, source or target of an Edge. This makes the result GraphML data invalid.

@snowleopard
Copy link
Member

@debug-ito Thanks for the report -- could you give a simple example with an expected and produced output?

@debug-ito
Copy link
Author

Sure.

{-# LANGUAGE OverloadedStrings #-}
module Main (main) where

import qualified Data.ByteString as B
import Pangraph (makePangraph, makeVertex, makeEdge)
import qualified Pangraph.GraphML.Writer as GraphML

main :: IO ()
main = B.putStrLn $ GraphML.write graph
  where
    (Just graph) = makePangraph vertices edges
    vertices = [ makeVertex "foo" [],
                 makeVertex "bar" [],
                 makeVertex "buzz" []
               ]
    edges = [ makeEdge ("foo", "bar") [],
              makeEdge ("bar", "buzz") [],
              makeEdge ("buzz", "foo") []
            ]

Got:

<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <graph id="G" edgedefault="undirected">
    <node/>
    <node/>
    <node/>
    <edge/>
    <edge/>
    <edge/>
  </graph>
</graphml>

Expected:

<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <graph id="G" edgedefault="undirected">
    <node id="foo"/>
    <node id="bar"/>
    <node id="buzz"/>
    <edge source="foo" target="bar"/>
    <edge source="bar" target="buzz"/>
    <edge source="buzz" target="foo"/>
  </graph>
</graphml>

@snowleopard
Copy link
Member

@debug-ito Great, thank you!

I'm not sure I'll find time for this soon, so PRs are welcome.

(Or, perhaps, @thisiswhereitype could have a look.)

@debug-ito
Copy link
Author

OK, I'll make a pull-request.

@debug-ito
Copy link
Author

Wait, I just checked test/GraphML.hs. That test deals with Pangraph.Examples.SampleGraph.sampleGraph, which is defined as:

smallGraph :: Pangraph
smallGraph = fromJust graph
  where
    graph =
      makePangraph
        [makeVertex "n0" [("id","n0")]
        ,makeVertex "n1" [("id","n1")]
        ,makeVertex "n2" [("id","n2")]]
        [makeEdge ("n0", "n2") 
          [("source","n0"),("target","n2")]]

So, according to this test, users of Pangraph are supposed to make Vertex with the explicit id attribute and Edge with the explicit source and target attributes, aren't they? Is that the expected usage of Pangraph?

@snowleopard
Copy link
Member

@debug-ito The main purpose of Pangraph is to serve as a bridge for converting between various graph formats. It's internal graph representation is not really intended to be used for graph description -- for that you can use other graph libraries, which may be more suited for the task. With that in mind, I think the answer to your question

Is that the expected usage of Pangraph?

is negative: No, we do not expect the internal graph representation of Pangraph to be used, and it may change in future.

However, it is still important to have good documentation for the library to avoid confusion. So, if you think that the library's README or Haddock documentation can be improved, please let us know. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants