예제 #1
0
print "Vertex C outgoing"
print graph.V[2].Eo

print "Degree A"
print graph.deg_vertex(0)

print "Degree B"
print graph.deg_vertex(1)

print "Degree C"
print graph.deg_vertex(2)

print "Vertices"
print graph.list_vertices()
print "Edges"
print graph.list_edges()

print "Incident Edges A"
print graph.incident_edges(0)
print "Incident Edges B"
print graph.incident_edges(1)
print "Incident Edges C"
print graph.incident_edges(2)

graph.remove_vertex(0)

print "\nREMOVED VERTEX A\n"

print "Vertex B incoming"
print graph.V[1].Ei
print "Vertex B outgoing"
예제 #2
0
파일: tester.py 프로젝트: adekau/ClassWork
DFW_MIA = graph.new_edge(DFW, MIA, value=1120)
LGA_MIA = graph.new_edge(LGA, MIA, value=1099)
PVD_LGA = graph.new_edge(PVD, LGA, True, value=142)
PVD_MIA = graph.new_edge(PVD, MIA, value=1205)

print "Num vertices (should be 8)"
print graph.num_vertices()

print "\nNum edges (should be 12)"
print graph.num_edges()

print "\nVertices:"
print graph.list_vertices()

print "\nEdges:"
print graph.list_edges()

print "\nVertex test:"
print graph.vertex(graph.list_vertices()[0].getUid()).getLabel()

print "\nDegree vertices:"
for i, el in enumerate(graph.list_vertices()):
	print "Vertex " + str(el.getLabel()) + ": " + str(graph.deg_vertex(el.getUid()))

print "\nIncident Edges:"
for i, el in enumerate(graph.list_vertices()):
	print "Vertex " + str(el.getLabel()) + ": " + str(map(lambda x: x.getValue(), graph.incident_edges(el.getUid())))

print "\nAdjacent Vertices:"
for i, el in enumerate(graph.list_vertices()):
	print "Vertex " + str(el.getLabel()) + ": " + str(map(lambda x: x.getLabel(), graph.adjacent_vertices(el.getUid())))