Join the community

Data & AI

Graph theory in project scheduling: what the critical path doesn’t show you

9 min read Daniel Blázquez 0 comments

Graph theory in project scheduling treats your schedule as what it really is: a network of nodes (the activities) joined by edges (the relationships). Its metrics measure the structure of that network: which activities concentrate dependencies, where the logic crosses between packages and where it is incomplete. That is what the critical path doesn’t show you.

You are reviewing a programme with hundreds of activities. The critical path is clean and the float looks reasonable. Then someone in the meeting asks what happens if the engineering for one package is reorganised, and nobody knows how many activities depend on it.

Key takeaways

  • A schedule is a directed graph: activities are the nodes and relationships are the edges. CPM is already a graph algorithm.
  • The critical path measures float. Graph metrics measure structure: reach, betweenness and crossings between WBS packages.
  • An activity with float can hold up a large part of the network and still never appear on the critical path.
  • Before you measure anything, close the gaps in the logic: loops, relationships with a missing end and loose fragments.

What graph theory in project scheduling means

The same schedule as a Gantt chart and as a directed graph: six activities, their relationships and the critical path A, B, D, F

A graph is a set of nodes joined by edges. In a schedule, each activity is a node and each relationship (FS, SS, FF or SF) is an edge with a direction: it runs from the predecessor to the successor. It is a directed graph and, if the logic is right, it has no cycles.

Seen this way, every graph theory concept has an equivalent in your schedule:

Graph theory In your schedule
Node Activity or milestone
Directed edge Relationship, from predecessor to successor
Out-degree Number of direct successors
Descendants Every activity that depends on it, directly or indirectly
Cycle Logic loop: an activity that ends up depending on itself
Connected component A fragment of the network that doesn’t connect to the rest

CPM is already graph theory

The critical path method calculates the longest path through a directed graph with no cycles. That is applied graph theory, and it answers one question very well: which activities have no float. But it does so with a single measure, float, and the network has much more to tell you.

If what you want is to understand how the critical path is calculated, start with the critical path method. And if you want to show it alongside the sub-critical paths in your Primavera P6 reports, we explain how to do that too.

What the critical path doesn’t show you

The critical path answers «what slips if this slips?» with the float of each activity. It leaves three questions about the structure of the schedule unanswered:

  1. Which activities concentrate dependencies. An activity with float doesn’t appear on the critical path, but it can have a large part of the network downstream.
  2. Where the logic crosses between packages. The interfaces between WBS packages (engineering, procurement, construction) are the relationships that get argued about most and seen least in a table.
  3. Where the logic is incomplete. A loop, a relationship pointing to an activity that isn’t in the file or a loose fragment distorts the analysis before it starts.

I came to look at schedules this way by studying the Primavera P6 database. Years ago I found that graph theory let me understand a schedule far more deeply, beyond the critical path. That is why I built a tool to give planners a different view: to assess activities not only with CPM in the background, but with a more mathematical and analytical approach.

At Project 2080 we believe that reviewing only the critical path means reviewing half the schedule. The other half is its structure: how the activities are connected and which ones carry the most weight in the network.

See the structure of your schedule, free

Load your Primavera P6 XER into Schedule X-ray and see which activities concentrate dependencies, where the logic crosses between packages and where it is incomplete. It runs in your browser, with no sign-up.

X-ray my schedule

Graph metrics for analysing a schedule

Graph theory has many metrics. For a schedule, these four answer questions that planners actually ask.

Downstream reach

How many activities depend on one, directly or indirectly: its descendants in the graph. An activity with a large reach drags a big part of the schedule with it if its logic changes.

Betweenness

How many paths through the network pass through an activity. This is betweenness centrality from graph theory: for each pair of activities you count the shortest paths between them and see what share runs through it. High betweenness points to a logic bottleneck: an activity that joins parts of the network that would otherwise never touch.

Reach across WBS packages

How many other work packages sit downstream of an activity. It separates the activity that matters within one discipline from the one that feeds several disciplines or contracts.

Direct successors

The out-degree of the node: how many activities start straight after it. It is the simplest measure, and the closest to what you already see in the Relationships tab in P6.

Schedule X-ray combines these measures into a score that ranks activities by their weight in the structure. Its methodology view explains how each one is calculated.

Graph theory example: an eight-activity schedule

Eight-activity network example in which D concentrates the betweenness: nine paths pass through it

Example with made-up data: A opens two branches, B and C, which join at D. E and F leave D and finish at G. A second branch starts at H and feeds into F.

Activity Successors Downstream reach Betweenness
A B, C 6 0
B D 4 2
C D 4 2
D E, F 3 9
E G 1 2
F G 1 3
G — 0 0
H F 2 0

A has the largest reach, because everything starts there. But the key activity in the structure is D: any path from A, B or C to E, F or G goes through it, and that is nine pairs. F, with a betweenness of 3, is the other interface: it takes in the branch from H.

