예제 #1
0
파일: tester.py 프로젝트: adekau/ClassWork
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())))

print "\nEnd Vertices:"
for i, el in enumerate(graph.list_edges()):
예제 #2
0
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)


print "\n"
print graph.vertex(0).aV
print graph.vertex(1).aV

graph.remove_edge(0)

print "\nREMOVED EDGE\n"

print "Vertex A incoming"
print graph.V[0].Ei
print "Vertex A outgoing"
print graph.V[0].Eo
print "Vertex B incoming"
print graph.V[1].Ei
print "Vertex B outgoing"
print graph.V[1].Eo
print "Vertex C incoming"
예제 #3
0
graph.new_vertex("A")  #0
graph.new_vertex("B")  #1
graph.new_vertex("C")  #2

#Edges-Undirected
graph.new_edge(0, 1)  #0
graph.new_edge(0, 1, True)  #1
graph.new_edge(1, 2)  #2
graph.new_edge(2, 1, True)  #3
graph.new_edge(2, 2)  #4

print "Memory Addresses"
print graph.list_vertices()

print "A Adjacency"
print graph.vertex(0).aV
print "B Adjacency"
print graph.vertex(1).aV
print "C Adjacency"
print graph.vertex(2).aV

print "\nDuplicate using function\n"

print "A Adjacency"
print graph.adjacent_vertices(0)
print "B Adjacency"
print graph.adjacent_vertices(1)
print "C Adjacency"
print graph.adjacent_vertices(2)

# End vertices