# Documentation: Programming guide

## Dependency graphs

SPIRIT provides two graphs that visualize the logical and probabilistical dependencies among the variables in a knowledge base. There are two kinds of graphs supported. The nodes of these graphs are the variables.

*Undirected Graph*: an edge between two variables means that they both appear in a common rule.*Mixed Graph*: an undirected edge between two nodes means that they both appear in the conclusion of a common rule. An arrow from node A to B means that A can be found in the premise of a rule, the conclusion of which contains B.

### Defining a Graph

There is no direct way of defining or editing a dependency graph, because it is derived from the actual set of rules. So you do not need to worry about the graph at all. Its only use is to visualize the dependencies in a knowledge base.

### Visualising a Graph

There are three methods to get the actual graphs. For each node you should call
`KBase.graphAdjacentVars`

to find out the list of linked nodes. After
receiving such a list, you could call
`KBase.graphEdgeType`

to determine the type of edge between two linked
nodes. Depending on the selected graph type, an edge can be either an undirected arc
or an arrow, whereby arrows might point to both directions. Finally, you can compute
the thickness of an edge using the
`KBase.graphEdgeThickness`

method. Due to the complexity of the
underlying algorithm, this method takes quite a long time to finish.