Chapter 23 first version
This commit is contained in:
parent
864df3289e
commit
cf0c55f577
129
luku23.tex
129
luku23.tex
|
@ -607,19 +607,17 @@ X^n \cdot
|
||||||
\]
|
\]
|
||||||
\end{samepage}
|
\end{samepage}
|
||||||
|
|
||||||
\section{Verkot ja matriisit}
|
\section{Graphs and matrices}
|
||||||
|
|
||||||
\subsubsection{Polkujen määrä}
|
\subsubsection{Counting paths}
|
||||||
|
|
||||||
Matriisipotenssilla
|
The powers of an adjacency matrix of a graph
|
||||||
on mielenkiintoinen vaikutus
|
have an interesting property.
|
||||||
verkon vierusmatriisin sisältöön.
|
When $V$ is an adjacency matrix of an unweighted graph,
|
||||||
Kun $V$ on painottoman verkon vierusmatriisi,
|
the matrix $V^n$ contains the numbers of paths of
|
||||||
niin $V^n$ kertoo,
|
$n$ edges between the nodes in the graph.
|
||||||
montako $n$ kaaren pituista polkua
|
|
||||||
eri solmuista on toisiinsa.
|
|
||||||
|
|
||||||
Esimerkiksi verkon
|
For example, for the graph
|
||||||
\begin{center}
|
\begin{center}
|
||||||
\begin{tikzpicture}[scale=0.9]
|
\begin{tikzpicture}[scale=0.9]
|
||||||
\node[draw, circle] (1) at (1,3) {$1$};
|
\node[draw, circle] (1) at (1,3) {$1$};
|
||||||
|
@ -639,7 +637,7 @@ Esimerkiksi verkon
|
||||||
\path[draw,thick,->,>=latex] (6) -- (5);
|
\path[draw,thick,->,>=latex] (6) -- (5);
|
||||||
\end{tikzpicture}
|
\end{tikzpicture}
|
||||||
\end{center}
|
\end{center}
|
||||||
vierusmatriisi on
|
the adjacency matrix is
|
||||||
\[
|
\[
|
||||||
V= \begin{bmatrix}
|
V= \begin{bmatrix}
|
||||||
0 & 0 & 0 & 1 & 0 & 0 \\
|
0 & 0 & 0 & 1 & 0 & 0 \\
|
||||||
|
@ -650,7 +648,7 @@ V= \begin{bmatrix}
|
||||||
0 & 0 & 1 & 0 & 1 & 0 \\
|
0 & 0 & 1 & 0 & 1 & 0 \\
|
||||||
\end{bmatrix}.
|
\end{bmatrix}.
|
||||||
\]
|
\]
|
||||||
Nyt esimerkiksi matriisi
|
Now, for example, the matrix
|
||||||
\[
|
\[
|
||||||
V^4= \begin{bmatrix}
|
V^4= \begin{bmatrix}
|
||||||
0 & 0 & 1 & 1 & 1 & 0 \\
|
0 & 0 & 1 & 1 & 1 & 0 \\
|
||||||
|
@ -661,26 +659,26 @@ V^4= \begin{bmatrix}
|
||||||
0 & 0 & 1 & 1 & 1 & 0 \\
|
0 & 0 & 1 & 1 & 1 & 0 \\
|
||||||
\end{bmatrix}
|
\end{bmatrix}
|
||||||
\]
|
\]
|
||||||
kertoo, montako 4 kaaren pituista polkua
|
contains the numbers of paths of 4 edges
|
||||||
solmuista on toisiinsa.
|
between the nodes.
|
||||||
Esimerkiksi $V^4[2,5]=2$,
|
For example, $V^4[2,5]=2$,
|
||||||
koska solmusta 2 solmuun 5 on olemassa
|
because there are two paths of 4 edges
|
||||||
4 kaaren pituiset polut
|
from node 2 to node 5:
|
||||||
$2 \rightarrow 1 \rightarrow 4 \rightarrow 2 \rightarrow 5$
|
$2 \rightarrow 1 \rightarrow 4 \rightarrow 2 \rightarrow 5$
|
||||||
ja
|
and
|
||||||
$2 \rightarrow 6 \rightarrow 3 \rightarrow 2 \rightarrow 5$.
|
$2 \rightarrow 6 \rightarrow 3 \rightarrow 2 \rightarrow 5$.
|
||||||
|
|
||||||
\subsubsection{Lyhimmät polut}
|
\subsubsection{Shortest paths}
|
||||||
|
|
||||||
Samantapaisella idealla voi laskea painotetussa verkossa
|
Using a similar idea in a weighted graph,
|
||||||
kullekin solmuparille,
|
we can calculate for each pair of nodes the shortest
|
||||||
kuinka pitkä on lyhin $n$ kaaren pituinen polku solmujen välillä.
|
path between them that contains exactly $n$ edges.
|
||||||
Tämä vaatii matriisitulon määritelmän muuttamista
|
To calculate this, we have to define matrix multiplication
|
||||||
niin, että siinä ei lasketa polkujen yhteismäärää
|
in another way, so that we don't calculate the number
|
||||||
vaan minimoidaan polun pituutta.
|
of paths but minimize the length of a path.
|
||||||
|
|
||||||
\begin{samepage}
|
\begin{samepage}
|
||||||
Tarkastellaan esimerkkinä seuraavaa verkkoa:
|
As an example, consider the following graph:
|
||||||
\begin{center}
|
\begin{center}
|
||||||
\begin{tikzpicture}[scale=0.9]
|
\begin{tikzpicture}[scale=0.9]
|
||||||
\node[draw, circle] (1) at (1,3) {$1$};
|
\node[draw, circle] (1) at (1,3) {$1$};
|
||||||
|
@ -702,10 +700,10 @@ Tarkastellaan esimerkkinä seuraavaa verkkoa:
|
||||||
\end{center}
|
\end{center}
|
||||||
\end{samepage}
|
\end{samepage}
|
||||||
|
|
||||||
Muodostetaan verkosta vierusmatriisi, jossa arvo
|
Let's construct an adjacency matrix where
|
||||||
$\infty$ tarkoittaa, että kaarta ei ole,
|
$\infty$ means that an edge doesn't exist,
|
||||||
ja muut arvot ovat kaarten pituuksia.
|
and other values correspond to edge weights.
|
||||||
Matriisista tulee
|
The matrix is
|
||||||
\[
|
\[
|
||||||
V= \begin{bmatrix}
|
V= \begin{bmatrix}
|
||||||
\infty & \infty & \infty & 4 & \infty & \infty \\
|
\infty & \infty & \infty & 4 & \infty & \infty \\
|
||||||
|
@ -717,18 +715,20 @@ V= \begin{bmatrix}
|
||||||
\end{bmatrix}.
|
\end{bmatrix}.
|
||||||
\]
|
\]
|
||||||
|
|
||||||
Nyt voimme laskea matriisitulon kaavan
|
Instead of the formula
|
||||||
\[
|
\[
|
||||||
AB[i,j] = \sum_{k=1}^n A[i,k] \cdot B[k,j]
|
AB[i,j] = \sum_{k=1}^n A[i,k] \cdot B[k,j]
|
||||||
\]
|
\]
|
||||||
sijasta kaavalla
|
we now use the formula
|
||||||
\[
|
\[
|
||||||
AB[i,j] = \min_{k=1}^n A[i,k] + B[k,j],
|
AB[i,j] = \min_{k=1}^n A[i,k] + B[k,j],
|
||||||
\]
|
\]
|
||||||
eli summa muuttuu minimiksi ja tulo summaksi.
|
for matrix multiplication, so we calculate
|
||||||
Tämän seurauksena matriisipotenssi
|
a minimum instead of a sum,
|
||||||
selvittää lyhimmät polkujen pituudet solmujen
|
and a sum of elements instead of a product.
|
||||||
välillä. Esimerkiksi
|
After this modification,
|
||||||
|
matrix powers can be used for calculating
|
||||||
|
shortest paths in the graph:
|
||||||
|
|
||||||
\[
|
\[
|
||||||
V^4= \begin{bmatrix}
|
V^4= \begin{bmatrix}
|
||||||
|
@ -740,19 +740,20 @@ V^4= \begin{bmatrix}
|
||||||
\infty & \infty & 12 & 13 & 11 & \infty \\
|
\infty & \infty & 12 & 13 & 11 & \infty \\
|
||||||
\end{bmatrix}
|
\end{bmatrix}
|
||||||
\]
|
\]
|
||||||
eli esimerkiksi lyhin 4 kaaren pituinen polku
|
For example, the shortest path of 4 edges
|
||||||
solmusta 2 solmuun 5 on pituudeltaan 8.
|
from node 2 to node 5 has length 8.
|
||||||
Tämä polku on $2 \rightarrow 1 \rightarrow 4 \rightarrow 2 \rightarrow 5$.
|
This path is
|
||||||
|
$2 \rightarrow 1 \rightarrow 4 \rightarrow 2 \rightarrow 5$.
|
||||||
|
|
||||||
\subsubsection{Kirchhoffin lause}
|
\subsubsection{Kirchhoff's theorem}
|
||||||
|
|
||||||
\index{Kirchhoffin lause@Kirchhoffin lause}
|
\index{Kirchhoff's theorem}
|
||||||
\index{virittxvx puu@virittävä puu}
|
\index{spanning tree}
|
||||||
|
|
||||||
\key{Kirchhoffin lause} laskee
|
\key{Kirchhoff's theorem} provides us a way
|
||||||
verkon virittävän puiden määrän
|
to calculate the number of spanning trees
|
||||||
verkosta muodostetun matriisin determinantin avulla.
|
in a graph as a determinant of a special matrix.
|
||||||
Esimerkiksi verkolla
|
For example, the graph
|
||||||
\begin{center}
|
\begin{center}
|
||||||
\begin{tikzpicture}[scale=0.9]
|
\begin{tikzpicture}[scale=0.9]
|
||||||
\node[draw, circle] (1) at (1,3) {$1$};
|
\node[draw, circle] (1) at (1,3) {$1$};
|
||||||
|
@ -766,7 +767,7 @@ Esimerkiksi verkolla
|
||||||
\path[draw,thick,-] (1) -- (4);
|
\path[draw,thick,-] (1) -- (4);
|
||||||
\end{tikzpicture}
|
\end{tikzpicture}
|
||||||
\end{center}
|
\end{center}
|
||||||
on kolme virittävää puuta:
|
has three spanning trees:
|
||||||
\begin{center}
|
\begin{center}
|
||||||
\begin{tikzpicture}[scale=0.9]
|
\begin{tikzpicture}[scale=0.9]
|
||||||
\node[draw, circle] (1a) at (1,3) {$1$};
|
\node[draw, circle] (1a) at (1,3) {$1$};
|
||||||
|
@ -800,12 +801,12 @@ on kolme virittävää puuta:
|
||||||
%\path[draw,thick,-] (1c) -- (4c);
|
%\path[draw,thick,-] (1c) -- (4c);
|
||||||
\end{tikzpicture}
|
\end{tikzpicture}
|
||||||
\end{center}
|
\end{center}
|
||||||
\index{Laplacen matriisi@Laplacen matriisi}
|
\index{Laplacean matrix}
|
||||||
Muodostetaan verkosta \key{Laplacen matriisi} $L$,
|
We construct a \key{Laplacean matrix} $L$,
|
||||||
jossa $L[i,i]$ on solmun $i$ aste ja
|
where $L[i,i]$ is the degree of node $i$
|
||||||
$L[i,j]=-1$, jos solmujen $i$ ja $j$ välillä on kaari,
|
and $L[i,j]=-1$ if there is an edge between
|
||||||
ja muuten $L[i,j]=0$.
|
nodes $i$ and $j$, and otherwise $L[i,j]=0$.
|
||||||
Tässä tapauksessa matriisista tulee
|
In this graph, the matrix is as follows:
|
||||||
|
|
||||||
\[
|
\[
|
||||||
L= \begin{bmatrix}
|
L= \begin{bmatrix}
|
||||||
|
@ -813,14 +814,14 @@ L= \begin{bmatrix}
|
||||||
-1 & 1 & 0 & 0 \\
|
-1 & 1 & 0 & 0 \\
|
||||||
-1 & 0 & 2 & -1 \\
|
-1 & 0 & 2 & -1 \\
|
||||||
-1 & 0 & -1 & 2 \\
|
-1 & 0 & -1 & 2 \\
|
||||||
\end{bmatrix}.
|
\end{bmatrix}
|
||||||
\]
|
\]
|
||||||
|
|
||||||
Nyt virittävien puiden määrä on determinantti
|
The number of spanning trees is the same as
|
||||||
matriisista, joka saadaan poistamasta matriisista $L$
|
the determinant of a matrix that is obtained
|
||||||
jokin rivi ja jokin sarake.
|
when we remove any row and any column from $L$.
|
||||||
Esimerkiksi jos poistamme ylimmän rivin ja
|
For example, if we remove the first row
|
||||||
vasemman sarakkeen, tuloksena on
|
and column, the result is
|
||||||
|
|
||||||
\[ \det(
|
\[ \det(
|
||||||
\begin{bmatrix}
|
\begin{bmatrix}
|
||||||
|
@ -829,12 +830,12 @@ vasemman sarakkeen, tuloksena on
|
||||||
0 & -1 & 2 \\
|
0 & -1 & 2 \\
|
||||||
\end{bmatrix}
|
\end{bmatrix}
|
||||||
) =3.\]
|
) =3.\]
|
||||||
Determinantista tulee aina sama riippumatta siitä,
|
The determinant is always the same,
|
||||||
mikä rivi ja sarake matriisista $L$ poistetaan.
|
regardless of which row and column we remove from $L$.
|
||||||
|
|
||||||
Huomaa, että Kirchhoffin lauseen erikoistapauksena on
|
Note that a special case of Kirchhoff's theorem
|
||||||
luvun 22.5 Cayleyn kaava, koska
|
is Cayley's formula in Chapter 22.5,
|
||||||
täydellisessä $n$ solmun verkossa
|
because in a complete graph of $n$ nodes
|
||||||
|
|
||||||
\[ \det(
|
\[ \det(
|
||||||
\begin{bmatrix}
|
\begin{bmatrix}
|
||||||
|
|
Loading…
Reference in New Issue