From 93ab890b30408dcedf13557d4177ba228088d615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A4=A9=E5=AE=9D=5FGit=E5=AE=9E=E8=B7=B5?= Date: Wed, 12 Apr 2023 20:46:26 +0800 Subject: [PATCH] 123 --- 人工智能/.idea/.gitignore | 3 + .../inspectionProfiles/profiles_settings.xml | 6 + 人工智能/.idea/misc.xml | 4 + 人工智能/.idea/modules.xml | 8 + 人工智能/.idea/pythonProject1.iml | 10 + 人工智能/main.py | 39 +++ 人工智能/name - 副本.csv | 22 ++ 人工智能/name.csv | 4 + 人工智能/relation - 副本.csv | 11 + 人工智能/relation.csv | 4 + 人工智能/简单关系图.html | 265 ++++++++++++++++++ 11 files changed, 376 insertions(+) create mode 100644 人工智能/.idea/.gitignore create mode 100644 人工智能/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 人工智能/.idea/misc.xml create mode 100644 人工智能/.idea/modules.xml create mode 100644 人工智能/.idea/pythonProject1.iml create mode 100644 人工智能/main.py create mode 100644 人工智能/name - 副本.csv create mode 100644 人工智能/name.csv create mode 100644 人工智能/relation - 副本.csv create mode 100644 人工智能/relation.csv create mode 100644 人工智能/简单关系图.html diff --git a/人工智能/.idea/.gitignore b/人工智能/.idea/.gitignore new file mode 100644 index 0000000..359bb53 --- /dev/null +++ b/人工智能/.idea/.gitignore @@ -0,0 +1,3 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml diff --git a/人工智能/.idea/inspectionProfiles/profiles_settings.xml b/人工智能/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/人工智能/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/人工智能/.idea/misc.xml b/人工智能/.idea/misc.xml new file mode 100644 index 0000000..2e02ba2 --- /dev/null +++ b/人工智能/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/人工智能/.idea/modules.xml b/人工智能/.idea/modules.xml new file mode 100644 index 0000000..fdd8fdf --- /dev/null +++ b/人工智能/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/人工智能/.idea/pythonProject1.iml b/人工智能/.idea/pythonProject1.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/人工智能/.idea/pythonProject1.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/人工智能/main.py b/人工智能/main.py new file mode 100644 index 0000000..819b05a --- /dev/null +++ b/人工智能/main.py @@ -0,0 +1,39 @@ +from pyecharts import options as opts +from pyecharts.charts import Graph +from pyecharts.globals import CurrentConfig +import csv + +# 设置 echarts 的在线主机 +CurrentConfig.ONLINE_HOST = "http://cdn.jsdelivr.net/npm/echarts@4.9.0/dist/" + +# 读取名字文件,并添加节点 +nodes = [] +with open('name.csv') as f: + reader = csv.reader(f) + for line in reader: + nodes.append(opts.GraphNode(name=line[0])) + +# 读取关系文件,并添加关系 +links = [] +with open('relation.csv') as f: + reader = csv.reader(f) + next(reader) # 跳过标题行 + for line in reader: + links.append(opts.GraphLink(source=line[0], target=line[1], value=line[2])) + +# 生成关系图 +c = ( + Graph() + .add("", nodes, links, repulsion=4000, + edge_label=opts.LabelOpts(is_show=True, position="middle", formatter="{c}")) + .set_global_opts( + title_opts=opts.TitleOpts(title="简单关系图", subtitle="by pyecharts"), + legend_opts=opts.LegendOpts(is_show=True), + tooltip_opts=opts.TooltipOpts(trigger="item"), + visualmap_opts=opts.VisualMapOpts(max_=10, min_=0), + toolbox_opts=opts.ToolboxOpts(is_show=True), + xaxis_opts=opts.AxisOpts(is_show=True), + yaxis_opts=opts.AxisOpts(is_show=True), + ) +) +c.render("简单关系图.html") diff --git a/人工智能/name - 副本.csv b/人工智能/name - 副本.csv new file mode 100644 index 0000000..1bb23f3 --- /dev/null +++ b/人工智能/name - 副本.csv @@ -0,0 +1,22 @@ + + +ŷ + +ܲ + +Ȩ + + +ا +ֲ + + +Ԭ +Ԭ + +κ + +A +˾ܲ +ܲ +ӷ \ No newline at end of file diff --git a/人工智能/name.csv b/人工智能/name.csv new file mode 100644 index 0000000..14246d4 --- /dev/null +++ b/人工智能/name.csv @@ -0,0 +1,4 @@ +Tom +Jerry +Lucy +John diff --git a/人工智能/relation - 副本.csv b/人工智能/relation - 副本.csv new file mode 100644 index 0000000..fc04ea2 --- /dev/null +++ b/人工智能/relation - 副本.csv @@ -0,0 +1,11 @@ +, ,5 +, ŷ,5 +, ,5 +ܲ, ,5 +ܲ, ,5 +Ȩ, ,5 +, ŷ,5 +, ŷ,5 +ا, ֲ,5 +, ,5 +Ԭ, Ԭ,5 diff --git a/人工智能/relation.csv b/人工智能/relation.csv new file mode 100644 index 0000000..a0cc0d5 --- /dev/null +++ b/人工智能/relation.csv @@ -0,0 +1,4 @@ +Tom,Jerry,5 +Tom,Lucy,3 +Jerry,Lucy,4 +John,Tom,2 diff --git a/人工智能/简单关系图.html b/人工智能/简单关系图.html new file mode 100644 index 0000000..14a11d8 --- /dev/null +++ b/人工智能/简单关系图.html @@ -0,0 +1,265 @@ + + + + + Awesome-pyecharts + + + + +
+ + +