forked from ParAlg/gbbs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gbbs.py
31 lines (28 loc) · 1005 Bytes
/
gbbs.py
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
27
28
29
30
31
from gbbs_lib import *
import gbbs_lib
import os
def loadGraph(graphPath="",undirected=True, compressed=False, binary=False):
if (graphPath == ""):
print("Expect a non-empty path to the graph input file")
exit(0)
if (undirected):
if (compressed):
return gbbs_lib.readCompressedSymmetricUnweightedGraph(graphPath)
else:
return gbbs_lib.readSymmetricUnweightedGraph(graphPath, binary)
else:
if (compressed):
return gbbs_lib.readCompressedAsymmetricUnweightedGraph(graphPath)
else:
return gbbs_lib.readAsymmetricUnweightedGraph(graphPath, binary)
def loadSnap(graphPath="",undirected=True):
if (graphPath == ""):
print("Expect a non-empty path to the graph input file")
exit(0)
graphName = os.path.splitext(graphPath)[0]+'.adj'
if (undirected):
return gbbs_lib.loadSymmetricEdgeListAsGraph(graphPath, graphName)
else:
return gbbs_lib.loadAsymmetricEdgeListAsGraph(graphPath, graphName)
print("Unsupported options")
exit(0)