Skip to content

Commit

Permalink
updates cfg in order to fix code syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
Darakuu committed Jan 24, 2024
1 parent 3596f79 commit 5a91102
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions content/Algoritmo di Kruskal.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ Seguendo un ordine non decrescente per costi, se l'arco corrente $e$ è contenut

> [!example]- Esempio
> ![[Algoritmo di Kruskal-20240124015826262.png|512]]
>
> <ins>Ordinamento</ins>
>
> $(b,d)<(c,d)<(e,g)<(a,c)<(a,b)<(b,c)<(d,e)<(d,g)<(c,f)<(b,e)<(f,g)<(d,f)$
>
> <ins>Colorazione</ins>
>
> $\textcolor{royalblue}{(b,d)}<\textcolor{royalblue}{(c,d)}<\textcolor{royalblue}{(e,g)}<\textcolor{royalblue}{(a,c)}<\textcolor{red}{(a,b)}<\textcolor{red}{(b,c)}<\textcolor{royalblue}{(d,e)}<\textcolor{red}{(d,g)}<\textcolor{royalblue}{(c,f)}<\textcolor{red}{(b,e)}<\textcolor{red}{(f,g)}<\textcolor{red}{(d,f)}$
Oppure, per una strategia senza colori: ordina gli edge in ordine non-decrescente, come da pseudocodice (vedi sotto), crea un set per ogni vertice del grafo, e controlla via via in ordine di peso se due vertici sono nello stesso subset. 
Expand All @@ -34,16 +38,16 @@ La riga 6 dello pseudocodice (l'istruzione *if* ) garantisce che il vertice $u$

Pseudocodice:

```C
T = EMPTY_SET(); // T is going to be the MST
for each (v in V)
MAKE_SET(v) // create a subtree for each vertex
E = sort(E,w); // non-decreasing order
for each ((u,v) in E) // in sorted edges...
if (FIND_SET(u) != FIND_SET(v)) // if u and v are in different subtrees (sets), avoid cycles
T = T U {(u,v)} // insert the edge inside the MST
UNION(u,v) // union between the two different subtrees (sets), we're sure there are no cycles.
return T; // return the MST
```cs title="Kruskal(G,w)"
T = EMPTY_SET(); // T is going to be the MST
foreach (v in V)
MAKE_SET(v) // create a subtree for each vertex
E = sort(E,w); // non-decreasing order
foreach ((u,v) in E) // in sorted edges...
if (FIND_SET(u) != FIND_SET(v)) // if u and v are in different subtrees (sets), avoid cycles
T = T U {(u,v)} // insert the edge inside the MST
UNION(u,v) // union between the two different subtrees (sets), we're sure there are no cycles.
return T; // return the MST
```

# Complessità
2 changes: 1 addition & 1 deletion quartz.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ const config: QuartzConfig = {
priority: ["frontmatter", "filesystem"], // you can add 'git' here for last modified from Git but this makes the build slower
}),
Plugin.Latex({ renderEngine: "mathjax" }),
Plugin.SyntaxHighlighting(),
Plugin.ObsidianFlavoredMarkdown({ enableInHtmlEmbed: true }),
Plugin.GitHubFlavoredMarkdown(),
Plugin.SyntaxHighlighting(),
Plugin.CrawlLinks({ markdownLinkResolution: "shortest" }),
Plugin.Description(),
],
Expand Down

0 comments on commit 5a91102

Please sign in to comment.