-
Notifications
You must be signed in to change notification settings - Fork 51
Description
Right now, this project will respect the Vertex::getGroup()
method to group vertices into clusters, provided that at least 2 groups are set. In the future, this method will be removed via graphp/graph#114, so we should look into way to improve our subgraph/cluster support.
A simple switch would be to just use vertex attributes as suggested in the above ticket. For example, this could look like this:
$graph = new Graph();
$graph->createVertex()->setAttribute('group', 'A');
$graph->createVertex()->setAttribute('group', 'B');
The first benefit is that this now supports string groups instead of only integers. On top of this, we may also provide some API in this project to respect arbitrary attribute names as groups, for example like this:
$graph = new Graph();
$graph->createVertex()->setAttribute('language', 'php');
$graph->createVertex()->setAttribute('language', 'javascript');
$graphviz = new GraphVizRenderer();
$graphviz->setClusterAttribute('language');
$graphviz->render();
On top of this, we may also provide some kind of API to apply additional GraphViz attributes (https://github.com/graphp/graphviz#attributes) to each cluster, e.g. adding a background color or specal label to certain groups.
In a future version, we may also look into nested subgraphs/clusters. Implementing this isn't too hard, but we have yet to come up with a good API.