# Examples --- ## Title of the slide Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. --- ## Unordered lists - Lorem ipsum dolor sit amet, - consectetur adipiscing elit, - sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. --- ## Ordered lists 1. Lorem ipsum dolor sit amet, 2. consectetur adipiscing elit, 3. sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. --- ## Ordered lists (the easy way) If you are in a lazy mood, you can let markdown calculate the numbers. Just use `1.` for all list entries, instead of `1.`, `2.`, `3.`, ... (see the source code in the markdown file). 1. Lorem ipsum dolor sit amet, 1. consectetur adipiscing elit, 1. sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. _Tip: Editors with markdown support often fix these numbers automatically._ --- ## Citation Some pretty quote: > The problem with 83% of the quotes found on the internet is, that they are not true. > > ~ Abraham Lincoln. Some text here. --- ## Links, bold, italic, strikethrough [Link to website](https://www.hogent.be) . You can also just type the URL: https://www.hogent.be . Text in **bold**. _Italic_ text. This text has been ~~stricken~~. --- ## Emoji's 🎉 😄 👍 💯 🔗 💬 🔧 🚧 ⚠️ ❗ 🚫 ⛔ ❌ - https://github.com/ikatyang/emoji-cheat-sheet/blob/master/README.md - https://gitmoji.dev/ - https://emoojees.com/ --- ## HTML entities ≠ ≈ • ⧉ ⦻ ⦰ © ♪ ♭ ♯ ✓ ✗ ♀ ♂ ← ↔ → ↵ ⟵ ⟷ ⟶ α β θ ω ♠ ♣ ♥ ♦ - https://www.freeformatter.com/html-entities.html - https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references --- ## Math You can use [LaTeX / KaTeX](https://katex.org/) math notations: $$ S_n(x)=\sum_{k=1}^n \frac{\sin(kx)}{k} \gt 0\quad (n\geq 1,\quad 0 \lt x \lt \pi) $$ --- ## Tables | Left-aligned | Middle-aligned | Right-aligned | Auto | | :----------- | :------------: | ------------: | ---- | | aaa | bbb | ccc | ddd | | 000 | 111 | 222 | 333 | _Tip: Editors with markdown support often auto align markdown tables so they also look pretty in the source code. Saves you a lot of spaces to type!_ --- ## Images ![](./img/hello.webp) Image too small or too big? Look at the advanced examples to learn about specifying height or width. --- ### GIF's ![Rotating molecule](./img/molecule.gif) --- ## Inline source code Variables `iso`, `iso_size` and `destination` belong to function `copy_iso_to_usb()`. --- ## Source code Some pretty code: ```java public void test() { String words = "Hello world!"; int[] numbers = {0, 1, 42, 1337}; System.out.println(words); // Print each number in the array for (int n : numbers) { System.out.println(n); } System.out.println("Well this is a very long line of code, I wonder how it will wrap? Do you know? I am very curious ... . Well, let's find out, shall we!"); } ``` --- ## Line numbers You can add line numbers automatically by adding `[]` brackets (see the markdown source): ```java [] public void test() { String words = "Hello world!"; int[] numbers = {0, 1, 42, 1337}; System.out.println(words); // Print each number in the array for (int n : numbers) { System.out.println(n); } System.out.println("Well this is a very long line of code, I wonder how it will wrap? Do you know? I am very curious ... . Well, let's find out, shall we!"); } ``` --- ## Code highlights It even allows for code highlights to follow! Currently, it is best to place such code fragments on a slide of their own ... --- ```cpp [1-3|20-21|97|103|218|388] // Copyright (C) 2020 Martijn Saelens // // SPDX-License-Identifier: MIT #ifndef GRAPH_HPP #define GRAPH_HPP #include "nlohmann/json.hpp" #include
#include
#include
#include
#include
template
class graph { private: class vertex; class edge; public: friend void swap(graph& lhs, graph& rhs) { std::swap(lhs.m_vertices, rhs.m_vertices); std::swap(lhs.m_freed_vertex_ids, rhs.m_freed_vertex_ids); std::swap(lhs.m_edges, rhs.m_edges); std::swap(lhs.m_freed_edge_ids, rhs.m_freed_edge_ids); } // Functions /////////////////////////////////////////////////////////////// std::ptrdiff_t add_vertex(const V& data) { std::ptrdiff_t new_vertex_id = 0; if (!m_freed_vertex_ids.empty()) { new_vertex_id = *m_freed_vertex_ids.begin(); m_freed_vertex_ids.erase(new_vertex_id); m_vertices[new_vertex_id] = vertex{new_vertex_id, data}; } else { new_vertex_id = std::ssize(m_vertices); m_vertices.emplace_back(new_vertex_id, data); } return new_vertex_id; } const V& vertex_data(std::ptrdiff_t vertex_id) const { assert(is_vertex_present(vertex_id)); return m_vertices[vertex_id].data(); } bool is_vertex_present(std::ptrdiff_t vertex_id) const { return is_id_in_use(vertex_id, (std::ssize(m_vertices) - 1), m_freed_vertex_ids); } void remove_vertex(std::ptrdiff_t vertex_id) { m_freed_vertex_ids.insert(vertex_id); for (const auto& edge : m_edges) { if ((edge.source_vertex_id() == vertex_id) || (edge.target_vertex_id() == vertex_id)) { m_vertices[edge.source_vertex_id()].remove_edge(edge.id()); m_freed_edge_ids.insert(edge.id()); } } } int amount_vertices() const { return (std::ssize(m_vertices) - std::ssize(m_freed_vertex_ids)); } void clear() { *this = graph
{}; } std::ptrdiff_t add_edge(std::ptrdiff_t from_vertex_id, std::ptrdiff_t to_vertex_id, const E& data) { assert(is_vertex_present(from_vertex_id)); assert(is_vertex_present(to_vertex_id)); std::ptrdiff_t new_edge_id; if (!m_freed_edge_ids.empty()) { new_edge_id = *m_freed_edge_ids.begin(); m_freed_edge_ids.erase(new_edge_id); m_edges[new_edge_id] = edge{new_edge_id, from_vertex_id, to_vertex_id, data}; } else { new_edge_id = std::ssize(m_edges); m_edges.emplace_back(new_edge_id, from_vertex_id, to_vertex_id, data); } m_vertices[from_vertex_id].add_edge(new_edge_id); return new_edge_id; } std::pair
add_undirected_edge(std::ptrdiff_t from_vertex_id, std::ptrdiff_t to_vertex_id, const E& data) { std::ptrdiff_t a = add_edge(from_vertex_id, to_vertex_id, data); std::ptrdiff_t b = add_edge(to_vertex_id, from_vertex_id, data); return {a, b}; } const E& edge_data(std::ptrdiff_t edge_id) const { assert(is_edge_present(edge_id)); return m_edges[edge_id].data(); } std::ptrdiff_t edge_source_vertex_id(std::ptrdiff_t edge_id) const { return m_edges[edge_id].source_vertex_id(); } std::ptrdiff_t edge_target_vertex_id(std::ptrdiff_t edge_id) const { return m_edges[edge_id].target_vertex_id(); } bool is_edge_present(std::ptrdiff_t edge_id) const { return is_id_in_use(edge_id, (std::ssize(m_edges) - 1), m_freed_edge_ids); } void remove_edge(std::ptrdiff_t edge_id) { m_freed_edge_ids.insert(edge_id); } std::ptrdiff_t amount_edges() const { return (std::ssize(m_edges) - std::ssize(m_freed_edge_ids)); } void clear_edges() { m_edges.clear(); m_freed_edge_ids.clear(); for (auto& v : m_vertices) { v.clear_edges(); } } bool empty() const { return (amount_vertices() == 0); } std::set
edge_ids(std::ptrdiff_t vertex_id) const { assert(is_vertex_present(vertex_id)); return m_vertices[vertex_id].edge_ids(); } std::set
vertex_ids() const { std::set
ids; for (std::ptrdiff_t i = 0; i < std::ssize(m_vertices); i++) { if (!m_freed_vertex_ids.contains(i)) { ids.insert(i); } } return ids; } std::set
edge_ids() const { std::set
ids; for (std::ptrdiff_t i = 0; i < std::ssize(m_edges); i++) { if (!m_freed_vertex_ids.contains(i)) { ids.insert(i); } } return ids; } void transpose() { for (auto& edge : m_edges) { m_vertices[edge.source_vertex_id()].remove_edge(edge.id()); edge.transpose(); m_vertices[edge.source_vertex_id()].add_edge(edge.id()); } } nlohmann::json to_json() const { nlohmann::json graph_json; graph_json["graph"]["nodes"] = nlohmann::json::array(); for (const auto& vertex : m_vertices) { if (!m_freed_vertex_ids.contains(vertex.id())) { nlohmann::json vertex_json; vertex_json["id"] = vertex.id(); vertex_json["edge_ids"] = vertex.edge_ids(); std::stringstream data; data << vertex.data(); vertex_json["data"] = data.str(); data.clear(); graph_json["graph"]["nodes"].push_back(vertex_json); } } graph_json["graph"]["edges"] = nlohmann::json::array(); for (const auto& edge : m_edges) { if (!m_freed_edge_ids.contains(edge.id())) { nlohmann::json edge_json; edge_json["id"] = edge.id(); edge_json["source"] = edge.source_vertex_id(); edge_json["target"] = edge.target_vertex_id(); std::stringstream data; data << edge.data(); edge_json["data"] = data.str(); data.clear(); graph_json["graph"]["edges"].push_back(edge_json); } } return graph_json; } std::string to_dot() const { std::stringstream out; out << "digraph {\n"; for (const auto& v : m_vertices) { if (!m_freed_vertex_ids.contains(v.id())) { out << "\t" << v.id() << " [label=\"(" << v.id() << ") " << v.data() << "\"]\n"; } } for (const auto& e : m_edges) { if (!m_freed_edge_ids.contains(e.id())) { out << "\t" << e.source_vertex_id() << " -> " << e.target_vertex_id() << " [label=\"(" << e.id() << ") " << e.data() << "\"]\n"; } } out << "}"; return out.str(); } // Operators /////////////////////////////////////////////////////////////// friend std::ostream& operator<<(std::ostream& os, const graph& object) { os << object.to_json().dump(4); return os; } // Nested classes ////////////////////////////////////////////////////////// private: class edge { public: edge(std::ptrdiff_t id, std::ptrdiff_t source_vertex_id, std::ptrdiff_t target_vertex_id, const E& data) : m_id{id}, m_source_vertex_id{source_vertex_id}, m_target_vertex_id{target_vertex_id}, m_data{data} { } std::ptrdiff_t id() const { return m_id; } std::ptrdiff_t source_vertex_id() const { return m_source_vertex_id; } std::ptrdiff_t target_vertex_id() const { return m_target_vertex_id; } const E& data() const { return m_data; } void transpose() { std::swap(m_source_vertex_id, m_target_vertex_id); } private: std::ptrdiff_t m_id; std::ptrdiff_t m_source_vertex_id; std::ptrdiff_t m_target_vertex_id; E m_data; }; class vertex { public: vertex(std::ptrdiff_t id, const V& data) : m_id{id}, m_data{data} { } std::ptrdiff_t id() const { return m_id; } void add_edge(std::ptrdiff_t edge_id) { m_edge_ids.insert(edge_id); } void remove_edge(std::ptrdiff_t edge_id) { m_edge_ids.erase(edge_id); } void clear_edges() { m_edge_ids.clear(); } std::set
edge_ids() const { return m_edge_ids; } const V& data() const { return m_data; } private: std::ptrdiff_t m_id; std::set
m_edge_ids; V m_data; }; bool is_id_in_use(std::ptrdiff_t id, std::ptrdiff_t max_id_in_use, std::set
freed_ids) const { return ((id >= 0) && (id <= max_id_in_use) && !(freed_ids.contains(id))); } std::vector
m_vertices; std::set
m_freed_vertex_ids; std::vector
m_edges; std::set
m_freed_edge_ids; }; #endif ``` --- Want more examples? Be sure to check out the advanced examples for more advanced stuff like resizing images, video, fragments, custom backgrounds, multicolumn slides, ... . ---