https://github.com/tmc/dot
graphviz dot language support for Go
https://github.com/tmc/dot
Last synced: 8 months ago
JSON representation
graphviz dot language support for Go
- Host: GitHub
- URL: https://github.com/tmc/dot
- Owner: tmc
- License: mit
- Created: 2012-09-23T02:38:49.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2024-07-07T23:16:45.000Z (almost 2 years ago)
- Last Synced: 2024-12-01T10:23:33.874Z (over 1 year ago)
- Language: Go
- Size: 969 KB
- Stars: 21
- Watchers: 4
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-graphviz - tmc/dot - graphviz dot language support for Go (Content / Language Bindings)
README
# dot
dot is a Go package that provides support for working with the DOT language, which is used for describing graphs in Graphviz.
## Features
- Create and manipulate graph structures
- Add nodes, edges, and subgraphs
- Set attributes for graphs, nodes, and edges
- Generate DOT language output
- Import and export graphs in DOT and JSON formats
- Graph analysis and algorithms (e.g., topological sort, shortest path)
- Graph visualization helpers (PNG and SVG output)
## Installation
To install the dot package, use the following command:
```
go install github.com/tmc/dot@latest
```
## Usage
Here's a simple example of how to use the dot package:
```go
package main
import (
"fmt"
"github.com/tmc/dot"
)
func main() {
g := dot.NewGraph("Example")
g.Set("label", "This is an example graph")
n1 := dot.NewNode("Node1")
n1.Set("shape", "box")
n2 := dot.NewNode("Node2")
n2.Set("color", "red")
g.AddNode(n1)
g.AddNode(n2)
e := dot.NewEdge(n1, n2)
e.Set("label", "connects to")
g.AddEdge(e)
fmt.Println(g.String())
}
```
This will output the DOT language representation of the graph.
## Documentation
For detailed documentation, please refer to the [GoDoc](https://pkg.go.dev/github.com/tmc/dot) page.
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.