How to parse a DOT file in Python

前端 未结 6 2288
别跟我提以往
别跟我提以往 2020-12-15 00:11

I have a transducer saved in the form of a DOT file. I can see a graphical representation of the graphs using gvedit, but what if I want to convert the DOT file to an execut

6条回答
  •  抹茶落季
    2020-12-15 00:40

    Another path, and a simple way of finding cycles in a dot file:

    import pygraphviz as pgv
    import networkx as nx
    
    gv = pgv.AGraph('my.dot', strict=False, directed=True)
    G = nx.DiGraph(gv)
    
    cycles = nx.simple_cycles(G)
    for cycle in cycles:
        print(cycle)
    

提交回复
热议问题