CPM/PERT diagrams (which Microsoft Project refers to by the ambiguous name of "network diagrams") are useful for planning what needs to be done in what order. Often thought of as a "one-off" project planning aid, more generally these precedence diagrams can be used for visualizing recurring procedures like the operations in a manufacturing assembly line, or even a guided procedure for business processes (like on-boarding an employee, which can include orientation, provisioning of equipment, granting security access, and of course forms to be filled out).
This application is based on Stefan Althoefer's Holiday Calendar Blog, which first showed how to generate diagrams from TWiki tables. In that respect, this blog is a sequel.
Where Stefan's application requires the EasyTimelinePlugin, this one requires the DirectedGraphPlugin. In both cases, the script that generates the graph can be tedious to work with, and so tables enhance the usability.
I prefer this application's diagrams to MS Project's because they are easier to configure, maintain, and read. It is also much easier collaborate on these diagrams with TWiki than to use MS Project's collaboration environment.
Here's an example of a finished precedence diagram, based on a familiar process. (Of course everyone puts their pants on one leg at a time, but here's proof! With shading applied to completed nodes, you can see that our subject has been caught with his left leg unpanted).
Figure 1: Sample Precedence Diagram - "How To Get Dressed"
the diagram in this topic is not dynamically updated because DirectedGraphPlugin and FilterPlugin are not installed at twiki.org.
How it Works
Step 1: Maintain Tables
Two data tables are used in this application:
The (mandatory) set of nodes (tasks or milestones) with the following fields/columns:
Node (row number): is the used by the predecessor field. To maintain the referential integrity nodes should not be renumbered, e.g., by deleting rows or sorting table. %EDITTABLE{changerows="add"}% was used to prevent rows from being deleted.
Label: text that appears in diagram. Use \n to force a line break (e.g. to change the appearance of a node symbol.
Predecessors: a text field of comma-separated values. It would have been nice to use a multiple select here instead, but neither EditTablePlugin nor EditRowPlugin support multiple selects at this time. Large projects could use a separate topic for each node, and a predecessor field in a TWikiForm (since those do support multiple selects). But to avoid "topic proliferation" I would rather have the content in one place if possible.
Milestone flag: an indicator to overload node the default node shape
Completed flag: an indicator to overload node the default node shading
Cluster name: a named group items (see below)
Notes: long text that describes the task or milestone.
The (optional) set of "clusters" or groups of nodes. These might be used to show sub-projects, or a set of tasks assigned to particular resource.
This application has "database-like" behaviour, in that the clusters defined in one table are used when maintaining the other, as shown below:
The original code for the cluster/subgraph section was a bit ugly because I couldn't get a newline to appear in the output of %EXTRACT%. For legibility of this article, I manually cleaned up the white space a bit (I cheated ).
Step 4: Generate the Diagram
The DirectedGraphPlugin calls Graphviz to generate the diagram from the .dot file.
Some Implementation Details
A space was inserted before each line in the cluster table, to differentiate the tables during data extraction (a different regular expression works too).
SEARCH strings like "\| ([0-9]*) are used to find all lines in the topic that have table data except for the table header, which does not a number in the first cell.
The predecessor extract skips nodes without predecessors by virtue of those cells containing only one space.
The node numbers were prefixed to the node labels (e.g., "1. START") as an aid when maintaining the predecessor lists.
Precedence (this was the trickiest bit): after the FilterPlugin EXTRACTs the row number and predecessor list, the SpreadSheetPlugin is used to split the comma-separated predecessors into separate entries. But since its SUBSTITUTE can't handle commas, they first had to be TRANSLATEd into semi-colons. But in the end:
Use the Graphviz imagemap feature to create links from nodes to the appropriate table row, for ease of maintenance. That would provide behaviour similar to clicking on a node in MS Project.
Fields for start dates, durations, resources... Gantt charts, and all the other stuff that MS Project has.
Edge labels: Graphviz has the ability to add labels to the lines (or 'edges'). Besides providing additional annotation, this could be used by those who prefer 'activity-on-the-line' diagrams to this 'activity-on-the-node' diagram.