Trivial Graph Format

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

Trivial Graph Format (TGF) is a simple text-based adjacency list file format for describing graphs,[1] widely used because of its simplicity.[2]

Format

[edit | edit source]

The format consists of a list of node definitions, which map node IDs to labels, followed by a list of edges, which specify node pairs and an optional edge label. Because of its lack of standardization, the format has many variations.[1] For instance, some implementations of the format require the node IDs to be integers,[3] while others allow more general alphanumeric identifiers.

Each node definition is a single line of text starting with the node ID, separated by a space from its label. The node definitions are separated from the edge definitions by a line containing the "#" character. Each edge definition is another line of text, starting with the two IDs for the endpoints of the edge separated by a space. If the edge has a label, it appears on the same line after the endpoint IDs.[3]

The graph may be interpreted as a directed or undirected graph. For directed graphs, to specify the concept of bi-directionality in an edge, one may either specify two edges (forward and back) or differentiate the edge by means of a label.

Example

[edit | edit source]

A simple graph with two nodes and one edge might look like:

1 First node
2 Second node
#
1 2 Edge between the two

See also

[edit | edit source]
  • yEd, a graph editor that can handle TGF file format.

References

[edit | edit source]
  1. ^ a b Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  2. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  3. ^ a b Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
[edit | edit source]