acsets.petris

In this model, we define a schema for petri nets, and then a subclass of acset with some convenience methods.

class Petri(name='Petri', schema=<acsets.acsets.Schema object>)[source]

A subclass of ACSet customized for petri nets.

sir = Petri()
s,i,r = sir.add_species(3)
sir.set_subpart(s,attr_sname,"susceptible")
sir.set_subpart(s,attr_sprop, { "uuid": "dae22e85-d941-4156-b559-d153a44356f3" })
inf = sir.add_transitions([([s,i],[i,i])])
sir.set_subpart(inf,attr_tname,"infection")
sir.set_subpart(inf,attr_tprop, { "uuid": "bba26d0e-3ce5-41e5-ac0e-6be35535d534" })

Initialize a new petri net.

add_species(n)[source]

Add n number of species to the petri net

Return type:

range

Args:

n: The number of species to add to the petri net.

Returns:

A range of the indexes of the species that were inserted into the petri net.

add_transitions(transitions)[source]

Add transitions to the petri net

Return type:

range

Args:

transitions: A list of tuples where each tuple has two items: the first is a list of the input species and the second is a list of the output species.

Returns:

A range of the of the indexes of the transitions that were inserted into the petri net.