Skip to content

Commit

Permalink
update: 240626 ver 1
Browse files Browse the repository at this point in the history
  • Loading branch information
V1CeVersaa committed Jun 26, 2024
1 parent 0287f27 commit d5c98c4
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 31 deletions.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,21 @@ Python支持**`int`**、**`float`**、**`bool`**、**`complex`**四种类型。

### 列表 (List)

列表由一系列按照特定顺序排列的元素组成,我们用方括号表示列表,并且用逗号分隔其中的元素。列表中的元素可以不相同,甚至可以包含列表 (也就是嵌套)。列表的索引和字符串的索引相同,从`0`开始;或者从尾部开始,最后一个元素的索引为`-1`,往前一位为`-2`,以此类推。
列表由一系列按照特定顺序排列的元素组成,我们用方括号 `[]` 表示列表,并且用逗号分隔其中的元素。列表中的元素可以不相同,甚至可以包含列表 (也就是嵌套)。列表的索引和字符串的索引相同,从`0`开始;或者从尾部开始,最后一个元素的索引为`-1`,往前一位为`-2`,以此类推。

需要注意的是,`sorted()`函数和`sort()`方法 (和排序相关的) 均不能用在字符串和数字混合的列表 (元组和字典) 排序之中。

### 元组 (Tuple)

### 字典 (Dictionary)
使用圆括号 `()` 表示元组,当元组只有一个元素的时候,只能写成 `(a, )` 的形式,这是因为 `(a)` 其实表示的是一个值。

### 集合

使用花括号 `{}` 括起来表示集合,内部元素使用逗号来分割。

#### 声明与基本操作
### 字典 (Dictionary)

字典是一系列**键-值对**。每一个键都与值相对应,我们可以用键访问对应的值。值可以是任意数据类型,但是键必须是不可变的数据类型,比如数字或字符串。我们允许创建空字典,可以随时添加、修改或者删除字典内的数据
也是使用花括号 `{}` 括起来表示,但是字典内部存储的是键值对 `{key: value, ...}`

```python
dictionary1 = dict()
Expand All @@ -115,8 +119,6 @@ del dictionary1 #删除词典

可以发现添加键-值对的语法和修改值的相同。

#### 遍历词典

如果要遍历字典内的键-值对,我们需要先声明两个变量,使用`items()`方法,它返回一个键-值对列表,在遍历每一个键值对的过程之中,会将键和值依次存储到两个变量之中。同理`keys()`方法和`values()`方法分别返回一个存储着键和值的列表,值得注意的是这些列表的元素顺序和其原本的存储顺序不相同,因为Python只关心键与值的对应关系,而不关心存储顺序。

```python
Expand All @@ -129,14 +131,6 @@ for val in dic1.values()
print(val.upper())
```

### 嵌套

#### 字典列表

#### 字典中的列表

#### 字典中的字典

### 语句(statement)

#### 布尔运算符(boolean operators)
Expand Down Expand Up @@ -270,17 +264,6 @@ Hello World!
### 转义字符



| | | |
| :------: | :--------------: | ---- |
| max(a,b) | 输出a和b的最大值 | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |

## Lambda Expressions

```
Expand Down
2 changes: 1 addition & 1 deletion docs/Computer Science/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

- [ ] [Programming Language: C](./Programming%20Language/C.md)
- [ ] [Programming Language: C++](Programming%20Language/C++/C++.md)
- [ ] [Programming Language: Python](./Programming%20Language/Python.md)
- [ ] [Programming Language: Python](./Programming%20Language/Python/Python.md)
- [ ] [Programming Language: Java](./Programming%20Language/Java.md) <**SUSPENDING**>

### Web
Expand Down
2 changes: 1 addition & 1 deletion docs/Math/Discrete Mathematics/09 Relations.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Let $R$ and $S$ be equivalence relations on the set $A$, then $R\cap S$ is also

However, $R\cup S$ is not necessarily an equivalence relation. It is indeed reflexive and symmetric. And $(R\cup S)^*$ is an equivalence relation.

### 9.6 Partial Orderings
## 9.6 Partial Orderings

**Partial Ordering**: A relation $R$ on a set $A$ is called a **partial ordering** or **partial order** if and only if $R$ is reflexive, antisymmetric and transitve. A set with a partial ordering is called a **partially ordered set** or **poset** and denoted by $(A, R)$.

Expand Down
47 changes: 44 additions & 3 deletions docs/Math/Discrete Mathematics/10 Graph Theory.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,14 @@ There is one unbounded region in a planar graph.

