Skip to content

Commit 226e0a7

Browse files
committed
update code format for graphviz plot
1 parent afe100c commit 226e0a7

File tree

2 files changed

+87
-88
lines changed

2 files changed

+87
-88
lines changed

lectures/eigen.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ What guarantees the existence of a unique vector $x^{*}$ that satisfies
956956
The following is a fundamental result in functional analysis that generalises
957957
{eq}`gp_sum` to a multivariate case.
958958

959-
959+
(neumann_series_lemma)=
960960
```{prf:theorem} Neumann Series Lemma
961961
:label: neumann_series_lemma
962962

lectures/networks.md

Lines changed: 86 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -128,27 +128,27 @@ fig, ax = plt.subplots(figsize=(10, 10))
128128
ax.axis('off')
129129
130130
nx.draw_networkx_nodes(DG,
131-
node_pos_dict,
132-
node_color=node_colors,
133-
node_size=node_sizes,
134-
linewidths=2,
135-
alpha=0.6,
136-
ax=ax)
131+
node_pos_dict,
132+
node_color=node_colors,
133+
node_size=node_sizes,
134+
linewidths=2,
135+
alpha=0.6,
136+
ax=ax)
137137
138138
nx.draw_networkx_labels(DG,
139139
node_pos_dict,
140140
ax=ax)
141141
142142
nx.draw_networkx_edges(DG,
143-
node_pos_dict,
144-
edge_color=edge_colors,
145-
width=edge_widths,
146-
arrows=True,
147-
arrowsize=20,
148-
ax=ax,
149-
arrowstyle='->',
150-
node_size=node_sizes,
151-
connectionstyle='arc3,rad=0.15')
143+
node_pos_dict,
144+
edge_color=edge_colors,
145+
width=edge_widths,
146+
arrows=True,
147+
arrowsize=20,
148+
ax=ax,
149+
arrowstyle='->',
150+
node_size=node_sizes,
151+
connectionstyle='arc3,rad=0.15')
152152
153153
plt.show()
154154
```
@@ -275,9 +275,9 @@ mystnb:
275275
---
276276
graph1 = graphviz.Digraph(comment='Graph',engine = "neato")
277277
graph1.attr(rankdir='LR')
278-
graph1.node("poor", pos = '0,0!')
279-
graph1.node("middle class", pos = '2,1!')
280-
graph1.node("rich", pos = '4,0!')
278+
graph1.node("poor", pos='0,0!')
279+
graph1.node("middle class", pos='2,1!')
280+
graph1.node("rich", pos='4,0!')
281281
282282
graph1.edge("poor", "poor")
283283
graph1.edge("poor", "middle class")
@@ -306,9 +306,9 @@ mystnb:
306306
---
307307
graph2 = graphviz.Digraph(comment='Graph',engine="neato")
308308
graph2.attr(rankdir='LR')
309-
graph2.node("poor", pos = '0,0!')
310-
graph2.node("middle class", pos = '2,1!')
311-
graph2.node("rich", pos = '4,0!')
309+
graph2.node("poor", pos='0,0!')
310+
graph2.node("middle class", pos='2,1!')
311+
graph2.node("rich", po ='4,0!')
312312
313313
graph2.edge("poor", "poor")
314314
graph2.edge("middle class", "poor")
@@ -512,30 +512,30 @@ fig, ax = plt.subplots(figsize=(8, 10))
512512
ax.axis('off')
513513
514514
nx.draw_networkx_nodes(G,
515-
node_pos_dict,
516-
node_color=node_colors,
517-
node_size=node_sizes,
518-
edgecolors='grey',
519-
linewidths=2,
520-
alpha=0.4,
521-
ax=ax)
515+
node_pos_dict,
516+
node_color=node_colors,
517+
node_size=node_sizes,
518+
edgecolors='grey',
519+
linewidths=2,
520+
alpha=0.4,
521+
ax=ax)
522522
523523
nx.draw_networkx_labels(G,
524524
node_pos_dict,
525525
font_size=12,
526526
ax=ax)
527527
528528
nx.draw_networkx_edges(G,
529-
node_pos_dict,
530-
edge_color=edge_colors,
531-
width=edge_widths,
532-
arrows=True,
533-
arrowsize=20,
534-
alpha=0.8,
535-
ax=ax,
536-
arrowstyle='->',
537-
node_size=node_sizes,
538-
connectionstyle='arc3,rad=0.15')
529+
node_pos_dict,
530+
edge_color=edge_colors,
531+
width=edge_widths,
532+
arrows=True,
533+
arrowsize=20,
534+
alpha=0.8,
535+
ax=ax,
536+
arrowstyle='->',
537+
node_size=node_sizes,
538+
connectionstyle='arc3,rad=0.15')
539539
540540
plt.show()
541541
```
@@ -603,14 +603,14 @@ graph3.node("poor")
603603
graph3.node("middle class")
604604
graph3.node("rich")
605605
606-
graph3.edge("poor", "poor", label = '0.9')
607-
graph3.edge("poor", "middle class", label = '0.1')
608-
graph3.edge("middle class", "poor", label = '0.4')
609-
graph3.edge("middle class", "middle class", label = '0.4')
610-
graph3.edge("middle class", "rich", label = '0.2')
611-
graph3.edge("rich", "poor", label = '0.1')
612-
graph3.edge("rich", "middle class", label = '0.1')
613-
graph3.edge("rich", "rich", label = '0.8')
606+
graph3.edge("poor", "poor", label='0.9')
607+
graph3.edge("poor", "middle class", label='0.1')
608+
graph3.edge("middle class", "poor", label='0.4')
609+
graph3.edge("middle class", "middle class", label='0.4')
610+
graph3.edge("middle class", "rich", label='0.2')
611+
graph3.edge("rich", "poor", label='0.1')
612+
graph3.edge("rich", "middle class", label='0.1')
613+
graph3.edge("rich", "rich", label='0.8')
614614
615615
graph3
616616
```
@@ -707,21 +707,21 @@ plt.show()
707707
graph4 = graphviz.Digraph(engine = "neato")
708708
709709
graph4.attr(rankdir='LR')
710-
graph4.node('1', pos = '1,0!')
711-
graph4.node('2', pos = '3,0!')
712-
graph4.node('3', pos = '4,2!')
713-
graph4.node('4', pos = '2,3!')
714-
graph4.node('5', pos = '0,2!')
715-
716-
graph4.edge('1','2', label = '100')
717-
graph4.edge('2','1', label = '50')
718-
graph4.edge('2','3', label = '200')
719-
graph4.edge('3','4', label = '\t100')
720-
graph4.edge('4','2', label = '500')
721-
graph4.edge('4','5', label = '\n50\t')
722-
graph4.edge('5','1', label = '150')
723-
graph4.edge('5','3', label = '250')
724-
graph4.edge('5','4', label = '300')
710+
graph4.node('1', pos='1,0!')
711+
graph4.node('2', pos='3,0!')
712+
graph4.node('3', pos='4,2!')
713+
graph4.node('4', pos='2,3!')
714+
graph4.node('5', pos='0,2!')
715+
716+
graph4.edge('1','2', label='100')
717+
graph4.edge('2','1', label='50')
718+
graph4.edge('2','3', label='200')
719+
graph4.edge('3','4', label='\t100')
720+
graph4.edge('4','2', label='500')
721+
graph4.edge('4','5', label='\n50\t')
722+
graph4.edge('5','1', label='150')
723+
graph4.edge('5','3', label='250')
724+
graph4.edge('5','4', label='300')
725725
726726
graph4
727727
```
@@ -786,21 +786,21 @@ plt.show()
786786
graph5 = graphviz.Digraph(engine = "neato")
787787
788788
graph5.attr(rankdir='LR')
789-
graph5.node('1', pos = '1,0!')
790-
graph5.node('2', pos = '3,0!')
791-
graph5.node('3', pos = '4,2!')
792-
graph5.node('4', pos = '2,3!')
793-
graph5.node('5', pos = '0,2!')
794-
795-
graph5.edge('1','2', label = '50')
796-
graph5.edge('1','5', label = '150')
797-
graph5.edge('2','1', label = '100')
798-
graph5.edge('2','4', label = '500')
799-
graph5.edge('3','2', label = '200')
800-
graph5.edge('3','5', label = '250')
801-
graph5.edge('4','3', label = '\t100')
802-
graph5.edge('4','5', label = '\n300\t')
803-
graph5.edge('5','4', label = '50')
789+
graph5.node('1', pos='1,0!')
790+
graph5.node('2', pos='3,0!')
791+
graph5.node('3', pos='4,2!')
792+
graph5.node('4', pos='2,3!')
793+
graph5.node('5', pos='0,2!')
794+
795+
graph5.edge('1', '2', label='50')
796+
graph5.edge('1', '5', label='150')
797+
graph5.edge('2', '1', label='100')
798+
graph5.edge('2', '4', label='500')
799+
graph5.edge('3', '2', label='200')
800+
graph5.edge('3', '5', label='250')
801+
graph5.edge('4', '3', label='\t100')
802+
graph5.edge('4', '5', label='\n300\t')
803+
graph5.edge('5', '4', label='50')
804804
805805
graph5
806806
```
@@ -845,8 +845,8 @@ $$
845845
The above result is obvious when $k=1$ and a proof of the general case can be
846846
found in \cite{sargent2022economic}.
847847

