Elektrine lite

← Feed

@MartinEscardo@mathstodon.xyz

Post #982927

2026-04-07 19:08 UTC

Is there any command line utility to get a topological sort of a directed graph written down in graphviz `dot` format? Preferably, I would prefer that instead of a linear order, I was given a list of lists, where each list has the next level of dependency. For example, something in homebrew or github? Or, is there a tool to convert a graph in `dot` format to a graph in the format required by unix `tsort`? In any case, `tsort` is less than what I want, as discussed above.

Replies (3)

  • @Joshua@mathstodon.xyz 2026-04-07 19:36

    @MartinEscardo I don't know about topological sort itself. But when you install graphviz, you also get some utilities, like `tred` for transitive reduction and `ccomp` for connected components. Depending on the actual problem, these might be useful?

    Open ##1330056

  • @benjamingeer@piaille.fr 2026-04-07 19:38

    @MartinEscardo My first thought is to parse the dot file in Python using pydot, then pass it to the topological_sort function in networkx.

    Open ##1330060

  • @dimpase@mathstodon.xyz 2026-04-08 03:13

    @MartinEscardo Python package networkx has a convertor from the dot format to its internal format, and from the latter various other formats. It's very easy to install (not sure how well-versed you are in Python, feel free to ask for more advice) See https://networkx.org/documentation/stable/reference/readwrite/dot.html#pygraphviz

    Open ##1330061