MCPcopy
hub / github.com/dmlc/dgl / rep_per_node

Function rep_per_node

python/dgl/distgnn/tools/tools.py:20–54  ·  view source on GitHub ↗

Used on Libra partitioned data. This function reports number of split-copes per node (replication) of a partitioned graph Parameters ---------- prefix: Partition folder location (contains replicationlist.csv) num_community: number of partitions or communities

(prefix, num_community)

Source from the content-addressed store, hash-verified

18
19
20def rep_per_node(prefix, num_community):
21 """
22 Used on Libra partitioned data.
23 This function reports number of split-copes per node (replication) of
24 a partitioned graph
25 Parameters
26 ----------
27 prefix: Partition folder location (contains replicationlist.csv)
28 num_community: number of partitions or communities
29 """
30 ifile = os.path.join(prefix, "replicationlist.csv")
31 fhandle = open(ifile, "r")
32 r_dt = {}
33
34 fline = fhandle.readline() ## reading first line, contains the comment.
35 print(fline)
36 for line in fhandle:
37 if line[0] == "#":
38 raise DGLError("[Bug] Read Hash char in rep_per_node func.")
39
40 node = line.strip("\n")
41 if r_dt.get(node, -100) == -100:
42 r_dt[node] = 1
43 else:
44 r_dt[node] += 1
45
46 fhandle.close()
47 ## sanity checks
48 for v in r_dt.values():
49 if v >= num_community:
50 raise DGLError(
51 "[Bug] Unexpected event in rep_per_node() in tools.py."
52 )
53
54 return r_dt
55
56
57def download_proteins():

Callers

nothing calls this directly

Calls 5

DGLErrorClass · 0.90
joinMethod · 0.45
getMethod · 0.45
closeMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected