Skip to content

Commit

Permalink
translation: refine translation of chapter_graph/graph.md (#1385)
Browse files Browse the repository at this point in the history
* refine translation of graph/graph.md

* Update graph.md
  • Loading branch information
yuelinxin authored Jul 12, 2024
1 parent f4a6d21 commit ff6d42b
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions en/docs/chapter_graph/graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ If vertices are viewed as nodes and edges as references (pointers) connecting th

![Relationship between linked lists, trees, and graphs](graph.assets/linkedlist_tree_graph.png)

## Common types of graphs
## Common types and terminologies of graphs

Based on whether edges have direction, graphs can be divided into <u>undirected graphs</u> and <u>directed graphs</u>, as shown in the figure below.
Graphs can be divided into <u>undirected graphs</u> and <u>directed graphs</u> depending on whether edges have direction, as shown in the figure below.

- In undirected graphs, edges represent a "bidirectional" connection between two vertices, for example, the "friendship" in WeChat or QQ.
- In directed graphs, edges have directionality, that is, the edges $A \rightarrow B$ and $A \leftarrow B$ are independent of each other, for example, the "follow" and "be followed" relationship on Weibo or TikTok.
- In undirected graphs, edges represent a "bidirectional" connection between two vertices, for example, the "friends" in Facebook.
- In directed graphs, edges have directionality, that is, the edges $A \rightarrow B$ and $A \leftarrow B$ are independent of each other. For example, the "follow" and "followed" relationship on Instagram or TikTok.

![Directed and undirected graphs](graph.assets/directed_graph.png)

Based on whether all vertices are connected, graphs can be divided into <u>connected graphs</u> and <u>disconnected graphs</u>, as shown in the figure below.
Depending on whether all vertices are connected, graphs can be divided into <u>connected graphs</u> and <u>disconnected graphs</u>, as shown in the figure below.

- For connected graphs, it is possible to reach any other vertex starting from a certain vertex.
- For disconnected graphs, there is at least one vertex that cannot be reached from a certain starting vertex.
- For connected graphs, it is possible to reach any other vertex starting from an arbitrary vertex.
- For disconnected graphs, there is at least one vertex that cannot be reached from an arbitrary starting vertex.

![Connected and disconnected graphs](graph.assets/connected_graph.png)

We can also add a weight variable to edges, resulting in <u>weighted graphs</u> as shown in the figure below. For example, in mobile games like "Honor of Kings", the system calculates the "closeness" between players based on shared gaming time, and this closeness network can be represented with a weighted graph.
We can also add a weight variable to edges, resulting in <u>weighted graphs</u> as shown in the figure below. For example, in Instagram, the system sorts your follower and following list by the level of interaction between you and other users (likes, views, comments, etc.). Such an interaction network can be represented by a weighted graph.

![Weighted and unweighted graphs](graph.assets/weighted_graph.png)

Expand All @@ -42,7 +42,7 @@ Graph data structures include the following commonly used terms.

## Representation of graphs

Common representations of graphs include "adjacency matrices" and "adjacency lists". The following examples use undirected graphs.
Common representations of graphs include "adjacency matrix" and "adjacency list". The following examples use undirected graphs.

### Adjacency matrix

Expand All @@ -55,10 +55,10 @@ As shown in the figure below, let the adjacency matrix be $M$, and the list of v
Adjacency matrices have the following characteristics.

- A vertex cannot be connected to itself, so the elements on the main diagonal of the adjacency matrix are meaningless.
- For undirected graphs, edges in both directions are equivalent, thus the adjacency matrix is symmetric about the main diagonal.
- By replacing the elements of the adjacency matrix from $1$ and $0$ to weights, it can represent weighted graphs.
- For undirected graphs, edges in both directions are equivalent, thus the adjacency matrix is symmetric with regard to the main diagonal.
- By replacing the elements of the adjacency matrix from $1$ and $0$ to weights, we can represent weighted graphs.

When representing graphs with adjacency matrices, it is possible to directly access matrix elements to obtain edges, thus operations of addition, deletion, lookup, and modification are very efficient, all with a time complexity of $O(1)$. However, the space complexity of the matrix is $O(n^2)$, which consumes more memory.
When representing graphs with adjacency matrices, it is possible to directly access matrix elements to obtain edges, resulting in efficient operations of addition, deletion, lookup, and modification, all with a time complexity of $O(1)$. However, the space complexity of the matrix is $O(n^2)$, which consumes more memory.

### Adjacency list

Expand All @@ -78,6 +78,6 @@ As shown in the table below, many real-world systems can be modeled with graphs,

| | Vertices | Edges | Graph Computing Problem |
| --------------- | ---------------- | --------------------------------------------- | -------------------------------- |
| Social Networks | Users | Friendships | Potential Friend Recommendations |
| Social Networks | Users | Follow / Followed | Potential Following Recommendations |
| Subway Lines | Stations | Connectivity Between Stations | Shortest Route Recommendations |
| Solar System | Celestial Bodies | Gravitational Forces Between Celestial Bodies | Planetary Orbit Calculations |

0 comments on commit ff6d42b

Please sign in to comment.