Where to Find Up-to-date yFiles Information

This page is from the outdated yFiles for Java 2.13 documentation. You can find the most up-to-date documentation for all yFiles products on the yFiles documentation overview page.

Please see the following links for more information about the yFiles product family of diagramming programming libraries and corresponding yFiles products for modern web apps, for cross-platform Java(FX) applications, and for applications for the Microsoft .NET environment.

More about the yFiles product family Close X


TGF, the "Trivial Graph Format," supports the pure graph structure together with (at most) one label per graph element. Anything related to position, dimension, or visual representation is ignored. Also, TGF does not provide support for nested graph structures.

What it Looks Like

Example 9.22, “TGF representation” shows the TGF representation for the example graph from Figure 9.5, “A simple graph”.

Figure 9.5. A simple graph

A simple graph.

Example 9.22. TGF representation

1 January
2 March
3 April
4 May
5 December
6 June
7 September
1 2
3 2
4 3
5 1 Happy New Year!
5 3 April Fools Day
6 3
6 1
7 5
7 6
7 1

Common Usage

A TGF file is written using class TGFIOHandler. The code fragment in Example 9.23, “Instantiating a TGFIOHandler” shows how to instantiate a TGFIOHandler and using it to write a graph to file.

Example 9.23. Instantiating a TGFIOHandler

// Instantiate a TGF I/O handler and write the graph to file. 
IOHandler ioh = new TGFIOHandler();
writeGraphToFile(graph, ioh, "MyTGF.tgf");

By means of the following setter methods both writing and reading of node labels and edge labels, respectively can be controlled:

void setIgnoreNodeLabels(boolean ignore)
void setIgnoreEdgeLabels(boolean ignore)
Description Setter methods from class TGFIOHandler.


Due to the lack of support for both coordinates and dimensions reading a graph from a TGF file can result in a representation that differs from the exported graph.