0

Can someone tell me which language this is and how i should compile this into a graph? I downloaded a python code and after execute it gave me this back. There was nothing in the documentation except that the output is a dot-file.

digraph pn {
rankdir=LR;
"e" -> "P((('e', 'c'), ('d',)))";
"e" [shape=box];
"P((('e', 'c'), ('d',)))" [shape=circle];
"c" -> "P((('e', 'c'), ('d',)))";
"c" [shape=box];
"P((('e', 'c'), ('d',)))" [shape=circle];
"P((('e', 'c'), ('d',)))" -> "d";
"d" [shape=box];
"a" -> "P((('a',), ('e', 'c')))";
"a" [shape=box];
"P((('a',), ('e', 'c')))" [shape=circle];
"P((('a',), ('e', 'c')))" -> "e";
"e" [shape=box];
"P((('a',), ('e', 'c')))" -> "c";
"c" [shape=box];
"e" -> "P((('e', 'b'), ('d',)))";
"e" [shape=box];
"P((('e', 'b'), ('d',)))" [shape=circle];
"b" -> "P((('e', 'b'), ('d',)))";
"b" [shape=box];
"P((('e', 'b'), ('d',)))" [shape=circle];
"P((('e', 'b'), ('d',)))" -> "d";
"d" [shape=box];
"a" -> "P((('a',), ('e', 'b')))";
"a" [shape=box];
"P((('a',), ('e', 'b')))" [shape=circle];
"P((('a',), ('e', 'b')))" -> "e";
"e" [shape=box];
"P((('a',), ('e', 'b')))" -> "b";
"b" [shape=box];
in -> "a";
"d" -> out ;
}

vace
  • 35
  • 4
  • 4
    That's a graphviz DOT file. https://graphviz.org/doc/info/lang.html There are probably Python scripts to translate that into something else. – Tim Roberts Feb 17 '22 at 21:50

1 Answers1

0

As Tim Roberts pointed out, that's definitely a graphviz DOT file. With that being said, this becomes a repeat question. The short answer to your question becomes using Source from graphviz to view your DOT file.

from graphviz import Source
filecontents="""
digraph pn {
rankdir=LR;
"e" -> "P((('e', 'c'), ('d',)))";
...
"d" -> out ;
}
"""
graphdot= Source(filecontents, filename="filename.gv", format="png")
graphdot.view()

More info on Source here.

Hope this helps. Happy Coding!

METCOMechE
  • 23
  • 4