Skip to content

Latest commit

 

History

174 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

layout GoDoc Go Report Card

Experimental

Current version and API is in experimental stage. Property names may change.

Installation

The graph layouting can be used as a command-line tool and as a library.

To install the command-line tool:

go get -u github.com/loov/layout/cmd/glay

To install the package:

go get -u github.com/loov/layout

Usage

Minimal usage:

package main

import (
    "log"
    "os"

    "github.com/loov/layout"
    "github.com/loov/layout/format/svg"
)

func main() {
    graph := layout.NewDigraph()
    graph.Edge("A", "B")
    graph.Edge("A", "C")
    graph.Edge("B", "D")
    graph.Edge("C", "D")

    if err := layout.Hierarchical(graph); err != nil {
        log.Fatal(err)
    }

    svg.Write(os.Stdout, graph)
}

Output

See other examples in examples folder.

Other layouts and outputs:

  • layout.Force(graph) — force-directed layout for undirected or cyclic graphs.
  • layout.HierarchicalWith(graph, layout.Fast) or layout.Quality — trade crossings for time.
  • format/json — plain coordinates for drawing the graph elsewhere.
  • format/text — Unicode box-drawing output for terminals; call text.Prepare(graph) before laying out.

The same is available from the command line: glay -l force -q fast -t txt|json|svg|dot input.dot.

Quality

Currently the layout.Hierarchy algorithm output is significantly worse than graphviz. It is recommended to use graphviz dot, if possible.

About

Graph layouting package

Resources

Stars

25 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages