1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#!/usr/bin//python3
from __future__ import print_function
import sys
from community import best_partition, load_binary, modularity
def main():
"""Main function to mimic C++ version behavior"""
try:
filename = sys.argv[1]
graph_file = load_binary(filename)
partition = best_partition(graph_file)
print(str(modularity(partition, graph_file)), file=sys.stderr)
for elem, part in partition.items():
print(str(elem) + " " + str(part))
except (IndexError, IOError):
print("Usage : ./community filename")
print("find the communities in graph filename "
"and display the dendrogram")
print("Parameters:")
print("filename is a binary file as generated by the ")
print("convert utility distributed with the C implementation")
if __name__ == '__main__':
main()
|