Skip to content

Commit 592f446

Browse files
committed
684-redundant-connection.md Added a graph of tree.
1 parent 9d6aa6b commit 592f446

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

images/graph_tree_1.png

11.5 KB
Loading

solutions/1-1000/684-redundant-connection.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ Output: [1,4]
3232
- The given graph is connected.
3333

3434
## Intuition
35-
- This undirected graph has only **one** **connected component**, which is a tree.
35+
- In graph theory, a tree is an _undirected graph_ in which any two vertices are connected by exactly one path, or equivalently a **connected acyclic undirected graph**. Like this:
36+
![A labeled tree with six vertices and five edges.](../../images/graph_tree_1.png)
37+
3638
- When an edge is added to the graph, its two nodes are also added to the graph.
3739
- If the two nodes are already in the graph, then they must be on the same tree. At this time, a cycle is bound to be formed.
3840

@@ -44,9 +46,9 @@ Output: [1,4]
4446

4547
### 'UnionFind' algorithm
4648
- `UnionFind` algorithm typically has three methods:
47-
- The `unite(node1, node2)` operation can be used to merge two trees.
48-
- The `find_root(node)` method can be used to return the root of a node.
49-
- The `same_root(node1, node2)` method can be used to judge if two nodes are in the same tree.
49+
- The `unite(node1, node2)` operation is used to merge two trees.
50+
- The `find_root(node)` method is used to return the root of a node.
51+
- The `same_root(node1, node2)` method is used to determine whether two nodes are in the same tree.
5052

5153
## Approach (UnionFind algorithm)
5254
1. Initially, each node is in its own group.

solutions/1001-2000/1971-find-if-path-exists-in-graph-2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ This graph may have multiple **connected components**.
5454
- `UnionFind` algorithm typically has three methods:
5555
- The `unite(node1, node2)` operation can be used to merge two trees.
5656
- The `find_root(node)` method can be used to return the root of a node.
57-
- The `same_root(node1, node2)` method can be used to judge if two nodes are in the same tree.
57+
- The `same_root(node1, node2)` method is used to determine whether two nodes are in the same tree.
5858

5959
## Approach (UnionFind algorithm)
6060
1. Initially, each node is in its own group.

0 commit comments

Comments
 (0)