Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve subgraph/cluster API #38

Open
clue opened this issue Oct 4, 2019 · 0 comments
Open

Improve subgraph/cluster API #38

clue opened this issue Oct 4, 2019 · 0 comments

Comments

@clue
Copy link
Member

clue commented Oct 4, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant