PHPackages                             graphp/graphml - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. graphp/graphml

ActiveLibrary

graphp/graphml
==============

GraphML is an XML-based file format for graphs

v0.1.0(10y ago)286.7k9[1 issues](https://github.com/graphp/graphml/issues)[1 PRs](https://github.com/graphp/graphml/pulls)1MITPHPPHP &gt;=5.3

Since Jun 7Pushed 5y ago2 watchersCompare

[ Source](https://github.com/graphp/graphml)[ Packagist](https://packagist.org/packages/graphp/graphml)[ Docs](https://github.com/graphp/graphml)[ RSS](/packages/graphp-graphml/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (1)

graphp/graphml
==============

[](#graphpgraphml)

[![CI status](https://github.com/graphp/graphml/workflows/CI/badge.svg)](https://github.com/graphp/graphml/actions)

[GraphML](http://graphml.graphdrawing.org/) is an XML-based file format for graphs

> Note: This project is in early beta stage! Feel free to report any issues you encounter.

**Table of contents**

- [Usage](#usage)
    - [Exporter](#exporter)
        - [getOutput()](#getoutput)
    - [Loader](#loader)
        - [loadContents()](#loadcontents)
- [Install](#install)
- [Tests](#tests)
- [License](#license)

Usage
-----

[](#usage)

### Exporter

[](#exporter)

#### getOutput()

[](#getoutput)

The `getOutput(Graph $graph): string` method can be used to export the given graph instance.

```
$graph = new Fhaculty\Graph\Graph();

$a = $graph->createVertex('a');
$b = $graph->createVertex('b');
$a->createEdgeTo($b);

$exporter = new Graphp\GraphML\Exporter();
$data = $exporter->getOutput($graph);

file_put_contents('example.graphml', $data);
```

This method only supports exporting the basic graph structure, with all vertices and directed and undirected edges.

Note that none of the attributes attached to any objects nor any of the "advanced concepts" of GraphML (Nested Graphs, Hyperedges and Ports) are currently implemented. We welcome PRs!

### Loader

[](#loader)

#### loadContents()

[](#loadcontents)

The `loadContents(string $contents): Graph` method can be used to load a graph instance from the given GraphML contents.

```
$data = file_get_contents('example.graphml');

$loader = new Graphp\GraphML\Loader();
$graph = $loader->loadContents($data);

foreach ($graph->getVertices() as $vertex) {
    foreach ($vertex->getVerticesEdgeTo() as other) {
        echo $vertex->getId() . ' connected with ' . $other->getId() . PHP_EOL;
    }
}
```

This method supports loading the graph, all vertices and directed and undirected edges among with any attributes attached from the GraphML source.

Note that neither of the "advanced concepts" of GraphML (Nested Graphs, Hyperedges and Ports) are currently implemented. We welcome PRs!

Install
-------

[](#install)

The recommended way to install this library is [through composer](http://getcomposer.org). [New to composer?](http://getcomposer.org/doc/00-intro.md)

```
{
    "require": {
        "graphp/graphml": "~0.1.0"
    }
}
```

This project aims to run on any platform and thus does not require any PHP extensions and supports running on legacy PHP 5.3 through current PHP 7+ and HHVM. It's *highly recommended to use PHP 7+* for this project.

Tests
-----

[](#tests)

To run the test suite, you first need to clone this repo and then install all dependencies [through Composer](https://getcomposer.org):

```
$ composer install
```

To run the test suite, go to the project root and run:

```
$ php vendor/bin/phpunit
```

License
-------

[](#license)

Released under the terms of the permissive [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 73.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3998d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/776829?v=4)[Christian Lück](/maintainers/clue)[@clue](https://github.com/clue)

---

Top Contributors

[![clue](https://avatars.githubusercontent.com/u/776829?v=4)](https://github.com/clue "clue (14 commits)")[![SimonFrings](https://avatars.githubusercontent.com/u/44357440?v=4)](https://github.com/SimonFrings "SimonFrings (4 commits)")[![tomzx](https://avatars.githubusercontent.com/u/188960?v=4)](https://github.com/tomzx "tomzx (1 commits)")

---

Tags

GraphMLGraph XML

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/graphp-graphml/health.svg)

```
[![Health](https://phpackages.com/badges/graphp-graphml/health.svg)](https://phpackages.com/packages/graphp-graphml)
```

###  Alternatives

[graphp/graphviz

GraphViz graph drawing for the mathematical graph/network library GraPHP.

3232.1M49](/packages/graphp-graphviz)[graphp/algorithms

Common mathematical graph algorithms implemented in PHP

1402.9M14](/packages/graphp-algorithms)[mamuz/php-dependency-analysis

Static code analysis to find violations in a dependency graph

573108.5k65](/packages/mamuz-php-dependency-analysis)[lmc/steward

Steward - makes Selenium WebDriver + PHPUnit testing easy and robust

222163.1k1](/packages/lmc-steward)[daveawb/understated

A PHP Finite State Machine for Laravel 5+

302.0k](/packages/daveawb-understated)[clue/graph-uml

Generate UML class diagrams by reflection for your PHP projects

231.4k](/packages/clue-graph-uml)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
