Last active
December 26, 2016 17:39
-
-
Save gph03n1x/1f5e24c6669d1d698f7f to your computer and use it in GitHub Desktop.
Blog Codes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diffs = differ.compare(files_cache[file_name], log_file.read()) | |
diff_l = [diff for diff in diffs if re.search(diff_regex, diff)] | |
file_diffs[file_name] = "".join(diff_l) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file_diffs[file_name] = file_contents[len(files_cache[file_name]):] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>db.lists.count() | |
1626 | |
>db.urls.count() | |
4055 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
except urllib2.HTTPError: | |
if not (len(queue_item) > 2): | |
self.queue.put((self.current_url, self.depth, 1)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while (!openQueue.isEmpty()) { | |
currentNode = openQueue.poll(); | |
closedList.add(currentNode); | |
double firstDeg = 0; | |
double divisions = currentNode.actualNode.costs.size()+1; | |
for (Node neighbor: currentNode.actualNode.costs.keySet()){ | |
double wideX=80, wideY=80; | |
firstDeg +=1; | |
visualNode currentNeighbor = visualNodes.get(neighbor); | |
if (closedList.contains(currentNeighbor)) continue; | |
boolean positionedProperly = false; | |
while (!positionedProperly){ | |
// Ελένγχει αν έχει τοποθετηθεί πολύ κοντά ένας | |
// κόμβος σε έναν άλλον. | |
positionedProperly = true; | |
currentNeighbor.calcX(wideX, currentNode.x, firstDeg/divisions); | |
currentNeighbor.calcY(wideY, currentNode.y, firstDeg/divisions); | |
for (visualNode otherNode: closedList){ | |
double d = Math.sqrt(Math.pow(otherNode.x - currentNeighbor.x, 2)+Math.pow(otherNode.y - currentNeighbor.y, 2)); | |
if (d < shouldBeAwayDistance){ | |
positionedProperly = false; | |
break; | |
} | |
} | |
wideX += 50; | |
wideY += 50; | |
} | |
if (!closedList.contains(currentNeighbor)) { | |
openQueue.add(currentNeighbor); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Estimation until Bucharest | |
Timisoara 329 | |
Lugoj 246 | |
Mahadia 247 | |
Dobreta 242 | |
... | |
# Origin destination cost | |
Timisoara Arad 110 | |
Arad Zerind 75 | |
Arad Sibiu 140 | |
Zerind Oradea 71 | |
Oradea Sibiu 151 | |
Timisoara Lugoj 111 | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void constructGraph(){ | |
visualNodes.clear(); | |
visualEdges.clear(); | |
int count = 1; | |
for (String name: graph.graph.keySet()){ | |
visualNode currentNode = new visualNode(); | |
currentNode.actualNode = graph.graph.get(name); | |
currentNode.nodeNumberId = count; | |
currentNode.nodeCount = graph.graph.size(); | |
currentNode.nodeColor = graph.graph.get(name).nodeColor; | |
visualNodes.put(graph.graph.get(name), currentNode); | |
count +=1; | |
... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment