Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 1.04 KB

README.md

File metadata and controls

52 lines (38 loc) · 1.04 KB

go-nettle

Go Report Card

A foray into graph layout algorithms with golang. Implements the Barycentric Method described here.

Install

go get github.com/JohnCoene/go-nettle/nettle

Example

package main

import (
	"fmt"
	"go-nettle/nettle"
)

func main() {

	var nodes = []string{"India", "Canada", "Japan"}

	edges := make([]nettle.Edge, 3)
	edges[0] = nettle.Edge{
		Source: "India",
		Target: "Canada",
	}
	edges[1] = nettle.Edge{
		Source: "Canada",
		Target: "Japan",
	}
	edges[2] = nettle.Edge{
		Source: "Japan",
		Target: "India",
	}

	g := nettle.Graph{
		Nodes: nodes,
		Edges: edges,
	}

	gl := g.CreateGraph()

	gl = nettle.Layout(100, 100, 1, 5, gl)

	fmt.Println(gl)
}