Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • graph-tool graph-tool
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 47
    • Issues 47
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

Please use the issue tracker only to report bugs (i.e. errors in the library that need to be fixed) or feature requests.

For questions about how to compile, install or use the library, please use instead the mailing list at https://graph-tool.skewed.de/mailing
(If unsure, use the mailing list first.)



When opening new issues, please choose the BUG template from the drop-down menu, and fill out the required information.

  • Tiago Peixoto
  • graph-toolgraph-tool
  • Issues
  • #466

Closed
Open
Created May 07, 2018 by stphan-arch@stphan-arch2 of 5 tasks completed2/5 tasks

Writing DOT files does not quote ID strings correctly

Bug reports:

Please follow the general troubleshooting steps first:

  • Are you running the latest graph-tool version?
  • Do you observe the problem with the current git version?
  • Are you using Macports or Homebrew? If yes, please submit an issue there instead: https://github.com/Homebrew/brew/issues and https://trac.macports.org/newticket
  • Did you compile graph-tool manually?
  • If you answered yes above, did you use the exact same compiler to build graph-tool, boost-python and Python?

Problem

I have a DOT file with names as node_ids which contain dashes ('-'). These names are quoted (because of the dashes). Loading such a file works fine, however, when saving the graph again to DOT format, the quotes are gone:

echo 'digraph G { "name-with-dashes"; }' | python3 -c 'import io; import sys; import graph_tool.all as gt; output = io.BytesIO(); g = gt.load_graph(sys.stdin, fmt="dot"); g.save(output, fmt="dot"); print(output.getvalue().decode())'

Output:

digraph G {
name-with-dashes;
}

According to the DOT file specification (http://www.graphviz.org/doc/info/lang.html) a node_id (or just ID) may include a dash '-' either if it is numerical or quoted. So the resulting DOT file does not comply with the specification.

This becomes clear when trying to load the above DOT file output again in graph-tool:

echo 'digraph G { "name-with-dashes"; }' | python3 -c 'import io; import sys; import graph_tool.all as gt; output = io.BytesIO(); g = gt.load_graph(sys.stdin, fmt="dot"); g.save(output, fmt="dot"); print(output.getvalue().decode())' |  python3 -c 'import sys; import graph_tool.all as gt; g = gt.load_graph(sys.stdin, fmt="dot")'

which fails with an error message complaining about the unquoted dashes (as expected):

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/graph_tool/__init__.py", line 2936, in load_graph
    g.load(file_name, fmt, ignore_vp, ignore_ep, ignore_gp)
  File "/usr/lib/python3.6/site-packages/graph_tool/__init__.py", line 2485, in load
    ignore_vp, ignore_ep, ignore_gp)
RuntimeError: Invalid character (char is '-')

Suggested fix

When writing DOT files: Check vertex_name for illegal characters and quote the whole name if necessary.

System Information:

  • OS: Archlinux 4.16.5-1-ARCH
  • Python 3.6.5
  • gcc 7.3.1
  • boost 1.66.0
Assignee
Assign to
Time tracking