'Can someone tell me which language this is and how i should compile this into a graph?

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 ;
}



Solution 1:[1]

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!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 METCOMechE