Exemplo n.º 1
0
from dependency_graph import DependencyGraph

dependencyGraph = DependencyGraph()

dependencyGraph.addVertex("A")
dependencyGraph.addVertex("B")
dependencyGraph.addVertex("C")
dependencyGraph.addVertex("D")

print "\n"
print dependencyGraph.es
print dependencyGraph.vs["A"]["depList"]
print dependencyGraph.vs["B"]["depList"]
print dependencyGraph.vs["C"]["depList"]
print dependencyGraph.vs["D"]["depList"]

dependencyGraph.addEdge("B", 2, "A")
dependencyGraph.addEdge("C", 5, "B")
dependencyGraph.addEdge("D", 1, "B")

print "\n"
print dependencyGraph.es
print dependencyGraph.vs["A"]["depList"]
print dependencyGraph.vs["B"]["depList"]
print dependencyGraph.vs["C"]["depList"]
print dependencyGraph.vs["D"]["depList"]

# dependencyGraph.setPrice("C", 2)
# print "-" * 40
# print "(A)", dependencyGraph.vs["A"]["directPrice"], "-", dependencyGraph.vs["A"]["craftPrice"]
# print "(B)", dependencyGraph.vs["B"]["directPrice"], "-", dependencyGraph.vs["B"]["craftPrice"]
Exemplo n.º 2
0
total = len(auctions)
count = 0

# loop through auctions and create dependency graph
for auction in auctions:
	count += 1

	if count % 1000 == 0:
		print count, "/", total, "(", (count / (total / 100)), "%)"

	auctionItem = str(auction["item"])
	auctionPrice = auction["buyout"]
	auctionQuant = auction["quantity"]
	auctionPricePU = float(auctionPrice) / auctionQuant

	dependencyGraph.addVertex(auctionItem)

	vertexPrice = dependencyGraph.getPrice(auctionItem)

	if vertexPrice > auctionPricePU:
		dependencyGraph.setPrice(auctionItem, auctionPricePU)

	edges = relationsGraph.getEdges(auctionItem)

	for edge in edges:
		dependencyGraph.addEdge(auctionItem, edge[0], edge[1])

# get a sorted list of craft / direct price differences
diffs = dependencyGraph.getPriceDiffs()

# dump price differences to file