You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: solutions/1001-2000/1971-find-if-path-exists-in-graph-2.md
+52-52
Original file line number
Diff line number
Diff line change
@@ -40,14 +40,11 @@ Explanation: There is no path from vertex 0 to vertex 5.
40
40
Please see [1971. Find if Path Exists in Graph ('Breadth-First Search' Solution)](1971-find-if-path-exists-in-graph.md).
41
41
42
42
## Intuition
43
-
The island problem can be abstracted into a **graph theory** problem. This is an **undirected graph**:
44
-
45
-

46
-
47
-
And this graph may have multiple **connected components**. Initially, we start from `source` vertex which belongs to one of the `connected components`.
43
+
This graph may have multiple **connected components**.
48
44
49
45

50
46
47
+
- Initially, we start from `source` vertex which belongs to one of the `connected components`.
51
48
- We need to find if there is a path from `source` to `destination`. This question is equivalent to determine if `source` and `destination` vertices belong to the same `connected component`.
52
49
- A `tree` is a type of `graph`. If two nodes are in the same tree, then return `true`. So we need a method `in_same_tree(node1, node2)` to return a boolean value.
53
50
- We are given `edges` data and need to divide them into multiple groups, each group can be abstracted into a **tree**.
@@ -73,10 +70,10 @@ And this graph may have multiple **connected components**. Initially, we start f
Copy file name to clipboardExpand all lines: solutions/1001-2000/1971-find-if-path-exists-in-graph.md
+2-5
Original file line number
Diff line number
Diff line change
@@ -40,14 +40,11 @@ Explanation: There is no path from vertex 0 to vertex 5.
40
40
Please see [1971. Find if Path Exists in Graph (UnionFind Solution)](1971-find-if-path-exists-in-graph-2.md).
41
41
42
42
## Intuition
43
-
The island problem can be abstracted into a **graph theory** problem. This is an **undirected graph**:
44
-
45
-

46
-
47
-
And this graph may have multiple **connected components**. Initially, we start from `source` vertex which belongs to one of the `connected components`.
43
+
This graph may have multiple **connected components**.
48
44
49
45

50
46
47
+
Initially, we start from `source` vertex which belongs to one of the `connected components`.
51
48
We need to find if there is a path from `source` to `destination`. This question is equivalent to determine if `source` and `destination` vertices belong to the same `connected component`.
0 commit comments