Go bindings for METIS - Serial Graph Partitioning and Fill-reducing Matrix Ordering
go get github.com/notargets/go-metis- METIS library (5.1.0 or later)
- CGO-enabled Go installation
# Install dependencies
sudo apt-get install build-essential cmake
# Build from source
git clone https://github.com/KarypisLab/GKlib.git
git clone https://github.com/KarypisLab/METIS.git
cd GKlib
make config prefix=/usr/local
sudo make install
cd ../METIS
make config shared=1 prefix=/usr/local gklib_path=/usr/local
sudo make install
sudo ldconfigbrew install metispackage main
import (
"fmt"
"log"
"github.com/notargets/go-metis"
)
func main() {
// Simple 4-node graph (square)
// 0 -- 1
// | |
// 2 -- 3
xadj := []int32{0, 2, 4, 6, 8}
adjncy := []int32{1, 2, 0, 3, 0, 3, 1, 2}
// Partition into 2 parts
part, edgeCut, err := metis.PartitionGraph(xadj, adjncy, 2)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Partitioning: %v\n", part)
fmt.Printf("Edge cut: %d\n", edgeCut)
}- Graph partitioning (k-way and recursive)
- Mesh partitioning
- Matrix reordering
- Graph coarsening
- Nested dissection (coming soon)
See GoDoc for detailed API documentation.
Check the examples directory for more usage examples.
go test -v ./...This project is licensed under the MIT License - see the LICENSE file for details.
Note: METIS itself is licensed under the Apache License 2.0.