PHPackages                             graphp/trivial-graph-format - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. graphp/trivial-graph-format

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

graphp/trivial-graph-format
===========================

Trivial Graph Format (TGF) is a simple text-based file format for describing graphs

v0.1.1(11y ago)43.5k3MITPHPPHP &gt;=5.3

Since Feb 24Pushed 5y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

graphp/trivial-graph-format
===========================

[](#graphptrivial-graph-format)

[![CI status](https://github.com/graphp/trivial-graph-format/workflows/CI/badge.svg)](https://github.com/graphp/trivial-graph-format/actions)

[Trivial Graph Format](http://en.wikipedia.org/wiki/Trivial_Graph_Format) (TGF) is a simple text-based file format for describing graphs.

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

**Table of contents**

- [Usage](#usage)
    - [TrivialGraphFormat](#trivialgraphformat)
        - [getOutput()](#getoutput)
- [Install](#install)
- [Tests](#tests)
- [License](#license)

Usage
-----

[](#usage)

### TrivialGraphFormat

[](#trivialgraphformat)

#### 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\TrivialGraphFormat\TrivialGraphFormat();
$data = $exporter->getOutput($graph);

file_put_contents('example.tgf', $data);
echo $data;
```

The TGF output will look something like this:

```
1 a
2 b
#
1 2

```

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

Note that TGF does not support the notion of directed and undirected edges. As such, this method will print two edges in opposite directions for any undirected edges.

Note that TGF does not support the notion of structured attributes. As such, this method will print the mathematical attributes as vertex and edge labels as appropriate.

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/trivial-graph-format": "~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

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% 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

Every ~11 days

Total

2

Last Release

4089d 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 (20 commits)")[![SimonFrings](https://avatars.githubusercontent.com/u/44357440?v=4)](https://github.com/SimonFrings "SimonFrings (4 commits)")

---

Tags

Trivial Graph FormatTGF

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/graphp-trivial-graph-format/health.svg)

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

###  Alternatives

[graphp/graphviz

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

3232.1M49](/packages/graphp-graphviz)[clue/graph-composer

Dependency graph visualization for composer.json

93798.0k11](/packages/clue-graph-composer)[graphp/algorithms

Common mathematical graph algorithms implemented in PHP

1402.9M14](/packages/graphp-algorithms)[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)
