Skip to content

Commit

Permalink
GraphDisplay コンポーネントを紹介する
Browse files Browse the repository at this point in the history
  • Loading branch information
Seasawher committed Nov 18, 2024
1 parent e50f31f commit cb9f004
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions LeanByExample/Reference/Diagnostic/Html.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
-/
import ProofWidgets.Component.HtmlDisplay
import ProofWidgets.Component.Recharts
import ProofWidgets.Component.GraphDisplay

-- JSX ライクな構文が使えるようにする
open scoped ProofWidgets.Jsx
Expand Down Expand Up @@ -54,6 +55,28 @@ open ProofWidgets
for $\\mathrm{Re} (s) > 0$.
"}/>

end --#
/- ## GraphDisplay
`<GraphDisplay />` コンポーネントを使用すると、有向グラフを表示させることができます。
-/
section --#

open ProofWidgets Jsx GraphDisplay

/-- `Edge` を作る -/
def mkEdge (st : String × String) : Edge := {source := st.1, target := st.2}

/-- 文字列として与えられたラベルから `Vertex` を作る -/
def mkVertex (id : String) : Vertex := {id := id}

-- 有向グラフを表示する
#html
<GraphDisplay
vertices={#["a", "b", "c", "d", "e"].map mkVertex}
edges={#[("a","b"), ("b","c"), ("c","d"), ("d","e"), ("e", "a")].map mkEdge}
/>

end --#
/- ## LineChart
Expand Down

0 comments on commit cb9f004

Please sign in to comment.