Skip to content

dalzilio/nets

Repository files navigation

Nets

Nets is a Go library for parsing Petri nets, and Time Petri nets, written using the textual description format of the Tina toolbox. The format is defined in the section on the .net format described in the manual pages for Tina.

The library provides an exported type for dealing with Petri nets that can be useful to build new tools. We also provide methods to marshall a Net into a .net file or a PNML file for Place/Transition nets.

Go Report Card GoDoc Release

Installation

go get github.com/dalzilio/nets

Usage

You can find some examples of code in the *_test.go files and some example of .net files in directory testdata. The main function, Parse, returns a Net struct from an io.Reader.

package main

import (
  "fmt"
  "os"
  
  "github.com/dalzilio/nets"
)

func main() {
	file, _ := os.Open("testdata/sokoban_3.net")
	net, err := nets.Parse(file)
	if err != nil {
		log.Fatal("parsing error: ", err)
	}
	fmt.Printf("net %s has %d transitions\n", net.Name, len(net.Tr))
	// Output:
	// net Sokoban has 452 transitions
}

Dependencies

The library has no dependencies outside of the standard Go library. It uses Go modules and has been tested with Go 1.16.

License

This software is distributed under the GNU Affero GPL v3. A copy of the license agreement is found in the LICENSE file.

Authors

About

Nets is a Go library for parsing Petri nets, and Time Petri nets, written using the textual description format of the Tina toolbox

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages