Skip to content

Instantly share code, notes, and snippets.

@slwu89
Created May 20, 2024 17:02
Show Gist options
  • Save slwu89/7825a84bc74c500e973d3c37f02932d6 to your computer and use it in GitHub Desktop.
Save slwu89/7825a84bc74c500e973d3c37f02932d6 to your computer and use it in GitHub Desktop.
temp thing for colored petri nets
using Catlab, AlgebraicRewriting, DataMigrations
@present SchLabledGraphToken <: SchLabeledGraph begin
TokenType::AttrType
Token::Ob
loc::Hom(Token,V)
token::Attr(Token,TokenType)
end
@abstract_acset_type AbstractLabeledGraphToken <: AbstractLabeledGraph
@acset_type LabeledGraphToken(SchLabledGraphToken, index=nameof.(generators(SchLabledGraphToken,:Hom))) <: AbstractLabeledGraphToken
mutable struct MyToken
name::String
size::Symbol
end
g = @acset LabeledGraphToken{Symbol,MyToken} begin
V=3
label=[:A,:B,:C]
E=2
src=[1,1]
tgt=[2,3]
end
to_graphviz(g, node_labels=:label)
mytoken = MyToken("job1", :small)
add_part!(g, :Token, loc=1, token=mytoken)
yLabeledGraphToken = yoneda(LabeledGraphToken{Symbol,MyToken})
Lb = @acset_colim yLabeledGraphToken begin
v::V
label(v) == :A
t::Token
loc(t) == v
end
Lb[1,:token] = MyToken("job1", :small)
Lb_matches = homomorphisms(Lb, g)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment