Skip to content

Instantly share code, notes, and snippets.

View gleb-chipiga's full-sized avatar

Gleb Chipiga gleb-chipiga

  • Saint-Petersburg, Russia
View GitHub Profile
#!/usr/bin/python
import numpy as np
# Schulze Condorcet voting method:
# http://en.wikipedia.org/wiki/Schulze_method
def schulze(votes):
"""Input: An array of votes. In each row are the candidates' rankings. The
index of each entry in the row corresponds to a single candidate.
Only the relative rankings of candidates matter.
Lower numbers are better."""
"""
floyd_warshall_fastest() is a fast Python+NumPy implementation of the Floyd-Warshall algorithm
for finding the shortest path distances between all nodes of a weighted Graph. For more details see
http://en.wikipedia.org/wiki/Floyd-Warshall_algorithm
Tests and time comparisons to slower versions are provided.
Result of test_floyd_warshall_compatibility_on_large_matrix():
Matrix size: 100
Slow algorithm (with allocations): 0.726 seconds elapsed