ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 16 Sep 2015 21:47:01 +0200load a graph from a dot filehttps://ask.sagemath.org/question/29477/load-a-graph-from-a-dot-file/ Sage allows me to get the representation of a Graph, G, in the [dot language](https://en.wikipedia.org/wiki/DOT_(graph_description_language)) by using the method
> [G.graphviz_string()](http://doc.sagemath.org/html/en/reference/graphs/sage/graphs/generic_graph.html#sage.graphs.generic_graph.GenericGraph.graphviz_string)
I can even have this string written directly to a file by using:
> [G.graphviz_to_file_named('my_graph_file.dot')](http://doc.sagemath.org/html/en/reference/graphs/sage/graphs/generic_graph.html#sage.graphs.generic_graph.GenericGraph.graphviz_to_file_named)
Is there a way of reloading G from such a file? I tried doing
> G = Graph('my_graph_file.dot')
> G = Graph(open('my_graph_file.dot'))
> G = Graph(open('my_graph_file.dot').read())
Where the contents of 'my_graph_file.dot' are:
> graph MyGraph{
> foo -- {bar}
> bar -- {foo; bas}
> bas -- {bar}
> }
But none of these worked.
Mark BellWed, 16 Sep 2015 21:47:01 +0200https://ask.sagemath.org/question/29477/