Skip to content

Commit 4800fd9

Browse files
committed
图的复制
1 parent e7e5ab2 commit 4800fd9

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

LeetCode/Doc/图的复制.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# clone-graph(图的复制)
2+
3+
<center>知识点:图</center>
4+
5+
## 题目描述
6+
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.
7+
8+
9+
OJ's undirected graph serialization:
10+
Nodes are labeled uniquely.
11+
12+
We use # as a separator for each node, and,as a separator for node label and each neighbor of the node.
13+
14+
As an example, consider the serialized graph{0,1,2# 1,2# 2,2}.
15+
16+
The graph has a total of three nodes, and therefore contains three parts as separated by#.
17+
18+
First node is labeled as 0. Connect node 0 to both node s1 and 2.
19+
Second node is labeled as 1. Connect node 1 to node 2.
20+
Third node is labeled as 2. Connect node 2 to node2(itself), thus forming a self-cycle.
21+
22+
Visually, the graph looks like the following:
23+
24+
复制一个无向图,图中的每一个节点都有一个标签,以及其若干个邻居节点。
25+
OJ的无向图序列:
26+
节点被唯一标志
27+
我们使用#作为每一个节点的分隔符以及节点和其邻居节点的分隔符
28+
比如,考虑一个{0,1,2# 1,2# 2,2}序列
29+
该图一共有3个节点,被#分隔为3个部分
30+
第一个节点的标志是0,连接节点1和节点2
31+
第二个节点是1,连接节点1和节点2
32+
第三个节点是2,连接节点2和节点2(自己),即形成了一个自环
33+
将上图可视化出来就是这样的:
34+
35+
![image-20190725212103586](http://picture-pool.oss-cn-beijing.aliyuncs.com/2019-07-25-132104.png)
36+
37+
38+
## 解题思路
39+
40+
41+
42+
## 代码
43+
44+
[这里](../src/n/Solution.java)

0 commit comments

Comments
 (0)