848-
Now recall from {ref}`the eigenvalues lecture <irreducible>` that a
849-
nonnegative matrix $A$ is called irreducible if for each $(i,j)$ there is an integer $k \geq 0$ such that $a^{k}_{ij} > 0$.
848+
Now recall from the eigenvalues lecture that a
849+
nonnegative matrix $A$ is called {ref}`irreducible<irreducible>` if for each $(i,j)$ there is an integer $k \geq 0$ such that $a^{k}_{ij} > 0$.
850850

851851
From the preceding theorem it is not too difficult (see
852852
\cite{sargent2022economic} for details) to get the next result.
@@ -875,11 +875,11 @@ graph6.node('1')
875875
graph6.node('2')
876876
graph6.node('3')
877877
878-
graph6.edge('1','2', label = '0.7')
879-
graph6.edge('1','3', label = '0.3')
880-
graph6.edge('2','1', label = '1')
881-
graph6.edge('3','1', label = '0.4')
882-
graph6.edge('3','2', label = '0.6')
878+
graph6.edge('1', '2', label='0.7')
879+
graph6.edge('1', '3', label='0.3')
880+
graph6.edge('2', '1', label='1')
881+
graph6.edge('3', '1', label='0.4')
882+
graph6.edge('3', '2', label='0.6')
883883
884884
graph6
885885
```
@@ -1072,7 +1072,7 @@ Suppose we have a weighted directed graph with adjacency matrix $A$.
10721072
For simplicity we will suppose that the nodes $V$ of the graph are just the
10731073
integers $1, \ldots, n$.
10741074

1075-
Let $r(A)$ denote the {ref}`spectral radius<la_neumann>` of $A$.
1075+
Let $r(A)$ denote the {ref}`spectral radius<neumann_series_lemma>` of $A$.
10761076

10771077
The **eigenvector centrality** of the graph is defined as the $n$-vector $e$ that solves
10781078

@@ -1084,8 +1084,7 @@ The **eigenvector centrality** of the graph is defined as the $n$-vector $e$ tha
10841084
```
10851085

10861086
In other words, $e$ is the dominant eigenvector of $A$ (the eigenvector of the
1087-
largest eigenvalue --- see the discussion of the Perron-Frobenius theorem in
1088-
{ref}`the eigenvalue lecture <perron-frobe>`
1087+
largest eigenvalue --- see the discussion of the {ref}`Perron-Frobenius theorem<perron-frobe>` in the eigenvalue lecture.
10891088

10901089
To better understand {eq}`ev_central`, we write out the full expression
10911090
for some element $e_i$
@@ -1229,7 +1228,7 @@ $$
12291228
$$
12301229

12311230

1232-
This follows from the {ref}`Neumann series theorem<la_neumann>`.
1231+
This follows from the {ref}`Neumann series theorem<neumann_series_lemma>`.
12331232

12341233
The parameter $\beta$ is used to ensure that $\kappa$ is finite
12351234

0 commit comments

Comments
 (0)