Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson19-diy1
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b13e2f60
authored
Apr 15, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
5e17500f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
1 deletions
1.py
2.py
bg.zip
client.py
1.py
0 → 100644
View file @
b13e2f60
# 用一个字典来表示无向图,节点为key,邻接点组成的list为value
graph
=
{
'A'
:
[
'B'
,
'C'
],
'B'
:
[
'A'
,
'C'
,
'D'
],
'C'
:
[
'A'
,
'B'
,
'D'
,
'E'
],
'D'
:
[
'B'
,
'C'
,
'E'
,
'F'
],
'E'
:
[
'C'
,
'D'
],
'F'
:
[
'D'
]
}
def
find_shortest_path
(
graph
:
dict
,
start_point
):
"""
:param graph: 传进来的图
:param start_point: 起始节点
:return:
"""
queue
=
[]
queue
.
append
(
start_point
)
# 储存已经访问过的节点
seen
=
set
()
seen
.
add
(
start_point
)
# 存储上一个节点
parent
=
{
start_point
:
None
}
while
len
(
queue
)
>
0
:
point
=
queue
.
pop
(
0
)
nodes
=
graph
[
point
]
for
node
in
nodes
:
# 如果这个节点没有被访问过
if
node
not
in
seen
:
queue
.
append
(
node
)
seen
.
add
(
node
)
parent
[
node
]
=
point
# print(point)
return
parent
if
__name__
==
'__main__'
:
parent_dict
=
find_shortest_path
(
graph
,
"A"
)
end
=
"E"
while
end
!=
None
:
print
(
end
,
end
=
'<-'
)
end
=
parent_dict
[
end
]
2.py
0 → 100644
View file @
b13e2f60
import
turtle
b
=
int
(
turtle
.
textinput
(
""
,
""
))
turtle
.
bgcolor
()
turtle
.
colormode
(
255
)
a
.
bgcolor
(
0
,
255
,
230
)
turtle
.
color
(
"red"
)
turtle
.
begin_fill
()
turtle
.
circle
(
100
)
turtle
.
end_fill
()
turtle
.
done
()
\ No newline at end of file
bg.zip
0 → 100644
View file @
b13e2f60
File added
client.py
View file @
b13e2f60
...
...
@@ -11,6 +11,7 @@ class Note(): # 便签、笔记
self
.
root
.
resizable
(
width
=
False
,
height
=
False
)
def
show
(
self
):
# 布置窗口界面
# 输入框
self
.
ent
=
tkinter
.
Entry
(
self
.
root
,
show
=
None
,
font
=
(
'宋体'
,
13
),
bg
=
"snow"
,
width
=
25
)
...
...
@@ -21,7 +22,8 @@ class Note(): # 便签、笔记
self
.
but
.
place
(
x
=
240
,
y
=
305
)
def
get_info
(
self
):
pass
kk
=
self
.
ent
.
get
()
app
=
Note
()
app
.
show
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment