Macaulay2 » Documentation
Packages » Nauty :: graphToString
next | previous | forward | backward | up | index | toc

# graphToString -- converts a graph to a string in the Graph6 format

- Usage:
    `S = graphToString(E, n)`
    `S = graphToString I`
    `S = graphToString G`
    `S = graphToString T`
- Inputs:
  - E, a list, a list of edge pairs
  - n, an integer, the number of vertices in the graph, must be positive (see caveat)
  - I, an ideal, the edge ideal of a graph
  - G, a graph,
  - T, a string, a string containing a graph; the string automatically passes through untouched
- Outputs:
  - S, a string, the graph converted to a Graph6 format string

## Description

This method converts various ways of representing a graph into nauty's Graph6 string format. Note that if the Ideal (or MonomialIdeal) passed to the method is not squarefree and monomial, then the method may have unknown and possibly undesired results.

In this example, all graphs are the 5-cycle.

    i1 : graphToString({{0,1}, {1,2}, {2,3}, {3,4}, {0,4}}, 5)

    o1 = Dhc

    i2 : R = QQ[a..e];

    i3 : graphToString monomialIdeal (a*c, a*d, b*d, b*e, c*e)

    o3 = DUW

    i4 : graphToString cycle R

    o4 = Dhc

    i5 : graphToString "Dhc"

    o5 = Dhc

We note that if the input is a string, then the output is simply that string returned, regardless of format or correctness.

## Caveat

Notice that if using a List and number of vertices input to create the string, then the List must have vertices labeled $0$ to $n-1$.

The number of vertices $n$ must be positive as nauty cannot handle graphs with zero vertices.

## See also

- Comparison of Graph6 and Sparse6 formats
- graph6ToSparse6 -- converts a Graph6 string to a Sparse6 string
- sparse6ToGraph6 -- converts a Sparse6 string to a Graph6 string
- stringToGraph -- converts a Sparse6 or Graph6 String to a Graph in the given polynomial ring

## Ways to use graphToString:

- `graphToString(Graph)`
- `graphToString(Ideal)`
- `graphToString(List,ZZ)`
- `graphToString(MonomialIdeal)`
- `graphToString(String)`

## For the programmer

The object graphToString is a method function.

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Nauty.m2:1299:0.