Clustering analysis¶
This page described how to use the available algorithms in RaGraph's
ragraph.analysis.cluster module as well as some in the
ragraph.analysis.heuristics module.
In general, clustering a Graph involves the grouping of components that
have many mutual or very strong dependencies (edges). One can also compute complete hierarchies by
clustering nodes in an iterative fashion (e.g. clusters of clusters).
Single level clustering¶
You can tweak some parameters later, but at minimal it suffices to supply a
Graph. Let's apply the Markov clustering algorithm
ragraph.analysis.cluster.markov to the Ford Climate Control
System dataset:
Which shows that our graph has been clustered into three new nodes, with some default naming for them. Lets review the hierarchy dictionary to view this in more detail:
The markov algorithm is a single-level clustering algorithm,
that gives you a single set of parent nodes (if any) for the given leaf nodes as input. If you
only supply a Graph it uses all the graph's leaf nodes.
In the example, we can identify three clusters that each has their own root. For many systems, it is intuitive to include an overarching system parent node.
We can do so by uncommenting the add_node function, and using the identified roots as the children of the overarching system node. Even better, we can employ a hierarchical clustering algorithm.
Hierarchical clustering¶
An example of hierarchical clustering using the Hierarchical Markov clustering algorithm
ragraph.analysis.cluster.hierarchical_markov would be the
following:
Where we can see that all three earlier found clusters have now also been recursively grouped together into a single root because of the interactions between their leaf nodes.
Hierarchical clustering with bus detection¶
We can also combine hierarchical clustering with bus detection. For this we are going to use the Aircraft Engine dataset. An example of using the
Hierarchical Markov clustering with bus detection ragraph.analysis.heuristics.markov_gamma is the following:
In the figure, we can find 11 clusters, and 3 bus components. The bus component spanning rows (1-8) is a global bus component, while the bus component at rows 47-54 and rows 55-60 are embedded in node3 and node1.
We can increase the granularity even further by repeating the Hierarchical Markov clustering with bus detection ragraph.analysis.heuristics.markov_gamma
for a specific cluster (root). The clustering parameters such as gamma can be different for each implementation. For demonstration purposes, we add node5 and node2 as roots to the markov_gamma. It is the responsibility of the modeller to determine if the granularity and parameters make sense.
An example could be:
Now, node5 and node3 are recursively grouped with more clusters, and new local bus components are found.
Warning
The Hierarchical Markov clustering with bus detection ragraph.analysis.heuristics.markov_gamma can be found under the module Heuristics, as it is a combination of algorithms.
Single level clustering and bus detection can be found at ragraph.analysis.cluster and ragraph.analysis.bus.