-
-
Save szarnyasg/3a1961918f48ed4e5f47d30ae2c72956 to your computer and use it in GitHub Desktop.
This file contains 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
from igraph import * | |
import csv | |
import time | |
dataset = '/home/szarnyasg/graphs/example-directed' | |
g = Graph(directed=True) | |
g.es["weight"] = 1.0 | |
start_time = time.time() | |
print("================================= Loading ===================================="); | |
with open(dataset + '.e', 'r') as efile: | |
g = Graph.Read(efile, format='ncol') | |
print("%.2f seconds" % (time.time() - start_time)) | |
start_time = time.time() | |
print("=================================== BFS ===================================="); | |
bfs = g.shortest_paths_dijkstra(source = 0, weights=None) | |
print("%.2f seconds" % (time.time() - start_time)) | |
start_time = time.time() | |
print("=================================== SSSP ==================================="); | |
sssp = g.shortest_paths_dijkstra(source = 0, weights="weight") | |
print("%.2f seconds" % (time.time() - start_time)) | |
start_time = time.time() | |
print("=================================== WCC ===================================="); | |
wcc = g.as_undirected().components() | |
print("%.2f seconds" % (time.time() - start_time)) | |
# CDLP, LCC, and PR give different results or lack support for some cases | |
# # different results due to randomized algorithm | |
# print("=================================== CDLP ==================================="); | |
# print(g.community_label_propagation()) | |
# # directed definition is not supported | |
# print("=================================== LCC ===================================="); | |
# print(g.as_undirected().transitivity_local_undirected()) | |
# # different results due to fixed-point (eps) approach | |
# print("==================================== PR ===================================="); | |
# print(g.pagerank()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment