4

Does anyone know if there is a way to generate a nice graph from Horn clauses? for example:

AND-OR graph

Ideally, I would like to generate AND-OR graphs like this directly from Horn clauses written in Latex; however, if you know another way such as from rules written in RDF, I will also appreciate it.

Also, generated graphs do not have to be exactly like this one I show. It just have to illustrate the inference relation between my data.

2
  • 1
    Have you looked at part 4 of the TikZ manual, 'Graph Drawing'? It uses Lua to automate graph drawing. You'd need to specify things in the right syntax or transform the clauses into that syntax, but it does automate the drawing of graphs. (Requires LuaTeX, of course.) – cfr Jun 24 '15 at 13:43
  • @cfr I'll take a look at it. – Rafael Angarita Jun 24 '15 at 13:48
3

Here's a potential solution using neato from the graphviz package. It requires a more difficult input format and the output isn't as nice as your example, but I think it conveys the right information.

A file named sample.dot as follows...

graph G
{
    P -- Q [dir=forward];

    L -- LM;
    M -- LM;
    LM -- P [dir=forward];

    B -- BL;
    L -- BL;
    BL -- M [dir=forward];

    A -- AP;
    P -- AP;
    AP -- L [dir=forward];

    A -- AB;
    B -- AB;
    AB -- L [dir=forward];

    LM [shape=point];
    BL [shape=point];
    AP [shape=point];
    AB [shape=point];
}

processed with the following command...

neato -Tpdf sample.dot -o sample.pdf

gives...

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.