{"id":13533796,"url":"https://github.com/graphp/graphviz","last_synced_at":"2026-04-01T20:44:13.169Z","repository":{"id":13683420,"uuid":"16377196","full_name":"graphp/graphviz","owner":"graphp","description":"GraphViz graph drawing for the mathematical graph/network library GraPHP.","archived":false,"fork":false,"pushed_at":"2023-10-16T07:28:12.000Z","size":98,"stargazers_count":324,"open_issues_count":8,"forks_count":54,"subscribers_count":15,"default_branch":"1.x","last_synced_at":"2026-03-26T13:52:40.989Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/graphp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2014-01-30T12:53:03.000Z","updated_at":"2026-03-17T03:39:25.000Z","dependencies_parsed_at":"2024-01-12T17:35:44.357Z","dependency_job_id":"b356a8e8-3735-40c8-b714-6d77cb798313","html_url":"https://github.com/graphp/graphviz","commit_stats":{"total_commits":46,"total_committers":5,"mean_commits":9.2,"dds":0.5652173913043479,"last_synced_commit":"24b1994071bb26d72eefb7fd886cb5a7dc749ff0"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/graphp/graphviz","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphp%2Fgraphviz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphp%2Fgraphviz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphp%2Fgraphviz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphp%2Fgraphviz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphp","download_url":"https://codeload.github.com/graphp/graphviz/tar.gz/refs/heads/1.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphp%2Fgraphviz/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31229293,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-31T09:14:28.471Z","status":"ssl_error","status_checked_at":"2026-03-31T09:14:19.506Z","response_time":111,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T07:01:23.194Z","updated_at":"2026-04-01T20:44:13.140Z","avatar_url":"https://github.com/graphp.png","language":"PHP","readme":"# graphp/graphviz\n\n[![CI status](https://github.com/graphp/graphviz/workflows/CI/badge.svg)](https://github.com/graphp/graphviz/actions)\n\nGraphViz graph drawing for the mathematical graph/network library GraPHP.\n\n\u003e **Development version:** This branch contains the code for the upcoming 1.0 release.\n\u003e For the code of the current stable 0.2 release, check out the\n\u003e [`0.2.x` branch](https://github.com/graphp/graphviz/tree/0.2.x).\n\u003e\n\u003e The upcoming 1.0 release will be the way forward for this package.\n\u003e However, we will still actively support 0.2.x for those not yet\n\u003e on the latest version.\n\u003e See also [installation instructions](#install) for more details.\n\nThe library supports visualizing graph images, including them into webpages,\nopening up images from within CLI applications and exporting them\nas PNG, JPEG or SVG file formats (among many others).\nBecause [graph drawing](http://en.wikipedia.org/wiki/Graph_drawing) is a complex area on its own,\nthe actual layouting of the graph is left up to the excelent [GraphViz](http://www.graphviz.org/)\n\"Graph Visualization Software\" and we merely provide some convenient APIs to interface with GraphViz.\n\n**Table of contents**\n\n* [Quickstart examples](#quickstart-examples)\n* [Attributes](#attributes)\n  * [Graph attributes](#graph-attributes)\n  * [Vertex attributes](#vertex-attributes)\n  * [Edge attributes](#edge-attributes)\n* [Labels](#labels)\n  * [Vertex labels](#vertex-labels)\n  * [Edge labels](#edge-labels)\n  * [HTML-like labels](#html-like-labels)\n  * [Record-based nodes](#record-based-nodes)\n* [Install](#install)\n* [Tests](#tests)\n* [License](#license)\n\n## Quickstart examples\n\nOnce [installed](#install), let's build and display a sample graph:\n\n````php\n$graph = new Graphp\\Graph\\Graph();\n\n$blue = $graph-\u003ecreateVertex();\n$blue-\u003esetAttribute('id', 'blue');\n$blue-\u003esetAttribute('graphviz.color', 'blue');\n\n$red = $graph-\u003ecreateVertex();\n$red-\u003esetAttribute('id', 'red');\n$red-\u003esetAttribute('graphviz.color', 'red');\n\n$edge = $graph-\u003ecreateEdgeDirected($blue, $red);\n$edge-\u003esetAttribute('graphviz.color', 'grey');\n\n$graphviz = new Graphp\\GraphViz\\GraphViz();\n$graphviz-\u003edisplay($graph);\n````\n\nThe above code will open your default image viewer with the following image:\n\n![red-blue](examples/01-simple.png)\n\nSee also the [examples](examples/).\n\n## Attributes\n\nGraphViz supports a number of attributes on the graph instance itself, each\nvertex instance (GraphViz calls these \"nodes\") and edge instance. Any of these\nGraphViz attributes are supported by this library and have to be assigned using\nGraPHP attributes as documented below.\n\nFor the full list of all GraphViz attributes, please refer to the\n[GraphViz documentation](https://graphviz.gitlab.io/_pages/doc/info/attrs.html).\n\nNote that all attributes use UTF-8 encoding (Unicode) and will be quoted and\nescaped by default, so a `ö` and `\u003e` will appear as-is and will not be\ninterpreted as HTML. See also [HTML-like labels](#html-like-labels) below for\nmore details.\n\n### Graph attributes\n\nGraphViz supports a number of attributes on the graph instance itself. Any of\nthese GraphViz attributes are supported by this library and have to be assigned\non the graph instance with the `graphviz.graph.` prefix like this:\n\n```php\n$graph = new Graphp\\Graph\\Graph();\n$graph-\u003esetAttribute('graphviz.graph.bgcolor', 'transparent');\n```\n\n\u003e Note how this uses the `graphviz.graph.` prefix and not just `graphviz.`. This\n  is done for consistency reasons with respect to default vertex and edge\n  attributes as documented below.\n\nFor example, the `rankdir` attribute can be used to change the orientation to\nhorizontal mode (left to right) like this:\n\n```php\n$graph = new Graphp\\Graph\\Graph();\n$graph-\u003esetAttribute('graphviz.graph.rankdir', 'LR');\n\n$hello = $graph-\u003ecreateVertex();\n$hello-\u003esetAttribute('id', 'hello');\n$world = $graph-\u003ecreateVertex();\n$world-\u003esetAttribute('id', 'wörld');\n$graph-\u003ecreateEdgeDirected($hello, $world);\n```\n\n![html graph example](examples/02-html.png)\n\nSee also the [examples](examples/).\n\nAdditionally, this library accepts an optional `graphviz.name` attribute that\nwill be used as the name (or ID) for the root graph object in the DOT output if\ngiven. Unless explicitly assigned, this will be omitted by default. It is common\nto assign a `G` here, but usually there should be no need to assign this. Among\nothers, this may be used as the title or tooltip in SVG output.\n\n```php\n$graph = new Graphp\\Graph\\Graph();\n$graph-\u003esetAttribute('graphviz.name', 'G');\n\n$graph-\u003ecreateVertex();\n```\n\n### Vertex attributes\n\nGraphViz supports a number of attributes on each vertex instance (GraphViz calls\nthese \"node\" attributes). Any of these GraphViz attributes are supported by this\nlibrary and have to be assigned on the respective vertex instance with the\n`graphviz.` prefix like this:\n\n```php\n$graph = new Graphp\\Graph\\Graph();\n\n$blue = $graph-\u003ecreateVertex();\n$blue-\u003esetAttribute('graphviz.color', 'blue');\n```\n\nAdditionally, GraphViz also supports default attributes for all vertices. Any of\nthese GraphViz attributes are supported by this library and have to be assigned\non the graph instance with the `graphviz.node.` prefix like this:\n\n```php\n$graph = new Graphp\\Graph\\Graph();\n$graph-\u003esetAttribute('graphviz.node.color', 'grey');\n\n$grey = $graph-\u003ecreateVertex();\n```\n\nThese default attributes can be overriden on each vertex instance by explicitly\nassigning the same attribute on the respective vertex instance like this:\n\n```php\n$graph = new Graphp\\Graph\\Graph();\n$graph-\u003esetAttribute('graphviz.node.color', 'grey');\n\n$blue = $graph-\u003ecreateVertex();\n$blue-\u003esetAttribute('graphviz.color', 'blue');\n```\n\n\u003e Note how this uses the `graphviz.node.` prefix and not `graphviz.vertex.`. This\n  is done for consistency reasons with respect to how GraphViz assigns these\n  default attributes in its DOT output.\n\n### Edge attributes\n\nGraphViz supports a number of attributes on each edge instance. Any of these\nGraphViz attributes are supported by this library and have to be assigned on the\nrespective edge instance with the `graphviz.` prefix like this:\n\n```php\n$graph = new Graphp\\Graph\\Graph();\n\n$a = $graph-\u003ecreateVertex();\n$b = $graph-\u003ecreateVertex();\n\n$blue = $graph-\u003ecreateEdgeDirected($a, $b);\n$blue-\u003esetAttribute('graphviz.color', 'blue');\n```\n\nAdditionally, GraphViz also supports default attributes for all edges. Any of\nthese GraphViz attributes are supported by this library and have to be assigned\non the graph instance with the `graphviz.edge.` prefix like this:\n\n```php\n$graph = new Graphp\\Graph\\Graph();\n$graph-\u003esetAttribute('graphviz.edge.color', 'grey');\n\n$a = $graph-\u003ecreateVertex();\n$b = $graph-\u003ecreateVertex();\n\n$grey = $graph-\u003ecreateEdgeDirected($a, $b);\n```\n\nThese default attributes can be overriden on each edge instance by explicitly\nassigning the same attribute on the respective edge instance like this:\n\n```php\n$graph = new Graphp\\Graph\\Graph();\n$graph-\u003esetAttribute('graphviz.edge.color', 'grey');\n\n$a = $graph-\u003ecreateVertex();\n$b = $graph-\u003ecreateVertex();\n\n$blue = $graph-\u003ecreateEdgeDirected($a, $b);\n$blue-\u003esetAttribute('graphviz.color', 'blue');\n```\n\n## Labels\n\n### Vertex labels\n\nBy default, GraphViz will always render the vertex ID as the label.\nIf you do not assign an explicit `id` attribute to a vertex, this library will\nautomatically assign a vertex ID starting at `1` in the DOT output and GraphViz\nwill automatically render this vertex ID as the label. The following example\nwill automatically assign `1` and `2` as the label:\n\n```php\n$graph = new Graphp\\Graph\\Graph();\n\n$v1 = $graph-\u003ecreateVertex();\n$v2 = $graph-\u003ecreateVertex();\n```\n\nIf you assign an `id` attribute to a vertex, this library will automatically\nuse it as the vertex ID in the DOT output and GraphViz will automatically render\nthis vertex ID as the label. The following example will automatically assign\n`blue` as the label:\n\n```php\n$graph = new Graphp\\Graph\\Graph();\n\n$a = $graph-\u003ecreateVertex();\n$a-\u003esetAttribute('id', 'blue');\n```\n\nIf you assign a `balance` attribute to a vertex, this library will automatically\ninclude a `label` attribute that appends the balance value in parenthesis. The\nfollowing example will automatically assign `blue (+10)` as the label:\n\n```php\n$graph = new Graphp\\Graph\\Graph();\n\n$blue = $graph-\u003ecreateVertex();\n$blue-\u003esetAttribute('id', 'blue');\n$blue-\u003esetAttribute('balance', 10);\n```\n\nYou can use [vertex attributes](#vertex-attributes) to explicitly assign a\ncustom `label` attribute. Note that any balance value will still be appended\nlike in the previous example.\n\n```php\n$graph = new Graphp\\Graph\\Graph();\n\n$blue = $graph-\u003ecreateVertex();\n$blue-\u003esetAttribute('id', 'blue');\n$blue-\u003esetAttribute('graphviz.label', 'Hello world!');\n```\n\nNote that all [attributes](#attributes) will be quoted and escaped by default,\nso a `\u003e` will appear as-is and will not be interpreted as HTML. See also\n[HTML-like labels](#html-like-labels) below for more details.\n\nAlso note that you should either define *no* vertex IDs at all or *all* vertex\nIDs. If you only define *some* vertex IDs, the automatic numbering may yield a\nvertex ID that is already used explicitly and overwrite some of its settings.\n\n### Edge labels\n\nBy default, GraphViz will not render any label on an edge:\n\n```php\n$graph = new Graphp\\Graph\\Graph();\n\n$a = $graph-\u003ecreateVertex();\n$b = $graph-\u003ecreateVertex();\n\n$edge = $graph-\u003ecreateEdgeDirected($a, $b);\n```\n\nIf you assign a `flow`, `capacity` or `weight` attribute to an edge, this library\nwill automatically include a `label` attribute that includes these values. The\nfollowing example will automatically assign `100` as the label for the weighted\nedge:\n\n```php\n$graph = new Graphp\\Graph\\Graph();\n\n$a = $graph-\u003ecreateVertex();\n$b = $graph-\u003ecreateVertex();\n\n$edge = $graph-\u003ecreateEdgeDirected($a, $b);\n$edge-\u003esetAttribute('weight', 100);\n```\n\nThe following example will automatically assign `4/10` as the label for an edge\nwith both flow and maximum capacity set:\n\n```php\n$graph = new Graphp\\Graph\\Graph();\n\n$a = $graph-\u003ecreateVertex();\n$b = $graph-\u003ecreateVertex();\n\n$edge = $graph-\u003ecreateEdgeDirected($a, $b);\n$edge-\u003esetAttribute('flow', 4);\n$edge-\u003esetAttribute('capacity', 10);\n```\n\nThe following example will automatically assign `4/∞/100` as the label for a\nweighted edge with a flow and unlimited capacity:\n\n```php\n$graph = new Graphp\\Graph\\Graph();\n\n$a = $graph-\u003ecreateVertex();\n$b = $graph-\u003ecreateVertex();\n\n$edge = $graph-\u003ecreateEdgeDirected($a, $b);\n$edge-\u003esetAttribute('flow', 4);\n$edge-\u003esetAttribute('capacity', null);\n$edge-\u003esetAttribute('weight', 100);\n```\n\nYou can use [edge attributes](#edge-attributes) to explicitly assign any\ncustom `label` attribute. Note that any flow, capacity or weight value will still\nbe appended like in the previous examples.\n\n```php\n$graph = new Graphp\\Graph\\Graph();\n\n$a = $graph-\u003ecreateVertex();\n$b = $graph-\u003ecreateVertex();\n\n$edge = $graph-\u003ecreateEdgeDirected($a, $b);\n$edge-\u003esetAttribute('graphviz.label', 'important');\n```\n\n### HTML-like labels\n\nNote that all [attributes](#attributes) will be quoted and escaped by default,\nso a `\u003e` will appear as-is and will not be interpreted as HTML. GraphViz also\nsupports [HTML-like labels](https://graphviz.gitlab.io/_pages/doc/info/shapes.html#html)\nthat support a subset of HTML features.\n\nGraphViz requires any HTML-like label to be wrapped in `\u003c` and `\u003e` and only\nsupports a limited subset of HTML features as documented above. In order to\nprevent automatic quoting and escaping, all HTML-like attribute values need to\nbe passed with a trailing `_html` in the attribute name like this:\n\n```php\n$graph = new Graphp\\Graph\\Graph();\n\n$a = $graph-\u003ecreateVertex();\n$a-\u003esetAttribute('id', 'Entity');\n$a-\u003esetAttribute('graphviz.shape', 'none');\n$a-\u003esetAttribute('graphviz.label_html', '\n\u003ctable cellspacing=\"0\" border=\"0\" cellborder=\"1\"\u003e\n    \u003ctr\u003e\u003ctd bgcolor=\"#eeeeee\"\u003e\u003cb\u003e\\N\u003c/b\u003e\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e+ touch()\u003c/td\u003e\u003c/tr\u003e\n\u003c/table\u003e');\n\n$b = $graph-\u003ecreateVertex();\n$graph-\u003ecreateEdgeDirected($b, $a);\n$b-\u003esetAttribute('id', 'Block');\n$b-\u003esetAttribute('graphviz.shape', 'none');\n$b-\u003esetAttribute('graphviz.label_html', '\n\u003ctable cellspacing=\"0\" border=\"0\" cellborder=\"1\"\u003e\n    \u003ctr\u003e\u003ctd bgcolor=\"#eeeeee\"\u003e\u003cb\u003e\\N\u003c/b\u003e\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e- size:int\u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\u003ctd\u003e+ touch()\u003c/td\u003e\u003c/tr\u003e\n\u003c/table\u003e');\n```\n\n![UML html graph example](examples/11-uml-html.png)\n\nSee also the [examples](examples/).\n\n### Record-based nodes\n\nNote that all [attributes](#attributes) will be quoted and escaped by default,\nso a `\u003e` will appear as-is and will not be interpreted as HTML. Similar to the\nabove [HTML-like labels](#html-like-labels), GraphViz also supports simple\n[record-based nodes](https://graphviz.gitlab.io/_pages/doc/info/shapes.html#record)\nusing the `record` and `Mrecord` shape attributes and structured label attributes.\n\nGraphViz requires any record-based node label to be quoted, but uses special\nsyntax to mark record fields and optional port names. In order to prevent\nautomatic quoting and escaping, all record-based attribute values need to\nbe passed with a trailing `_record` in the attribute name like this:\n\n```php\n$graph = new Graphp\\Graph\\Graph();\n\n$a = $graph-\u003ecreateVertex();\n$a-\u003esetAttribute('graphviz.shape', 'Mrecord');\n$a-\u003esetAttribute('graphviz.label_record', '\u003cf0\u003e left |\u003cmiddle\u003e middle |\u003cf2\u003e right'));\n\n$b = $graph-\u003ecreateVertex();\n$b-\u003esetAttribute('graphviz.shape', 'Mrecord');\n$b-\u003esetAttribute('graphviz.label_record', '\u003cf0\u003e left |\u003cf1\u003e middle |\u003cright\u003e right'));\n\n// a:middle -\u003e b:right\n$edge = $graph-\u003ecreateEdgeDirected($a, $b);\n$edge-\u003esetAttribute('graphviz.tailport', 'middle');\n$edge-\u003esetAttribute('graphviz.headport', 'right');\n```\n\n![records with ports graph example](examples/13-record-ports.png)\n\nSee also the [examples](examples/).\n\n## Install\n\nThe recommended way to install this library is [through Composer](https://getcomposer.org/).\n[New to Composer?](https://getcomposer.org/doc/00-intro.md)\n\nOnce released, this project will follow [SemVer](https://semver.org/).\nAt the moment, this will install the latest development version:\n\n```bash\ncomposer require graphp/graphviz:^1@dev graphp/graph:^1@dev\n```\n\nSee also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.\n\nThis project aims to run on any platform and thus does not require any PHP\nextensions and supports running on legacy PHP 5.3 through current PHP 7+.\nIt's *highly recommended to use PHP 7+* for this project.\n\nThe graph drawing feature is powered by the excellent [GraphViz](https://www.graphviz.org)\nsoftware. This means you'll have to install GraphViz (`dot` executable).\nThe [Graphviz homepage](https://www.graphviz.org/download/) includes complete\ninstallation instructions for most common platforms, users of Debian/Ubuntu-based\ndistributions may simply invoke:\n\n```bash\nsudo apt install graphviz\n```\n\n## Tests\n\nTo run the test suite, you first need to clone this repo and then install all\ndependencies [through Composer](https://getcomposer.org/):\n\n```bash\ncomposer install\n```\n\nTo run the test suite, go to the project root and run:\n\n```bash\nvendor/bin/phpunit\n```\n\n## License\n\nThis project is released under the permissive [MIT license](LICENSE).\n","funding_links":[],"categories":["PHP","Uncategorized","Content"],"sub_categories":["Uncategorized","Language Bindings"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphp%2Fgraphviz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphp%2Fgraphviz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphp%2Fgraphviz/lists"}