没有合适的资源?快使用搜索试试~ 我知道了~
Lab-3 Report 1160300314 朱明彦1
试读
34页
需积分: 0 0 下载量 2 浏览量
更新于2022-08-03
收藏 1.82MB PDF 举报
实验报告“Lab-3 Report 1160300314 朱明彦1”涉及了软件构造课程中的面向复用和可维护性的软件设计原则,主要围绕图数据结构及其应用进行展开。报告中详细介绍了四个待开发的应用场景以及基于语法的图数据输入方法。以下是这些内容的详细说明:
1. 实验目标概述:
本次实验的主要目标是让学生理解并掌握面向复用的软件设计,通过实现通用的图数据结构,提高代码的复用性和可维护性。同时,通过构建不同的应用场景,使学生能够灵活运用图数据结构解决实际问题。
2. 实验环境配置:
实验可能需要的环境包括编程语言(如Java或Python)、集成开发环境(IDE)和版本控制系统等。具体的配置信息在报告中未提及,通常会包括操作系统、编译器或解释器版本、必要的库和框架等。
3. 实验过程:
实验过程主要分为四个部分:分析待开发的应用场景、设计图数据结构、实现基于语法的图数据输入和面向复用的设计。
3.1 待开发的四个应用场景:
- GraphPoet:可能是一个用于生成和可视化图形的工具,可以用来描绘各种复杂关系。
- SocialNetwork:模拟社交网络平台,展示用户之间的关系和互动。
- NetworkTopology:用于表示和管理网络设备的拓扑结构,如路由器、交换机的连接关系。
- MovieGraph:构建电影之间的关联图,如导演、演员、类型等关系。
3.2 基于语法的图数据输入:
这部分探讨了如何定义图数据的类型和标签,以及如何创建和操作图的节点(顶点)和边。
- GraphType、GraphLabel、VertexType、EdgeType:这些是定义图的元数据,用于描述图的整体类型、节点和边的标签,使得数据具有语义含义,方便后续处理。
- Vertex:表示图中的一个节点,通常包含一些属性,如标识符、属性值等。
- Edge:连接两个Vertex的连接线,可以表示两个节点之间的关系,同样可能携带属性信息。
- HyperEdge:扩展了边的概念,可以连接多个顶点,适合表示多对多的关系。
3.3 面向复用的设计:Graph<L, E>:
这里的Graph是一个泛型类,L代表图的标签类型,E代表边的类型。这种设计允许图结构适应不同场景,通过传入不同的L和E,可以创建具有特定语义的图实例,提高代码的灵活性和复用性。
3.4 面向复用的设计:Vertex:
Vertex类设计为可复用的,意味着它包含了一组通用的方法和属性,适用于所有类型的图。这样,无论在哪个应用场景下,只要修改或扩展其特定行为,就能快速地适应新需求。
整个实验报告的目的是通过实践来强化理论学习,使学生能够将面向复用和可维护性的设计理念融入到实际的软件开发中,提高编程技能和问题解决能力。在每个应用场景的实现过程中,都需要考虑如何有效地抽象和复用代码,以及如何设计良好的接口以支持未来的需求变更。
2018 年春季学期
计算机学院大二软件构造课程
Lab 3 实验报告
姓名
朱明彦
学号
1160300314
班号
1603003
电子邮件
1160300314@stu.hit.edu.cn
手机号码
18846082306
软件构造课程实验报告 实验 3:面向复用和可维护性的软件构造
目录
1 实验目标概述 ········································································································································· 1
2 实验环境配置 ········································································································································· 1
3 实验过程 ·················································································································································· 1
3.1 待开发的四个应用场景 ············································································································· 1
3.1.1 GraphPoet ·························································································································· 1
3.1.2 SocialNetwork ················································································································ 2
3.1.3 NetworkTopology ··········································································································· 2
3.1.4 MovieGraph························································································································ 2
3.2 基于语法的图数据输入 ············································································································· 2
3.2.1 GraphType、GraphLabel、VertexType、EdgeType ······································ 2
3.2.2 Vertex ·································································································································· 2
3.2.3 Edge ······································································································································· 3
3.2.4 HyperEdge ·························································································································· 3
3.3 面向复用的设计:Graph<L, E> ·························································································· 3
3.3.1 Graph<L, E> ····················································································································· 3
3.3.2 ConcreteGraph ················································································································ 4
3.4 面向复用的设计:Vertex ······································································································· 4
3.4.1 GraphPoet ·························································································································· 4
3.4.2 SocialNetwork ················································································································ 5
3.4.3 NetworkTopology ··········································································································· 5
3.4.4 MovieGraph························································································································ 5
3.5 面向复用的设计:Edge ············································································································ 6
3.5.1 DirectedEdge ·················································································································· 7
3.5.2 UndirectedEdge ······················································································································ 7
3.5.3 HyperEdge································································································································ 8
3.6 可复用 API 设计 ·························································································································· 9
3.6.1 degreeCentrality 的计算 ······································································································ 9
3.6.2 ClosenessCentrality 的计算 ································································································ 9
3.6.3 betweennessCentrality 的计算 ························································································ 10
软件构造课程实验报告 实验 3:面向复用和可维护性的软件构造
3.6.4 indegreeCentrality 和 outDegreeCentrality 的计算 ·················································· 10
3.6.5 distance 的计算 ···················································································································· 10
3.6.6 Eccentricity 的计算 ·············································································································· 10
3.6.7 radius 和 diameter 的计算 ································································································ 10
3.7 图的可视化:第三方 API 的复用(选做) ····································································· 11
3.8 设计模式应用 ····························································································································· 13
3.8.1 使用 State/Memento 模式进行 Vertex 的状态管理(选做) ······················ 13
3.8.2 使用 factory method 模式构造 Vertex 对象 ··················································· 14
3.8.3 使用 factory method 模式构造 Edge 对象 ························································ 14
3.8.4 使用 abstract factory 或 builder 模式构造 Graph 对象 ························ 14
3.8.5 使用 Strategy 模式调用 centrality 度量算法 ··············································· 14
3.8.6 使用 Composite 模式设计超边对象(选做) ······················································ 15
3.8.7 使用 decorator 模式构造不同特征的 Edge 对象(选做) ···························· 15
3.8.8 使用其他设计模式(选做) ························································································ 15
3.9 图操作指令的输入和处理(选做) ···················································································· 15
3.10 应用设计与开发 ······················································································································ 15
3.10.1 单词网络 GraphPoet ·································································································· 15
3.10.2 微博社交网络 SocialNetwork ··············································································· 24
3.10.3 网络拓扑图 NetworkTopology··············································································· 25
3.10.4 电影网络 MovieGraph ································································································ 26
3.11 应对四个应用面临的新变化(任选两个)···································································· 26
3.11.1 单词网络 GraphPoet ·································································································· 27
3.11.2 微博社交网络 SocialNetwork ··············································································· 28
3.11.3 网络拓扑图 NetworkTopology··············································································· 28
3.11.4 电影网络 MovieGraph ································································································ 28
4 实验进度记录 ······································································································································· 28
5 验过程中遇到的困难与解决途径 ·································································································· 29
6 实验过程中收获的经验、教训、感想 ························································································· 29
软件构造课程实验报告 实验 3:面向复用和可维护性的软件构造
1
1 实验目标概述
这一次的实验覆盖课程的第 3、5、6 章的内容,目标是编写具有可复用性和
可维护性的软件,主要使用以下软件构造技术:
⚫ 子类型、泛多态重写载
⚫ 继承、代理组合
⚫ 常见的 OO 设计模式
⚫ 语法驱动的编程 、正则表达式
⚫ 基于状态的编程
⚫ API 设计
2 实验环境配置
Java 环境在以前的实验中就已经配置好。
Git 环境也在以前的实验中配置好。
在这里给出你的 GitHub Lab3 仓库的 URL 地址(Lab3-学号)。
https://github.com/ComputerScienceHIT/Lab3-1160300314
3 实验过程
请仔细对照实验手册,针对每一项任务,在下面各节中记录你的实验过程、
阐述你的设计思路和问题求解思路,可辅之以示意图或关键源代码加以说明(但
千万不要把你的源代码全部粘贴过来!)。
3.1 待开发的四个应用场景
3.1.1 GraphPoet
对于 GraphPoet 这个应用场景来说,由于其不需要直接在文本上生成出某
个图,而是选择根据固定的图的输入格式来形成 GraphPoet,所以对于这个应用
场景主要的需求在于组织一个单模有向并且带权的图。
软件构造课程实验报告 实验 3:面向复用和可维护性的软件构造
2
3.1.2 SocialNetwork
对于 SocialNetwork 这个应用场景,主要是维持一个比较特殊的 Spec,即
所有边的权值之和为 1,这个条件在所有的该应用的场景下均可以维持。另外这
个应用场景允许多重边的存在。总的来说,SocialNetwork 需要维持一个单模、
有向、带权的多重图。
3.1.3 NetworkTopology
对于 NetworkTopology 这个应用场景主要是需要维持一个网络拓扑关系,与上
面两个场景的不同就在于每一个网络节点可能有多个不同的类型,即该图为多模
图。并且由于任意两个网络节点之间的联系都是双向的,所以这是一个无向图。
另外我们使用边上的权值记录网络带宽,又是一个带权图。
3.1.4 MovieGraph
对于 MovieGraph 来说其不同于以上几个图的点在于这是一个带有超边的图。并
且边的种类也有很多种,允许多个顶点之间有多种边。所以 MovieGraph 需要维
持一个带有超边的单重图多模图。
3.2 基于语法的图数据输入
基于语法的图的输入,其实主要在于如何将输入的文本合理解析。在所有的输入
文本中主要有四种不同的类型。
3.2.1 GraphType、GraphLabel、VertexType、EdgeType
对于上面四种情况的输入,都属于用等号分开的两部分:前半部分表示的是
这个操作的具体类型,比如是输入的节点类型等等。但对于其中的具体表示,比
如后半部分是不是真的是一种顶点的类型,如果也选择在此处进行判断会使这部
分的程序过于臃肿。因此,基于以上的考虑,选用了
^(GraphType|VertexType|EdgeType|GraphName) =
(\"[\w]+\")(, ?\"[\w]\")*$
进行匹配以上四种类型的输入语句。
3.2.2 Vertex
对于顶点的信息输入主要考虑的是,是否符合
Vertex = <Label
m
, type
m
,<attr
1
,...,attr
k
>>
这种形式;换句话说就是,是否包含了 Label、type 这种必要的信息。以及对
于一些没有属性值的简化到下面这种形式
剩余33页未读,继续阅读
资源推荐
资源评论
2022-08-03 上传
138 浏览量
2022-08-03 上传
2022-08-08 上传
130 浏览量
2022-08-03 上传
121 浏览量
2022-08-03 上传
199 浏览量
181 浏览量
2022-08-08 上传
200 浏览量
2021-05-18 上传
103 浏览量
2021-11-28 上传
149 浏览量
5星 · 资源好评率100%
184 浏览量
5星 · 资源好评率100%
169 浏览量
5星 · 资源好评率100%
资源评论
巴蜀明月
- 粉丝: 42
- 资源: 301
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功