# Turning my Document into a Dependency Graph and Plotting it

Often times in math, we start out with some axioms, say A,B and from those prove theorems say C. In order visualize the logical relationships, I'd like a program to distill the logical dependencies of my document into a graph (in the mathematical sense, i.e. a set of vertices and edges), and then plot the result.

In this example, the graph would be {{A,C},{B,C}}.

Is there a package that can parse through my document, distill this structure and then plot it?

If not, hopefully I can write the backend stuff to make the mathematical graph, then reformat that syntax for whatever graphics package I choose, and then send that information to the package for plotting. What packages would you recommend for plotting graphs which aren't necessarily trees?

I could also just have python parse the actual latex file and generate the structure I want, and then plot it.

Edit: In the code below, I use labels and cross-references to delineate the dependency structure.

\begin_body

\begin_layout Definition
A
\begin_inset CommandInset label
LatexCommand label
name "def:A"

\end_inset

\end_layout

\begin_layout Standard
\begin_inset Separator plain
\end_inset

\end_layout

\begin_layout Definition
B
\begin_inset CommandInset label
LatexCommand label
name "def:B"

\end_inset

\end_layout

\begin_layout Standard
\begin_inset Separator plain
\end_inset

\end_layout

\begin_layout Definition
C
\begin_inset CommandInset label
LatexCommand label
name "def:C"

\end_inset

\end_layout

\begin_layout Definition
C is
\begin_inset CommandInset ref
LatexCommand ref
reference "def:A"

\end_inset

times
\begin_inset CommandInset ref
LatexCommand ref
reference "def:B"

\end_inset

\end_layout

\end_body
\end_document

• Please help us help you by showing a minimal compilable code example. Without the structure and some information how to find the dependencies in your source code we cannot do much. – TeXnician Apr 4 '18 at 19:49
• – michal.h21 Apr 4 '18 at 19:53
• latex (unless you use some custom macros for encoding more structure) is expressing natural language text, so there is no way to derive that theorem C logically depends on theorem B without reading the text, – David Carlisle Apr 4 '18 at 20:00
• @DavidCarlisle I was thinking of using labels and cross-references to encode the dependency structure. Will edit post with an example ASAP – Evan Rosica Apr 4 '18 at 20:08
• @EvanRosica sorry I have never used lyx, I did not recognise the syntax (which is totally unlike tex syntax) – David Carlisle Apr 4 '18 at 21:45