If D had float, it wouldn’t be on the critical path. Even so, any change to its logic would be felt in both halves of the schedule.

Common mistake
Reading connectivity as delay risk. An activity that concentrates dependencies is not going to slip because of it: it means that if it changes, it affects a lot of the network. Float and progress tracking are what tell you about delay.

Network integrity: the gaps to close first

Schedule X-ray with its sample schedule: a network of 315 activities coloured by total float

The metrics are only worth something if the network is complete. Before you measure anything, check for these five gaps:

  • Logic loops: an activity that ends up depending on itself. P6 flags them when it schedules the project.
  • Relationships with a missing end: they point to an activity that isn’t in the file, often from another project.
  • Isolated activities: no predecessors and no successors.
  • Open ends: activities with no predecessor or no successor that are neither the start nor the finish of the project. It is the logic check of the DCMA assessment, seen from the network.
  • Disconnected fragments: parts of the network that don’t connect to the rest.

Schedule X-ray runs 25 network integrity checks, these five among them.

How to apply graph theory to a Primavera P6 XER

Everything you need is in the XER file that P6 exports. There are four steps:

  1. Export the XER

    In File › Export, choose the XER format and the project you want to analyse.

  2. Find the two tables

    TASK holds the activities (task_id, task_code, wbs_id). TASKPRED holds the relationships: from pred_task_id to task_id, with the type in pred_type.

  3. Build the graph

    Each row in TASK is a node. Each row in TASKPRED is an edge from the predecessor to the successor.

  4. Check integrity, then measure

    Loops and fragments first. Then the reach and betweenness of each activity.

In Python, with the networkx library, it takes only a few lines:

import networkx as nx

def read_xer(path):
    tables, table, fields = {}, None, []
    with open(path, encoding="cp1252", errors="replace") as f:
        for line in f:
            parts = line.rstrip("\r\n").split("\t")
            if parts[0] == "%T":
                table = parts[1]
                tables[table] = []
            elif parts[0] == "%F":
                fields = parts[1:]
            elif parts[0] == "%R":
                tables[table].append(dict(zip(fields, parts[1:])))
    return tables

xer = read_xer("schedule.xer")
G = nx.DiGraph()
for t in xer["TASK"]:
    G.add_node(t["task_id"], code=t["task_code"], wbs=t["wbs_id"])
external = 0
for r in xer["TASKPRED"]:
    if r["pred_task_id"] in G and r["task_id"] in G:
        G.add_edge(r["pred_task_id"], r["task_id"], type=r["pred_type"])
    else:
        external += 1  # the other end is not in the file

print("Relationships with an end outside the file:", external)
print("No loops:", nx.is_directed_acyclic_graph(G))
print("Fragments:", nx.number_weakly_connected_components(G))

reach = {n: len(nx.descendants(G, n)) for n in G}
betweenness = nx.betweenness_centrality(G, normalized=False)
for n in sorted(G, key=betweenness.get, reverse=True)[:10]:
    print(G.nodes[n].get("code"), reach[n], round(betweenness[n], 1))

If you’d rather not write code, Schedule X-ray does all of this in your browser. And if you don’t have an XER to hand, you can try it with its sample schedule.

Frequently asked questions

What is a graph in project scheduling?

It is the schedule represented as nodes and edges: the activities are the nodes and the logic relationships are the edges. The precedence diagram you draw when you plan is already a directed graph.

Does graph theory replace the critical path method?

No. CPM is graph theory, and it is still how you find out which activities have no float. Structure metrics complement it: they don’t recalculate dates or predict delays, they describe how the network is built.

What is betweenness centrality in a schedule?

It measures how many of the shortest paths between pairs of activities pass through a given activity. High betweenness signals a logic bottleneck: an activity that joins parts of the network that would not otherwise connect.

Can you apply graph theory to a Microsoft Project schedule?

The concepts, yes: any schedule with logic relationships is a graph. Schedule X-ray reads Primavera P6 XER files; with Microsoft Project you would need to export the tasks and relationships and build the graph in code.

What we’d like you to remember at Project 2080

  • Close the gaps in the network first: loops, open ends and loose fragments.
  • Look for the activities with the largest downstream reach, even if they have float today.
  • Use betweenness to find the logic bottlenecks that join parts of the network.
  • Review the interfaces between WBS packages with whoever manages each package.
  • Don’t read connectivity as delay risk: that is what float and progress tracking are for.

Which activities hold your schedule together?

Find out with Schedule X-ray: free, in your browser and with no sign-up. If you don’t have an XER to hand, try it with the sample schedule.

X-ray my schedule

And if you want to stay up to date with what is happening in the industry, join the Project 2080 community: we only write when we have something genuinely worth your time.

¿Te ha gustado este contenido?

Share:

Leave a comment

Your email address will not be published. Required fields are marked with an asterisk.