generated from AlgebraicJulia/AlgebraicTemplate.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from AlgebraicJulia/AddNetWorkStructure
add schema composition method using structured cospan
- Loading branch information
Showing
9 changed files
with
121 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# this module defines some commonly used migration rules | ||
module MigrateRules | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# this moduel defines the basic networks | ||
module Networks | ||
|
||
using Catlab | ||
|
||
# using basic graph schemas as the schema of basic networks | ||
SchDirectedNetwork = SchGraph | ||
# # The Category of Graphs | ||
# | ||
# The Theory of Graphs is given by the following Schema: | ||
# ```julia | ||
# @present SchGraph(FreeSchema) begin | ||
# V::Ob | ||
# E::Ob | ||
# src::Hom(E,V) | ||
# tgt::Hom(E,V) | ||
# end | ||
|
||
SchUndirectedNetwork = SchSymmetricGraph | ||
|
||
# # Symmetric graphs | ||
# | ||
# @present SchSymmetricGraph <: SchGraph begin | ||
# inv::Hom(E,E) | ||
# compose(inv,inv) == id(E) | ||
# compose(inv,src) == tgt | ||
# compose(inv,tgt) == src | ||
#end | ||
|
||
SchUndirectedReflectiveNetwork = SchSymmetricReflexiveGraph | ||
|
||
# Symmetric reflexive graphs | ||
# | ||
# @present SchSymmetricReflexiveGraph <: SchSymmetricGraph begin | ||
# refl::Hom(V,E) | ||
# compose(refl, src) == id(V) | ||
# compose(refl, tgt) == id(V) | ||
# compose(refl, inv) == refl # Reflexive loop fixed by involution. | ||
#end | ||
|
||
|
||
end |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
module NetworkSchemaInterfaces | ||
|
||
using Test | ||
using StateCharts | ||
using Catlab | ||
|
||
# test schema of schema | ||
ob=(:S,:I,:R,:V) | ||
hom=(:SV=>(:S,:V), | ||
:IV=>(:I,:V), | ||
:RV=>(:R,:V)) | ||
|
||
|
||
schemaCSet=SchemaTheory(ob, hom, [], []) | ||
|
||
ob2=(:V) | ||
hom2=[] | ||
attrtype=[:SIR] | ||
attr=[:VSIR=>(:V,:SIR)] | ||
|
||
schemaACSet=SchemaTheory(ob2, hom2, attrtype,attr) | ||
|
||
# test composition of schemas - example 1: object person (which is V in this example) in state chart generated schema is identified | ||
# with the vertice object in basic graph. | ||
|
||
# Define basic graph schema | ||
BasicGraphSchema=SchemaTheory([:E,:V], [:src=>(:E,:V),:tgt=>(:E,:V)], [], []) | ||
|
||
# Compose the two schemas | ||
composedSchema=apex(compose(Open([:S],schemaCSet,[:V]),Open([:V],BasicGraphSchema,[:E]))) | ||
|
||
@test obnames(composedSchema) == [:S,:I,:R,:V,:E] | ||
@test homnames(composedSchema) == [:SV,:IV,:RV,:src,:tgt] | ||
|
||
# test composition of schemas - example 2: there is a morphism from the object person in state chart generated schema to | ||
# the vertice object in basic graph. | ||
|
||
schemaSIRP = SchemaTheory([:S,:I,:R,:P], [:SP=>(:S,:P),:IP=>(:I,:P),:RP=>(:R,:P)], [], []) | ||
schemaPV = SchemaTheory([:P,:V], [:PV=>(:P,:V)], [], []) | ||
composedSchema2 = (Open([:S],schemaSIRP,[:P]) · Open([:P],schemaPV,[:V])) · Open([:V],BasicGraphSchema,[:E]) |> apex | ||
# the syntax of compose can also using julia unicode of \cdotp | ||
|
||
@test obnames(composedSchema2) == [:S,:I,:R,:P,:V,:E] | ||
@test homnames(composedSchema2) == [:SP,:IP,:RP,:PV,:src,:tgt] | ||
|
||
end |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters