Skip to content

Repository files navigation

go-metis

Go bindings for METIS - Serial Graph Partitioning and Fill-reducing Matrix Ordering

Go Reference Go Report Card CI

Installation

go get github.com/notargets/go-metis

Requirements

  • METIS library (5.1.0 or later)
  • CGO-enabled Go installation

Installing METIS

Ubuntu/Debian

# 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 ldconfig

macOS

brew install metis

Usage

package 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)
}

Features

  • Graph partitioning (k-way and recursive)
  • Mesh partitioning
  • Matrix reordering
  • Graph coarsening
  • Nested dissection (coming soon)

Documentation

See GoDoc for detailed API documentation.

Examples

Check the examples directory for more usage examples.

Testing

go test -v ./...

License

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.

About

Go bindings for METIS graph partitioning library

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages