面向对象举例(一) —— 顶点(vertex)、边(edge)与图(graph)
来源:互联网 发布:淘宝手机搜索不精准 编辑:程序博客网 时间:2024/04/30 12:36
Graph:
class Graph(dict): def __init__(self, vs=[], es=[]): for v in vs: self.add_vertex(v) for e in es: self.add_edge(e) # 必须全部的顶点添加完毕之后,才可以添加新的边进去 def add_vertex(self, v): self[v] = {} def add_edge(self, e): v, w = e self[v][w] = e self[w][v] = e # 无向边以双向连接的方式实现;
vertex:
class Vertex(object): def __init__(self, label=''): self.label = label der __repr__(self): return 'Vertex(%s)' % self.label __str__ = __repr__
edge:
class Edge(tuple): def __new__(cls, e1, e2): return tuple.__new__(cls, (e1, e2)) def __repr(self): return 'Edge(%s, %s)' % (repr(self[0]), repr(self[1])) __str__ = __repr__
0 0
- 面向对象举例(一) —— 顶点(vertex)、边(edge)与图(graph)
- OpenGL顶点数组对象(vertex Array Object)VAO
- 面向对象(举例)
- OpenGl Vertex Atrributes(顶点属性)
- Unity3D shader(6)——vertex shader(顶点颜色变换)
- 基于图(graph)的应用举例
- 静态模型的Lightmap(光照贴图)与Vertex-Lighting(顶点光照)之比较(转)
- 静态模型的Lightmap(光照贴图)与Vertex-Lighting(顶点光照)之比较(转
- 静态模型的Lightmap(光照贴图)与Vertex-Lighting(顶点光照)比较
- DirectX 编程 第四步: 顶点(Vertex)绘图
- Introduction to Vertex Textures(顶点纹理介绍)---转
- 【Reading Notes】CP5-Vertex Functions (着色器顶点处理)
- C++面向对象(一)——类与对象
- Unity3D shader(5)——vertex shader(一)
- 【JavaScript】——剖析面向对象与原型(一)
- 面向对象(一)
- 面向对象(一)
- 面向对象(一)
- 第十五周项目1(3)——验证希尔排序
- hibernate 一对多,多对一,一对一,多对多 映射
- 51nod 异或凑数
- 令人振奋的好消息!2016年12月8日Google Developers中文网站发布!
- 遍历Map
- 面向对象举例(一) —— 顶点(vertex)、边(edge)与图(graph)
- Linux zip 与 unzip 的用法
- 第十五周 项目一(3)冒泡排序
- Hough变换原理
- 二叉树遍历之morris traversal
- python-vegetables bird 1
- time元素
- spark-submit提交任务的方式
- 移动立方体算法(MC)