====== MindMap ======

**Priority: high**
**Difficulty: high**
**Status: draft**

We would really, really, *really* love a mindmap widget.

Use cases:
A) Have a dialog that shows the linking relations of the current page
B) Have the user draw the mindmap

In both cases the nodes of the mindmap would link to (non-existent) zim pages. This would greatly help when using zim for ordering brainstorms. Just draw a structure and start filling in the text for each node in the corresponding page.

NOTE: I talk about "mindmap" but technically I should be talking about a graph. Mindmaps are typically hierarchical in structure, while the linking structure of a notebook can contain arbitrary connections.

**Implementation:**
Since algorithms to layout graphs are a study in themselves we don't want to do that from scratch. There is an established graphing program that we should use: Graphviz (a.k.a. "dot"). The "neato" program is quite good at these kinds of graphs and can output both image maps and svg output that can be parsed to construct an interactive widget. Basically take the coordinates from neato to draw an image and attach signals to mouse clicks and figure out which node was clicked.

We can build a proof-of-concept using the Gtk2::Ex::Graphviz code from CPAN. Next step would be to build a similar widget based on Cairo. Cairo can import from SVG, so we just need to get the coordinates of the boxes and then let Cairo do the drawing.

See also [[ImageMap]].

One consequence of using a graph generated by Graphviz is that the user can not put nodes on arbitrary grid locations, the graph will not be interactive in that way. Even for use case B the user can only input relations.

For use case A we need controls in the dialog to limit the depth of the graph we display. A kind of zoom control. Also we would want to be able to navigate the graph etc.

Use case B can be implemented by have "add link" and "add node" buttons in the dialog that effectively add a new page or puts links in existing pages. (Remove link is a bit more tricky though but can be done by turning the linked text in normal text or something like that.)

For use case B we want a "interactive" way of adding nodes etc. but for the advanced user it is also nice to be able to put in the dot syntax directly. (Similar to the way you put in latex in the [[Usage:Plugins:EquationEditor|EquationEditor]] plugin.) When inputting dot syntax directly it still should be an option to have all nodes linked to zim pages. These are graphs independent of the automatic generated linking graph, so this would be a separate dialog and a separate menu item.

Another plan is to add types to links - see [[Linking]] - if this is implemented we would like to see those types in the graph. Also it would be a good option to be able to filter which types are displayed in the dialog - consider this like another way of zooming in and out.

Of course we can do all kinds of stuff with color coding etc. in the graph.
