-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalc.py
More file actions
55 lines (38 loc) · 1.76 KB
/
calc.py
File metadata and controls
55 lines (38 loc) · 1.76 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import numpy as np
from utils.dispatcher import dispatch
from utils.debugger import Logger
# set logging test update lcx added by wenake
logger = Logger(__name__)
def getINF():
"""
function:
return the INF of this tool.
parameters:
None, no parameter.
return:
int, the INF in this tools.
"""
from utils.settings import INF as inf
return inf
def calc(graph = None, useCUDA = True, useMultiPro = False, pathRecordBool = False, srclist = None, block = None, grid = None):
"""
function:
a calculate interface.
parameters:
graph: class Graph, must, the graph data that you want to get the shortest path.
(more info please see the developer documentation).
useCUDA: bool, use CUDA to speedup or not.
useMultiPro, bool, use multiprocessing in CPU or not. only support dijkstra APSP and MSSP.
pathRecordBool: bool, record the path or not.
srclist: int/lsit/None, the source list, can be [None, list, number].(more info please see the developer documentation).
block: tuple, a 3-tuple of integers as (x, y, z), the block size, to shape the kernal threads.
grid: tuple, a 2-tuple of integers as (x, y), the grid size, to shape the kernal blocks.
return:
class, Result object. (see the 'sparry/classes/result.py/Result')
"""
# turn to dispatch to dispatch
# we only accept graphic data in edgeSet format
logger.info(f"entering calc func...")
return dispatch(graph = graph, useCUDA = useCUDA, useMultiPro = useMultiPro, pathRecordBool = pathRecordBool, srclist = srclist, block = block, grid = grid)
if __name__ == "__main__":
calc()