**Theorem 15** (Euler's Formula): Let $G$ be a **connected planar simple graph** with $e$ edges and $v$ vertices. Let $r$ be the number of regions in a planar representation of $G$. Then $r=e-v+2$.

**Proof**:
**Proof**: **OMITTED**.

**Degree of a Region**: Suppose $R$ is a region of a connected planar simple graph, the **number** of the edges on the boundary of $R$ is called the **Degree** of $R$, denoted by $\mathrm{Deg}(R)$.
**Degree of a Region**: Suppose $R$ is a region of a connected planar simple graph, the **number of the edges on the boundary** of $R$ is called the **Degree** of $R$, denoted by $\mathrm{Deg}(R)$.

**Corollary**: If $G$ is a connected planar simple graph with $e$ edges and $v$ vertices where $v\geqslant 3$, then $e\leqslant 3v-6$. The equality holds if and only if every region has exactly three edges.

**Proof**: From $2e = \sum \mathrm{Deg}(R) > 3r$, we can derive $r \leqslant \dfrac{2e}{3}$. Under the Euler's formula, we have $r = e - v + 2$, so $e - v + 2 \leqslant \dfrac{2e}{3}$, which means $e \leqslant 3v - 6$.

**Corollary**: If $G$ is a connected planar simple graph, then $G$ has a vertex of degree not exceeding five.

**Corollary**: If a connected planar simple graph has $e$ edges and $v$ vertices with $v\geqslant 3$ and no circuits of length $3$, then $e \leqslant 2v-4$. Generally, if every region of a connected planar simple graph has at least $k$ edges, then
Expand All @@ -268,4 +270,43 @@ $$e \leqslant \frac{k(v - 2)}{k - 2}.$$

## 10.8 Graph Coloring

## 10.9 Netflow
Each map in the plane can be represented by a graph, namely **the dual graph of the map**.

- Each region of the map is represented by a vertex.
- An edge connect two vertices if the regions represented by these vertices have a common border.
- Two regions that touch at only one point are not considered adjacent.

**Coloring**: A **coloring of a simple graph** is the assignment of a color to each vertex of the graph so that no two adjacent vertices are assigned the same color.

**Chromatic number/色数**: The **Chromatic number** of a graph is the **least number of colors needed** for a coloring of this graph, denoted by $x(G)$.


**The Four Color Theorem**: Every planar graph is $4$-colorable.

## 10.9 Netflow

**Flowgraph**: Directed graph with distinguished vertices s/source and t/sink.

**Capacities** on the edges: $:c(e) \geqslant 0$.

**Target**: Maximize the flow from $s$ to $t$ with the constraint that the flow on each edge does not exceed its capacity.

**Cut**: Partition of $V$ into disjoint sets $S$, $T$ with $s$ in $S$ and $t$ in $T$.

$Cap(S, T)$: Sum of the capacities of edges from $S$ to $T$.

$Flow(S, T)$: Net flow out of $S$, i.e. the sum of flows out of $S$ minus sum of flows into $S$.

**Residual Graph**: For flow graph $G$, the residual graph $G_f$ is defined as follows:

- $G$: Edge $e$ from $u$ to $v$ with capacity $c$ and flow $f$.
- $G_R$: Edge $e$ from $v$ to $u$ with capacity $f$.
- $G_R$: Edge $e$ from $u$ to $v$ with capacity $c-f$.

**Argumenting Path**: A path from $s$ to $t$ whose flow can be increased. Iff for all edges $f(u, v) < c(u, v)$ and $f(v, u) > 0$.

**Ford-Fulkerson Algorithm**: Build argument path until there is no forward path from source to sink.

**Augmenting path theorem**: Flow $f$ is a max flow iff there are no augmenting paths.

**Max-flow Min-cut Theorem**: The value of the max flow equals the capacity of the min cut.
2 changes: 1 addition & 1 deletion docs/Math/Discrete Mathematics/Discrete Mathematics.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
- [x] [Counting](./06%20Counting.md)
- [ ] [Advanced Counting Techniques](./08%20Advanced%20Counting%20Techniques.md)
- [x] [Relations](./09%20Relations.md)
- [ ] [Graph Theory](./10%20Graph%20Theory.md) (Omiting some proofs)
- [x] [Graph Theory](./10%20Graph%20Theory.md) (Omiting some proofs)
- [ ] [Trees](./11%20Trees.md)

0 comments on commit d5c98c4

Please sign in to comment.