-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuseGraph.py
43 lines (33 loc) · 984 Bytes
/
useGraph.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-
"""
Created on Beijing Aug 17 01:26:52 2018
@author: xuyingjie
"""
from Graph import *
y = GraphInformation()
x = GraphOperator()
# 插入顶点(Persion 类型)
x.insertVertex('1','xiaoming','20', 'Persion')
for vertex in y.pro_graph_vertex:
print(vertex)
print('\n')
# 插入顶点(Company 类型)
x.insertVertex('8','chagnhong','Company')
for vertex in y.pro_graph_vertex:
print(vertex)
print('\n')
# 插入边权信息 例: 3 --> 2 , property:Belong , weight:9
x.insertEdge('3', '2', 'Belong', 9)
for edge in y.pro_graph_edge:
print(edge)
print('\n')
# 获取类型为 Persion 的所有顶点信息
x.getVertexs('verType', 'Persion')
print('\n')
# 获取年龄为 20 的所有顶点信息
x.getVertexs('age', '20')
print('\n')
# 获取类型为 Persion 的所有顶点信息
x.getVertexs('verType','Company')
# 实现任意两个Vertex间的最短路径的计算
x.dijkstraModify('2', '7')