0 | module Data.Graph.Indexed.Ring.Relevant.Types
2 | import public Data.Graph.Indexed
3 | import public Data.Graph.Indexed.Subgraph
4 | import public Data.Graph.Indexed.Query.Util
6 | import Data.SortedSet as SS
7 | import Derive.Prelude
10 | %language ElabReflection
18 | record Path (k : Nat) where
24 | path : SnocList (Fin k)
43 | %runElab deriveIndexed "Path" [Show,Eq]
47 | record NCycle (k : Nat) where
59 | {auto 0 prf : LTE 3 size}
61 | %runElab deriveIndexed "NCycle" [Show,Eq]
68 | 0 ECycle : Nat -> Type
69 | ECycle k = List (Edg k)
72 | record Cycle (k: Nat) where
76 | nodeset : SortedSet (Fin k)
77 | edgeset : SortedSet (Edg k)
80 | (.nodes) : Cycle k -> List (Fin k)
81 | (.nodes) c = drop 1 c.ncycle.path
83 | %runElab deriveIndexed "Cycle" [Show,Eq]
86 | ecycle : List (Fin k) -> ECycle k
88 | case mkEdge x y () of
89 | Just e => e :: ecycle (y::xs)
90 | Nothing => ecycle (y::xs)
94 | Cast (NCycle k) (Cycle k) where
96 | let es := ecycle n.path
97 | in C n es (SS.fromList n.path) (SS.fromList es)
101 | sharedNodes : (cx,cy : Cycle k) -> List (Fin k)
102 | sharedNodes cx cy =
103 | case cx.ncycle.size <= cy.ncycle.size of
104 | True => filter (`contains` cy.nodeset) cx.nodes
105 | False => filter (`contains` cx.nodeset) cy.nodes
109 | numSharedNodes : (cx,cy : Cycle k) -> Nat
110 | numSharedNodes cx cy =
111 | case cx.ncycle.size <= cy.ncycle.size of
112 | True => count (`contains` cy.nodeset) cx.nodes
113 | False => count (`contains` cx.nodeset) cy.nodes
117 | sharedEdges : (cx,cy : Cycle k) -> List (Edg k)
118 | sharedEdges cx cy =
119 | case cx.ncycle.size <= cy.ncycle.size of
120 | True => filter (`contains` cy.edgeset) cx.ecycle
121 | False => filter (`contains` cx.edgeset) cy.ecycle
125 | numSharedEdges : (cx,cy : Cycle k) -> Nat
126 | numSharedEdges cx cy =
127 | case cx.ncycle.size <= cy.ncycle.size of
128 | True => count (`contains` cy.edgeset) cx.ecycle
129 | False => count (`contains` cx.edgeset) cy.ecycle
133 | isFusedTo : (cx,cy : Cycle k) -> Bool
134 | isFusedTo cx cy = numSharedNodes cx cy == 2 && numSharedEdges cx cy == 1
138 | isSpiro : (cx,cy : Cycle k) -> Bool
139 | isSpiro cx cy = numSharedNodes cx cy == 1
142 | record CycleSets (k : Nat) where
144 | cr : List (Cycle k)
145 | mcb : List (Cycle k)
147 | %runElab deriveIndexed "CycleSets" [Show,Eq]
150 | data Candidates : (k : Nat) -> (e : Type) -> Type where
151 | Empty : Candidates k e
152 | Isolate : Subgraph k e Nat -> NCycle k -> Candidates k e
155 | -> ISubgraph o k e Nat