0

Lets say I have a text file with the following data:

Form1 | L3 | depends on L4 and L5
Form1 | L4 | no dependence 
Form1 | L5 | depends on L6
Form1 | L7 | no dependence

What I would like to do is output a directed graph (where direction means "depends on"). In this example, we would have a graph with 2 components, one being a single vertex labelled "L7", and the other being 4 vertices connected in series (a 4-path), with arrows in the obvious directions.

I'm using Python 2.7 on a mac. I'm also very new to programming, but very skilled in mathematics (if that makes a difference).

thesecretmaster
  • 1,950
  • 1
  • 27
  • 39
boldbrandywine
  • 322
  • 1
  • 14

1 Answers1

1

One easy way would be to convert your input text file format to the Graphviz "dot" file format. Here's an example of someone writing a dot file using Python with no external libraries: How can python write a dot file for GraphViz asking for some edges to be colored red?

And there's PyDot which you could use to do the same thing: https://github.com/erocarrera/pydot

Once you have a "dot" file, you can turn it into an actual image using Graphviz (a separate program): http://www.graphviz.org/

Community
  • 1
  • 1
John Zwinck
  • 239,568
  • 38
  • 324
  • 436