Skip to content

A Javascript library to display and interact with Petri Nets.

License

Notifications You must be signed in to change notification settings

kyouko-taiga/petri-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

petri-js

A Javascript library to display and interact with Petri Nets.

Installation

To install the latest version (assuming you are using npm as your package manager):

npm install --save petri-js

petri-js is intended to be used as a CommonJS module, in a Webpack or Browserify environment. This lets you then import the module as follows:

import PetriNet from 'petri-js'

Usage

All you need to do is create an instance of simulator, a model to simulate and a SVG element it can renders to:

import PetriNet from 'petri-js'

// Create the Petri Net model:
const model = {
  places     : [ 'p0', 'p1' ],
  transitions: [
    {
      name          : 't1',
      preconditions : { 'p0': 1 },
      postconditions: { 'p1': 2 },
    },
    {
      name          : 't0',
      preconditions : { 'p1': 1 },
      postconditions: { 'p0': 1 },
    },
  ],
  m0: { 'p0': 1, 'p1': 0 },
}

// Create an instance of a simulator.
const petrinet = new PetriNet(document.getElementById('petrinet'), model)

By default, petri-js assumes the given models can be simulated with the semantics of classic Place/Transition (PT) nets.

About

A Javascript library to display and interact with Petri Nets.

Resources

License

Stars

Watchers

Forks

Packages